MCPcopy Create free account
hub / github.com/KDE/kdevelop / fillContextMenu

Method fillContextMenu

plugins/clang/codegen/clangrefactoring.cpp:63–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void ClangRefactoring::fillContextMenu(ContextMenuExtension& extension, Context* context, QWidget* parent)
64{
65 auto declContext = dynamic_cast<DeclarationContext*>(context);
66 if (!declContext) {
67 return;
68 }
69
70 DUChainReadLocker lock;
71
72 auto declaration = declContext->declaration().data();
73 if (!declaration) {
74 return;
75 }
76
77 QFileInfo fileInfo(declaration->topContext()->url().str());
78 if (!fileInfo.isWritable()) {
79 return;
80 }
81
82 auto action = new QAction(i18nc("@action", "Rename %1", declaration->qualifiedIdentifier().toString()), parent);
83 action->setData(QVariant::fromValue(IndexedDeclaration(declaration)));
84 action->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename")));
85 connect(action, &QAction::triggered, this, &ClangRefactoring::executeRenameAction);
86
87 extension.addAction(ContextMenuExtension::RefactorGroup, action);
88
89 if (!validCandidateToMoveIntoSource(declaration)) {
90 return;
91 }
92
93 action = new QAction(
94 i18n("Create separate definition for %1", declaration->qualifiedIdentifier().toString()), parent);
95 action->setData(QVariant::fromValue(IndexedDeclaration(declaration)));
96 connect(action, &QAction::triggered, this, &ClangRefactoring::executeMoveIntoSourceAction);
97 extension.addAction(ContextMenuExtension::RefactorGroup, action);
98}
99
100bool ClangRefactoring::validCandidateToMoveIntoSource(Declaration* decl)
101{

Callers 1

contextMenuExtensionMethod · 0.45

Calls 12

strMethod · 0.80
setIconMethod · 0.80
IndexedDeclarationClass · 0.50
dataMethod · 0.45
declarationMethod · 0.45
urlMethod · 0.45
topContextMethod · 0.45
isWritableMethod · 0.45
toStringMethod · 0.45
qualifiedIdentifierMethod · 0.45
setDataMethod · 0.45
addActionMethod · 0.45

Tested by

no test coverage detected