forked from qt-creator/qt-creator
Clang: implement globalRename based on clang Index
Has the same limitations as findUsages. Change-Id: I8de4df2ecbfd8a4f3073666994398dc43af0d73c Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -50,11 +50,29 @@ void CppRefactoringEngine::startLocalRenaming(const CursorInEditor &data,
|
||||
data.cursor().document()->revision());
|
||||
}
|
||||
|
||||
void CppRefactoringEngine::startGlobalRenaming(const CursorInEditor &data)
|
||||
void CppRefactoringEngine::globalRename(const CursorInEditor &data,
|
||||
UsagesCallback &&,
|
||||
const QString &replacement)
|
||||
{
|
||||
CppModelManager *modelManager = CppModelManager::instance();
|
||||
if (!modelManager)
|
||||
return;
|
||||
|
||||
CppEditorWidgetInterface *editorWidget = data.editorWidget();
|
||||
QTC_ASSERT(editorWidget, return;);
|
||||
editorWidget->renameUsages();
|
||||
|
||||
SemanticInfo info = editorWidget->semanticInfo();
|
||||
info.snapshot = modelManager->snapshot();
|
||||
info.snapshot.insert(info.doc);
|
||||
const QTextCursor &cursor = data.cursor();
|
||||
if (const CPlusPlus::Macro *macro = findCanonicalMacro(cursor, info.doc)) {
|
||||
modelManager->renameMacroUsages(*macro, replacement);
|
||||
} else {
|
||||
CanonicalSymbol cs(info.doc, info.snapshot);
|
||||
CPlusPlus::Symbol *canonicalSymbol = cs(cursor);
|
||||
if (canonicalSymbol)
|
||||
modelManager->renameUsages(canonicalSymbol, cs.context(), replacement);
|
||||
}
|
||||
}
|
||||
|
||||
void CppRefactoringEngine::findUsages(const CursorInEditor &data,
|
||||
|
||||
Reference in New Issue
Block a user