Changeset View
Changeset View
Standalone View
Standalone View
languages/clang/codegen/clangrefactoring.cpp
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | |||||
70 | } | 70 | } | ||
71 | 71 | | |||
72 | ClangRefactoring::ClangRefactoring(QObject* parent) | 72 | ClangRefactoring::ClangRefactoring(QObject* parent) | ||
73 | : BasicRefactoring(parent) | 73 | : BasicRefactoring(parent) | ||
74 | { | 74 | { | ||
75 | qRegisterMetaType<IndexedDeclaration>(); | 75 | qRegisterMetaType<IndexedDeclaration>(); | ||
76 | } | 76 | } | ||
77 | 77 | | |||
78 | void ClangRefactoring::fillContextMenu(ContextMenuExtension& extension, Context* context) | 78 | void ClangRefactoring::fillContextMenu(ContextMenuExtension& extension, Context* context, QWidget* parent) | ||
79 | { | 79 | { | ||
80 | auto declContext = dynamic_cast<DeclarationContext*>(context); | 80 | auto declContext = dynamic_cast<DeclarationContext*>(context); | ||
81 | if (!declContext) { | 81 | if (!declContext) { | ||
82 | return; | 82 | return; | ||
83 | } | 83 | } | ||
84 | 84 | | |||
85 | DUChainReadLocker lock; | 85 | DUChainReadLocker lock; | ||
86 | 86 | | |||
87 | auto declaration = declContext->declaration().data(); | 87 | auto declaration = declContext->declaration().data(); | ||
88 | if (!declaration) { | 88 | if (!declaration) { | ||
89 | return; | 89 | return; | ||
90 | } | 90 | } | ||
91 | 91 | | |||
92 | QFileInfo fileInfo(declaration->topContext()->url().str()); | 92 | QFileInfo fileInfo(declaration->topContext()->url().str()); | ||
93 | if (!fileInfo.isWritable()) { | 93 | if (!fileInfo.isWritable()) { | ||
94 | return; | 94 | return; | ||
95 | } | 95 | } | ||
96 | 96 | | |||
97 | auto action = new QAction(i18n("Rename %1", declaration->qualifiedIdentifier().toString()), this); | 97 | auto action = new QAction(i18n("Rename %1", declaration->qualifiedIdentifier().toString()), parent); | ||
98 | action->setData(QVariant::fromValue(IndexedDeclaration(declaration))); | 98 | action->setData(QVariant::fromValue(IndexedDeclaration(declaration))); | ||
99 | action->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename"))); | 99 | action->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename"))); | ||
100 | connect(action, &QAction::triggered, this, &ClangRefactoring::executeRenameAction); | 100 | connect(action, &QAction::triggered, this, &ClangRefactoring::executeRenameAction); | ||
101 | 101 | | |||
102 | extension.addAction(ContextMenuExtension::RefactorGroup, action); | 102 | extension.addAction(ContextMenuExtension::RefactorGroup, action); | ||
103 | 103 | | |||
104 | if (!validCandidateToMoveIntoSource(declaration)) { | 104 | if (!validCandidateToMoveIntoSource(declaration)) { | ||
105 | return; | 105 | return; | ||
106 | } | 106 | } | ||
107 | 107 | | |||
108 | action = new QAction( | 108 | action = new QAction( | ||
109 | i18n("Create separate definition for %1", declaration->qualifiedIdentifier().toString()), this); | 109 | i18n("Create separate definition for %1", declaration->qualifiedIdentifier().toString()), parent); | ||
110 | action->setData(QVariant::fromValue(IndexedDeclaration(declaration))); | 110 | action->setData(QVariant::fromValue(IndexedDeclaration(declaration))); | ||
111 | connect(action, &QAction::triggered, this, &ClangRefactoring::executeMoveIntoSourceAction); | 111 | connect(action, &QAction::triggered, this, &ClangRefactoring::executeMoveIntoSourceAction); | ||
112 | extension.addAction(ContextMenuExtension::RefactorGroup, action); | 112 | extension.addAction(ContextMenuExtension::RefactorGroup, action); | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | bool ClangRefactoring::validCandidateToMoveIntoSource(Declaration* decl) | 115 | bool ClangRefactoring::validCandidateToMoveIntoSource(Declaration* decl) | ||
116 | { | 116 | { | ||
117 | if (!decl || !decl->isFunctionDeclaration() || !decl->type<FunctionType>()) { | 117 | if (!decl || !decl->isFunctionDeclaration() || !decl->type<FunctionType>()) { | ||
▲ Show 20 Lines • Show All 173 Lines • Show Last 20 Lines |