diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index 6d6b1b37e05..0b4e5ca9033 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -148,7 +148,8 @@ public: | TextEditorActionHandler::UnCommentSelection | TextEditorActionHandler::UnCollapseAll | TextEditorActionHandler::FollowSymbolUnderCursor - | TextEditorActionHandler::RenameSymbol); + | TextEditorActionHandler::RenameSymbol + | TextEditorActionHandler::FindUsage); } }; diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index 4d6aa06ea50..426ee17fad5 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -853,8 +853,12 @@ void Client::activateDocument(TextEditor::TextDocument *document) TextEditor::TextEditorWidget *widget = textEditor->editorWidget(); widget->addHoverHandler(&d->m_hoverHandler); d->requestDocumentHighlights(widget); + uint optionalActions = widget->optionalActions(); + if (symbolSupport().supportsFindUsages(document)) + optionalActions |= TextEditor::TextEditorActionHandler::FindUsage; if (symbolSupport().supportsRename(document)) - widget->addOptionalActions(TextEditor::TextEditorActionHandler::RenameSymbol); + optionalActions |= TextEditor::TextEditorActionHandler::RenameSymbol; + widget->setOptionalActions(optionalActions); } } } diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index b0ea81c7d71..3db43211763 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -1083,7 +1083,8 @@ QmlJSEditorFactory::QmlJSEditorFactory(Utils::Id _id) | TextEditorActionHandler::UnCommentSelection | TextEditorActionHandler::UnCollapseAll | TextEditorActionHandler::FollowSymbolUnderCursor - | TextEditorActionHandler::RenameSymbol); + | TextEditorActionHandler::RenameSymbol + | TextEditorActionHandler::FindUsage); } void QmlJSEditorFactory::decorateEditor(TextEditorWidget *editor) diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index 62813ccbbda..348b421be83 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -116,6 +116,7 @@ public: QAction *m_unfoldAllAction = nullptr; QAction *m_followSymbolAction = nullptr; QAction *m_followSymbolInNextSplitAction = nullptr; + QAction *m_findUsageAction = nullptr; QAction *m_renameSymbolAction = nullptr; QAction *m_jumpToFileAction = nullptr; QAction *m_jumpToFileInNextSplitAction = nullptr; @@ -216,7 +217,7 @@ void TextEditorActionHandlerPrivate::createActions() m_followSymbolInNextSplitAction = registerAction(FOLLOW_SYMBOL_UNDER_CURSOR_IN_NEXT_SPLIT, [] (TextEditorWidget *w) { w->openLinkUnderCursorInNextSplit(); }, true, tr("Follow Symbol Under Cursor in Next Split"), QKeySequence(Utils::HostOsInfo::isMacHost() ? tr("Meta+E, F2") : tr("Ctrl+E, F2"))); - registerAction(FIND_USAGES, + m_findUsageAction = registerAction(FIND_USAGES, [] (TextEditorWidget *w) { w->findUsages(); }, true, tr("Find References to Symbol Under Cursor"), QKeySequence(tr("Ctrl+Shift+U"))); m_renameSymbolAction = registerAction(RENAME_SYMBOL, @@ -474,6 +475,8 @@ void TextEditorActionHandlerPrivate::updateOptionalActions() optionalActions & TextEditorActionHandler::FollowSymbolUnderCursor); m_followSymbolInNextSplitAction->setEnabled( optionalActions & TextEditorActionHandler::FollowSymbolUnderCursor); + m_findUsageAction->setEnabled( + optionalActions & TextEditorActionHandler::FindUsage); m_jumpToFileAction->setEnabled( optionalActions & TextEditorActionHandler::JumpToFileUnderCursor); m_jumpToFileInNextSplitAction->setEnabled( diff --git a/src/plugins/texteditor/texteditoractionhandler.h b/src/plugins/texteditor/texteditoractionhandler.h index c04a791f9f3..c33a1270f87 100644 --- a/src/plugins/texteditor/texteditoractionhandler.h +++ b/src/plugins/texteditor/texteditoractionhandler.h @@ -36,6 +36,7 @@ public: FollowSymbolUnderCursor = 8, JumpToFileUnderCursor = 16, RenameSymbol = 32, + FindUsage = 64 }; using TextEditorWidgetResolver = std::function;