CppEditor: add startGlobalRenaming

Existing built-in functionality is moved there.
Clang part is to be implemented later

Change-Id: I7595898495213c087243cd534b4ba1617b4c27e9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Ivan Donchevskii
2017-08-04 10:18:41 +02:00
parent c3c9fbfc44
commit 32b1244b2a
6 changed files with 20 additions and 2 deletions

View File

@@ -84,6 +84,11 @@ void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
server.requestSourceLocationsForRenamingMessage(std::move(message));
}
void RefactoringEngine::startGlobalRenaming(const CppTools::CursorInEditor &)
{
// TODO: implement
}
bool RefactoringEngine::isUsable() const
{
return server.isUsable();

View File

@@ -42,6 +42,7 @@ public:
void startLocalRenaming(const CppTools::CursorInEditor &data,
CppTools::ProjectPart *projectPart,
RenameCallback &&renameSymbolsCallback) override;
void startGlobalRenaming(const CppTools::CursorInEditor &data) override;
bool isUsable() const override;
void setUsable(bool isUsable);

View File

@@ -546,8 +546,10 @@ void CppEditorWidget::renameSymbolUnderCursor()
setExtraSelections(TextEditor::TextEditorWidget::CodeSemanticsSelection, selections);
d->m_localRenaming.updateSelectionsForVariableUnderCursor(selections);
}
if (!d->m_localRenaming.start()) // Rename local symbol
renameUsages(); // Rename non-local symbol or macro
if (!d->m_localRenaming.start()) {
refactoringEngine()->startGlobalRenaming(
CppTools::CursorInEditor{textCursor(), textDocument()->filePath(), this});
}
}
};

View File

@@ -46,5 +46,13 @@ void CppRefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &da
editorWidget->document()->revision());
}
void CppRefactoringEngine::startGlobalRenaming(const CppTools::CursorInEditor &data)
{
CppEditorWidget *editorWidget = static_cast<CppEditorWidget *>(data.editorWidget());
if (!editorWidget)
return;
editorWidget->renameUsages();
}
} // namespace Internal
} // namespace CppEditor

View File

@@ -38,6 +38,7 @@ public:
void startLocalRenaming(const CppTools::CursorInEditor &data,
CppTools::ProjectPart *projectPart,
RenameCallback &&renameSymbolsCallback) override;
void startGlobalRenaming(const CppTools::CursorInEditor &data) override;
bool isUsable() const override { return true; }
};

View File

@@ -54,6 +54,7 @@ public:
virtual void startLocalRenaming(const CursorInEditor &data,
CppTools::ProjectPart *projectPart,
RenameCallback &&renameSymbolsCallback) = 0;
virtual void startGlobalRenaming(const CursorInEditor &data) = 0;
virtual bool isUsable() const = 0;
};