diff options
author | hjk <hjk@qt.io> | 2024-01-25 15:52:51 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2024-01-26 12:16:52 +0000 |
commit | 9cc3988acd78d19ae4ae1881b97ff31003c4837d (patch) | |
tree | fe00f876a2fc9789a2dc7ce3943702857526ba5e /src/plugins/cppeditor | |
parent | 3c9238d29ae6ae360b1b06f9456048187347bc01 (diff) |
CppEditor: Remove some CppEditorPlugin member functions
Inline renameSymbolUnderCursor() and switchDeclarationDefinition()
implementation on the caller side. Also use the widget that's known
there instead of the currentCppEditorWidget().
Change-Id: I158bef34234ce199accf25861062c97491bea381
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/cppeditor')
-rw-r--r-- | src/plugins/cppeditor/cppeditorplugin.cpp | 12 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditorplugin.h | 3 | ||||
-rw-r--r-- | src/plugins/cppeditor/fileandtokenactions_test.cpp | 11 | ||||
-rw-r--r-- | src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp | 2 |
4 files changed, 8 insertions, 20 deletions
diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index aeda4b1fede..7852855763e 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -511,18 +511,6 @@ void CppEditorPlugin::registerTests() #endif } -void CppEditorPlugin::switchDeclarationDefinition() -{ - if (CppEditorWidget *editorWidget = currentCppEditorWidget()) - editorWidget->switchDeclarationDefinition(/*inNextSplit*/ false); -} - -void CppEditorPlugin::renameSymbolUnderCursor() -{ - if (CppEditorWidget *editorWidget = currentCppEditorWidget()) - editorWidget->renameSymbolUnderCursor(); -} - void CppEditorPluginPrivate::onTaskStarted(Id type) { if (type == Constants::TASK_INDEX) { diff --git a/src/plugins/cppeditor/cppeditorplugin.h b/src/plugins/cppeditor/cppeditorplugin.h index 85a038060b2..4e12c3a322a 100644 --- a/src/plugins/cppeditor/cppeditorplugin.h +++ b/src/plugins/cppeditor/cppeditorplugin.h @@ -22,9 +22,6 @@ public: static void clearHeaderSourceCache(); - void renameSymbolUnderCursor(); - void switchDeclarationDefinition(); - private: void initialize() override; void extensionsInitialized() override; diff --git a/src/plugins/cppeditor/fileandtokenactions_test.cpp b/src/plugins/cppeditor/fileandtokenactions_test.cpp index 66f9e5d31eb..ca6411116f8 100644 --- a/src/plugins/cppeditor/fileandtokenactions_test.cpp +++ b/src/plugins/cppeditor/fileandtokenactions_test.cpp @@ -330,13 +330,14 @@ public: void run(CppEditorWidget *) override; }; -void SwitchDeclarationDefinitionTokenAction::run(CppEditorWidget *) +void SwitchDeclarationDefinitionTokenAction::run(CppEditorWidget *editorWidget) { // Switch Declaration/Definition IEditor *editorBefore = EditorManager::currentEditor(); const int originalLine = editorBefore->currentLine(); const int originalColumn = editorBefore->currentColumn(); - CppEditorPlugin::instance()->switchDeclarationDefinition(); + if (editorWidget) + editorWidget->switchDeclarationDefinition(/*inNextSplit*/ false); QApplication::processEvents(); // Go back @@ -368,9 +369,11 @@ public: void run(CppEditorWidget *) override; }; -void RenameSymbolUnderCursorTokenAction::run(CppEditorWidget *) +void RenameSymbolUnderCursorTokenAction::run(CppEditorWidget *editorWidget) { - CppEditorPlugin::instance()->renameSymbolUnderCursor(); + if (editorWidget) + editorWidget->renameSymbolUnderCursor(); + QApplication::processEvents(); } diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 583d99d0969..0c06f86783c 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -357,7 +357,7 @@ F2TestCase::F2TestCase(CppEditorAction action, if (useClangd && tag.endsWith("Var")) initialTestFile->m_editorWidget->openLinkUnderCursor(); else - CppEditorPlugin::instance()->switchDeclarationDefinition(); + initialTestFile->m_editorWidget->switchDeclarationDefinition(/*inNextSplit*/false); break; default: QFAIL("Unknown test action"); |