diff options
author | David Schulz <david.schulz@qt.io> | 2023-03-22 10:39:09 +0100 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2023-03-22 14:40:38 +0000 |
commit | eb7ccfd8893607d0b8a46c17ed444233c353bf8e (patch) | |
tree | 565b2003c266bb5a7c5c0425f98ac18995d55be8 /src/plugins/texteditor | |
parent | f423db5cb71c7e3442ef31d5eb3ced615b9d1322 (diff) | |
download | qt-creator-eb7ccfd8893607d0b8a46c17ed444233c353bf8e.tar.gz |
LanguageClient: add action to open call hierarchy
Fixes: QTCREATORBUG-28839
Fixes: QTCREATORBUG-28842
Change-Id: Icb70412282c0c2c36241559d942a58ffddab5664
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r-- | src/plugins/texteditor/texteditor.cpp | 10 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditor.h | 2 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditoractionhandler.cpp | 5 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditoractionhandler.h | 3 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditorconstants.h | 1 |
5 files changed, 20 insertions, 1 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 6d3593aab7..ccbdb0467d 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -2348,6 +2348,11 @@ void TextEditorWidget::renameSymbolUnderCursor() emit requestRename(textCursor()); } +void TextEditorWidget::openCallHierarchy() +{ + emit requestCallHierarchy(textCursor()); +} + void TextEditorWidget::abortAssist() { d->m_codeAssistant.destroyContext(); @@ -8225,6 +8230,11 @@ void TextEditorWidget::appendStandardContextMenuActions(QMenu *menu) if (!menu->actions().contains(findUsage)) menu->addAction(findUsage); } + if (optionalActions() & TextEditorActionHandler::CallHierarchy) { + const auto callHierarchy = ActionManager::command(Constants::OPEN_CALL_HIERARCHY)->action(); + if (!menu->actions().contains(callHierarchy)) + menu->addAction(callHierarchy); + } menu->addSeparator(); appendMenuActionsFromContext(menu, Constants::M_STANDARDCONTEXTMENU); diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h index 31c4c9d6bf..4234645d50 100644 --- a/src/plugins/texteditor/texteditor.h +++ b/src/plugins/texteditor/texteditor.h @@ -437,6 +437,7 @@ public: virtual void findUsages(); virtual void renameSymbolUnderCursor(); + virtual void openCallHierarchy(); /// Abort code assistant if it is running. void abortAssist(); @@ -487,6 +488,7 @@ signals: bool resolveTarget, bool inNextSplit); void requestUsages(const QTextCursor &cursor); void requestRename(const QTextCursor &cursor); + void requestCallHierarchy(const QTextCursor &cursor); void optionalActionMaskChanged(); void toolbarOutlineChanged(QWidget *newOutline); diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 25116729c9..00ed94a5ee 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -116,6 +116,7 @@ public: QAction *m_followSymbolAction = nullptr; QAction *m_followSymbolInNextSplitAction = nullptr; QAction *m_findUsageAction = nullptr; + QAction *m_openCallHierarchyAction = nullptr; QAction *m_renameSymbolAction = nullptr; QAction *m_jumpToFileAction = nullptr; QAction *m_jumpToFileInNextSplitAction = nullptr; @@ -228,6 +229,8 @@ void TextEditorActionHandlerPrivate::createActions() m_jumpToFileInNextSplitAction = registerAction(JUMP_TO_FILE_UNDER_CURSOR_IN_NEXT_SPLIT, [] (TextEditorWidget *w) { w->openLinkUnderCursorInNextSplit(); }, true, Tr::tr("Jump to File Under Cursor in Next Split"), QKeySequence(Utils::HostOsInfo::isMacHost() ? Tr::tr("Meta+E, F2") : Tr::tr("Ctrl+E, F2")).toString()); + m_openCallHierarchyAction = registerAction(OPEN_CALL_HIERARCHY, + [] (TextEditorWidget *w) { w->openCallHierarchy(); }, true, Tr::tr("Open Call Hierarchy")); registerAction(VIEW_PAGE_UP, [] (TextEditorWidget *w) { w->viewPageUp(); }, true, Tr::tr("Move the View a Page Up and Keep the Cursor Position"), @@ -484,6 +487,8 @@ void TextEditorActionHandlerPrivate::updateOptionalActions() optionalActions & TextEditorActionHandler::UnCollapseAll); m_renameSymbolAction->setEnabled( optionalActions & TextEditorActionHandler::RenameSymbol); + m_openCallHierarchyAction->setEnabled( + optionalActions & TextEditorActionHandler::CallHierarchy); bool formatEnabled = (optionalActions & TextEditorActionHandler::Format) && m_currentEditorWidget && !m_currentEditorWidget->isReadOnly(); diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index 277c2cf66f..2bdb8efff3 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -36,7 +36,8 @@ public: FollowSymbolUnderCursor = 8, JumpToFileUnderCursor = 16, RenameSymbol = 32, - FindUsage = 64 + FindUsage = 64, + CallHierarchy = 128 }; using TextEditorWidgetResolver = std::function<TextEditorWidget *(Core::IEditor *)>; diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 0560dae9d8..f422630f0d 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -208,6 +208,7 @@ const char FOLLOW_SYMBOL_UNDER_CURSOR_IN_NEXT_SPLIT[] = "TextEditor.FollowSymbol const char FIND_USAGES[] = "TextEditor.FindUsages"; // moved from CppEditor to TextEditor avoid breaking the setting by using the old key const char RENAME_SYMBOL[] = "CppEditor.RenameSymbolUnderCursor"; +const char OPEN_CALL_HIERARCHY[] = "TextEditor.OpenCallHierarchy"; const char JUMP_TO_FILE_UNDER_CURSOR[] = "TextEditor.JumpToFileUnderCursor"; const char JUMP_TO_FILE_UNDER_CURSOR_IN_NEXT_SPLIT[] = "TextEditor.JumpToFileUnderCursorInNextSplit"; |