From 6efecebb10e6134f179ccea677f0e883cb76cab2 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 22 Feb 2023 23:08:19 +0100 Subject: [PATCH] ILocatorFilter: Provide default implementation for accept() Change-Id: Ide3c65ac78da60c9634b8f1c3009e947e8f1e2f3 Reviewed-by: Eike Ziller Reviewed-by: Qt CI Bot Reviewed-by: --- src/plugins/bookmarks/bookmarkfilter.cpp | 4 +-- .../clangcodemodel/clangdlocatorfilters.cpp | 19 ------------- .../clangcodemodel/clangdlocatorfilters.h | 6 ---- .../cmakelocatorfilter.cpp | 13 --------- .../cmakeprojectmanager/cmakelocatorfilter.h | 5 ---- .../coreplugin/locator/basefilefilter.cpp | 14 ---------- .../coreplugin/locator/basefilefilter.h | 3 -- .../coreplugin/locator/ilocatorfilter.cpp | 28 +++++++++++++------ .../coreplugin/locator/ilocatorfilter.h | 4 +-- .../locator/opendocumentsfilter.cpp | 11 -------- .../coreplugin/locator/opendocumentsfilter.h | 3 -- .../cppeditor/cppcurrentdocumentfilter.cpp | 10 ------- .../cppeditor/cppcurrentdocumentfilter.h | 3 -- src/plugins/cppeditor/cpplocatorfilter.cpp | 13 --------- src/plugins/cppeditor/cpplocatorfilter.h | 4 --- src/plugins/languageclient/locatorfilter.cpp | 21 -------------- src/plugins/languageclient/locatorfilter.h | 10 ------- .../qmljstools/qmljsfunctionfilter.cpp | 12 -------- src/plugins/qmljstools/qmljsfunctionfilter.h | 3 -- 19 files changed, 22 insertions(+), 164 deletions(-) diff --git a/src/plugins/bookmarks/bookmarkfilter.cpp b/src/plugins/bookmarks/bookmarkfilter.cpp index 7cc9bf2a759..d659885a548 100644 --- a/src/plugins/bookmarks/bookmarkfilter.cpp +++ b/src/plugins/bookmarks/bookmarkfilter.cpp @@ -110,10 +110,8 @@ void BookmarkFilter::accept(const LocatorFilterEntry &selection, QString *newTex Q_UNUSED(newText) Q_UNUSED(selectionStart) Q_UNUSED(selectionLength) - if (const Bookmark *bookmark = m_manager->bookmarkForIndex( - selection.internalData.toModelIndex())) { + if (Bookmark *bookmark = m_manager->bookmarkForIndex(selection.internalData.toModelIndex())) m_manager->gotoBookmark(bookmark); - } } } // Bookmarks::Internal diff --git a/src/plugins/clangcodemodel/clangdlocatorfilters.cpp b/src/plugins/clangcodemodel/clangdlocatorfilters.cpp index 7f431a36bf7..84b0171cbe3 100644 --- a/src/plugins/clangcodemodel/clangdlocatorfilters.cpp +++ b/src/plugins/clangcodemodel/clangdlocatorfilters.cpp @@ -168,16 +168,6 @@ QList ClangGlobalSymbolFilter::matchesFor( return matches; } -void ClangGlobalSymbolFilter::accept(const LocatorFilterEntry &selection, QString *newText, - int *selectionStart, int *selectionLength) const -{ - Q_UNUSED(newText) - Q_UNUSED(selectionStart) - Q_UNUSED(selectionLength) - EditorManager::openEditor(selection); -} - - ClangClassesFilter::ClangClassesFilter() : ClangGlobalSymbolFilter(new CppClassesFilter, new LspClassesFilter) { @@ -344,14 +334,5 @@ QList ClangdCurrentDocumentFilter::matchesFor( return d->activeFilter->matchesFor(future, entry); } -void ClangdCurrentDocumentFilter::accept(const LocatorFilterEntry &selection, QString *newText, - int *selectionStart, int *selectionLength) const -{ - Q_UNUSED(newText) - Q_UNUSED(selectionStart) - Q_UNUSED(selectionLength) - EditorManager::openEditor(selection); -} - } // namespace Internal } // namespace ClangCodeModel diff --git a/src/plugins/clangcodemodel/clangdlocatorfilters.h b/src/plugins/clangcodemodel/clangdlocatorfilters.h index f7deacc7605..11cf4c00b6b 100644 --- a/src/plugins/clangcodemodel/clangdlocatorfilters.h +++ b/src/plugins/clangcodemodel/clangdlocatorfilters.h @@ -22,9 +22,6 @@ private: void prepareSearch(const QString &entry) override; QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const Core::LocatorFilterEntry &selection, QString *newText, - int *selectionStart, int *selectionLength) const override; - Core::ILocatorFilter * const m_cppFilter; LanguageClient::WorkspaceLocatorFilter * const m_lspFilter; }; @@ -53,9 +50,6 @@ private: void prepareSearch(const QString &entry) override; QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const Core::LocatorFilterEntry &selection, QString *newText, - int *selectionStart, int *selectionLength) const override; - class Private; Private * const d; }; diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp index e902230ae43..7141fb276cb 100644 --- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp @@ -8,8 +8,6 @@ #include "cmakeproject.h" #include "cmakeprojectmanagertr.h" -#include - #include #include #include @@ -147,15 +145,4 @@ OpenCMakeTargetLocatorFilter::OpenCMakeTargetLocatorFilter() setPriority(Medium); } -void OpenCMakeTargetLocatorFilter::accept(const LocatorFilterEntry &selection, - QString *newText, - int *selectionStart, - int *selectionLength) const -{ - Q_UNUSED(newText) - Q_UNUSED(selectionStart) - Q_UNUSED(selectionLength) - EditorManager::openEditor(selection); -} - } // CMakeProjectManager::Internal diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h index 0a74eeafeb3..b8a748be85a 100644 --- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h +++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.h @@ -37,11 +37,6 @@ class OpenCMakeTargetLocatorFilter : CMakeTargetLocatorFilter { public: OpenCMakeTargetLocatorFilter(); - - void accept(const Core::LocatorFilterEntry &selection, - QString *newText, - int *selectionStart, - int *selectionLength) const final; }; } // CMakeProjectManager::Internal diff --git a/src/plugins/coreplugin/locator/basefilefilter.cpp b/src/plugins/coreplugin/locator/basefilefilter.cpp index 823b5d7fb58..3f8e87af20f 100644 --- a/src/plugins/coreplugin/locator/basefilefilter.cpp +++ b/src/plugins/coreplugin/locator/basefilefilter.cpp @@ -3,10 +3,8 @@ #include "basefilefilter.h" -#include #include #include -#include #include #include @@ -192,18 +190,6 @@ QList BaseFileFilter::matchesFor(QFutureInterface()); } -/*! - \reimp -*/ -void BaseFileFilter::accept(const LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const -{ - Q_UNUSED(newText) - Q_UNUSED(selectionStart) - Q_UNUSED(selectionLength) - EditorManager::openEditor(selection); -} - /*! Takes ownership of the \a iterator. The previously set iterator might not be deleted until a currently running search is finished. diff --git a/src/plugins/coreplugin/locator/basefilefilter.h b/src/plugins/coreplugin/locator/basefilefilter.h index 47754dc08f5..55289e57b0a 100644 --- a/src/plugins/coreplugin/locator/basefilefilter.h +++ b/src/plugins/coreplugin/locator/basefilefilter.h @@ -46,9 +46,6 @@ public: void prepareSearch(const QString &entry) override; QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const override; - protected: void setFileIterator(Iterator *iterator); QSharedPointer fileIterator(); diff --git a/src/plugins/coreplugin/locator/ilocatorfilter.cpp b/src/plugins/coreplugin/locator/ilocatorfilter.cpp index 4523c719fb6..61a433ffed7 100644 --- a/src/plugins/coreplugin/locator/ilocatorfilter.cpp +++ b/src/plugins/coreplugin/locator/ilocatorfilter.cpp @@ -4,6 +4,7 @@ #include "ilocatorfilter.h" #include "../coreplugintr.h" +#include "../editormanager/editormanager.h" #include @@ -98,6 +99,24 @@ void ILocatorFilter::prepareSearch(const QString &entry) Q_UNUSED(entry) } +/*! + Called with the entry specified by \a selection when the user activates it + in the result list. + Implementations can return a new search term \a newText, which has \a selectionLength characters + starting from \a selectionStart preselected, and the cursor set to the end of the selection. + + The default implementation tries to open an editor for \a selections's linkForEditor, + if it exists. +*/ +void ILocatorFilter::accept(const LocatorFilterEntry &selection, QString *newText, + int *selectionStart, int *selectionLength) const +{ + Q_UNUSED(newText) + Q_UNUSED(selectionStart) + Q_UNUSED(selectionLength) + EditorManager::openEditor(selection); +} + /*! Sets the default \a shortcut string that can be used to explicitly choose this filter in the locator input field. Call for example from the @@ -597,15 +616,6 @@ bool ILocatorFilter::isOldSetting(const QByteArray &state) \sa caseSensitivity() */ -/*! - \fn void Core::ILocatorFilter::accept(Core::const LocatorFilterEntry &selection, QString *newText, int *selectionStart, int *selectionLength) const - - Called with the entry specified by \a selection when the user activates it - in the result list. - Implementations can return a new search term \a newText, which has \a selectionLength characters - starting from \a selectionStart preselected, and the cursor set to the end of the selection. -*/ - /*! \fn void Core::ILocatorFilter::refresh(QFutureInterface &future) diff --git a/src/plugins/coreplugin/locator/ilocatorfilter.h b/src/plugins/coreplugin/locator/ilocatorfilter.h index 1e0a2fcf4b4..5adb2ebef71 100644 --- a/src/plugins/coreplugin/locator/ilocatorfilter.h +++ b/src/plugins/coreplugin/locator/ilocatorfilter.h @@ -154,8 +154,8 @@ public: virtual QList matchesFor(QFutureInterface &future, const QString &entry) = 0; - virtual void accept(const LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const = 0; + virtual void accept(const LocatorFilterEntry &selection, QString *newText, + int *selectionStart, int *selectionLength) const; virtual void refresh(QFutureInterface &future) { Q_UNUSED(future) }; diff --git a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp index 5a9042ce430..dc2a25b3736 100644 --- a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp +++ b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp @@ -4,11 +4,9 @@ #include "opendocumentsfilter.h" #include "../coreplugintr.h" -#include "../editormanager/editormanager.h" #include #include -#include #include #include @@ -117,13 +115,4 @@ QList OpenDocumentsFilter::editors() const return m_editors; } -void OpenDocumentsFilter::accept(const LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const -{ - Q_UNUSED(newText) - Q_UNUSED(selectionStart) - Q_UNUSED(selectionLength) - EditorManager::openEditor(selection); -} - } // Core::Internal diff --git a/src/plugins/coreplugin/locator/opendocumentsfilter.h b/src/plugins/coreplugin/locator/opendocumentsfilter.h index 537bdd45a5a..4924b04a1fb 100644 --- a/src/plugins/coreplugin/locator/opendocumentsfilter.h +++ b/src/plugins/coreplugin/locator/opendocumentsfilter.h @@ -23,9 +23,6 @@ public: OpenDocumentsFilter(); QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const override; - public slots: void slotDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); diff --git a/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp b/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp index 8b9386567d9..adb1e5d48e3 100644 --- a/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp +++ b/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -138,15 +137,6 @@ QList CppCurrentDocumentFilter::matchesFor( return betterEntries; } -void CppCurrentDocumentFilter::accept(const LocatorFilterEntry &selection, QString *newText, - int *selectionStart, int *selectionLength) const -{ - Q_UNUSED(newText) - Q_UNUSED(selectionStart) - Q_UNUSED(selectionLength) - EditorManager::openEditor(selection); -} - void CppCurrentDocumentFilter::onDocumentUpdated(Document::Ptr doc) { QMutexLocker locker(&m_mutex); diff --git a/src/plugins/cppeditor/cppcurrentdocumentfilter.h b/src/plugins/cppeditor/cppcurrentdocumentfilter.h index 484812a0cba..72a8359b097 100644 --- a/src/plugins/cppeditor/cppcurrentdocumentfilter.h +++ b/src/plugins/cppeditor/cppcurrentdocumentfilter.h @@ -27,9 +27,6 @@ public: QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const Core::LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const override; - private: void onDocumentUpdated(CPlusPlus::Document::Ptr doc); void onCurrentEditorChanged(Core::IEditor *currentEditor); diff --git a/src/plugins/cppeditor/cpplocatorfilter.cpp b/src/plugins/cppeditor/cpplocatorfilter.cpp index ddf185c2aed..b72bf261c98 100644 --- a/src/plugins/cppeditor/cpplocatorfilter.cpp +++ b/src/plugins/cppeditor/cpplocatorfilter.cpp @@ -6,14 +6,10 @@ #include "cppeditorconstants.h" #include "cppeditortr.h" -#include #include #include -#include -#include - using namespace Core; namespace CppEditor { @@ -116,15 +112,6 @@ QList CppLocatorFilter::matchesFor( return std::accumulate(std::begin(entries), std::end(entries), QList()); } -void CppLocatorFilter::accept(const LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const -{ - Q_UNUSED(newText) - Q_UNUSED(selectionStart) - Q_UNUSED(selectionLength) - EditorManager::openEditor(selection); -} - CppClassesFilter::CppClassesFilter(CppLocatorData *locatorData) : CppLocatorFilter(locatorData) { diff --git a/src/plugins/cppeditor/cpplocatorfilter.h b/src/plugins/cppeditor/cpplocatorfilter.h index 9770afe21b4..0bfa8a2d2da 100644 --- a/src/plugins/cppeditor/cpplocatorfilter.h +++ b/src/plugins/cppeditor/cpplocatorfilter.h @@ -5,7 +5,6 @@ #include "cppeditor_global.h" #include "cpplocatordata.h" -#include "searchsymbols.h" #include @@ -21,9 +20,6 @@ public: QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const Core::LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const override; - protected: virtual IndexItem::ItemType matchTypes() const { return IndexItem::All; } virtual Core::LocatorFilterEntry filterEntryFromIndexItem(IndexItem::Ptr info); diff --git a/src/plugins/languageclient/locatorfilter.cpp b/src/plugins/languageclient/locatorfilter.cpp index 88dc4419972..f646209e28d 100644 --- a/src/plugins/languageclient/locatorfilter.cpp +++ b/src/plugins/languageclient/locatorfilter.cpp @@ -7,18 +7,14 @@ #include "languageclient_global.h" #include "languageclientmanager.h" #include "languageclienttr.h" -#include "languageclientutils.h" #include #include -#include #include -#include #include -#include #include #include @@ -204,15 +200,6 @@ QList DocumentLocatorFilter::matchesFor( return {}; } -void DocumentLocatorFilter::accept(const LocatorFilterEntry &selection, - QString * /*newText*/, - int * /*selectionStart*/, - int * /*selectionLength*/) const -{ - if (selection.linkForEditor) - EditorManager::openEditor(selection); -} - WorkspaceLocatorFilter::WorkspaceLocatorFilter() : WorkspaceLocatorFilter(QVector()) {} @@ -302,14 +289,6 @@ QList WorkspaceLocatorFilter::matchesFor( return Utils::transform(m_results, generateEntry).toList(); } -void WorkspaceLocatorFilter::accept(const LocatorFilterEntry &selection, - QString * /*newText*/, - int * /*selectionStart*/, - int * /*selectionLength*/) const -{ - EditorManager::openEditor(selection); -} - void WorkspaceLocatorFilter::handleResponse(Client *client, const WorkspaceSymbolRequest::Response &response) { diff --git a/src/plugins/languageclient/locatorfilter.h b/src/plugins/languageclient/locatorfilter.h index 0d762b669ae..a6e107e97eb 100644 --- a/src/plugins/languageclient/locatorfilter.h +++ b/src/plugins/languageclient/locatorfilter.h @@ -29,11 +29,6 @@ public: void prepareSearch(const QString &entry) override; QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const Core::LocatorFilterEntry &selection, - QString *newText, - int *selectionStart, - int *selectionLength) const override; - signals: void symbolsUpToDate(QPrivateSignal); @@ -85,11 +80,6 @@ public: void prepareSearch(const QString &entry, const QList &clients); QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const Core::LocatorFilterEntry &selection, - QString *newText, - int *selectionStart, - int *selectionLength) const override; - signals: void allRequestsFinished(QPrivateSignal); diff --git a/src/plugins/qmljstools/qmljsfunctionfilter.cpp b/src/plugins/qmljstools/qmljsfunctionfilter.cpp index 7fcf045c7de..e713351e635 100644 --- a/src/plugins/qmljstools/qmljsfunctionfilter.cpp +++ b/src/plugins/qmljstools/qmljsfunctionfilter.cpp @@ -5,13 +5,10 @@ #include "qmljslocatordata.h" #include "qmljstoolstr.h" -#include #include #include -#include - using namespace Core; using namespace QmlJSTools::Internal; @@ -72,12 +69,3 @@ QList FunctionFilter::matchesFor(QFutureInterface()); } - -void FunctionFilter::accept(const LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const -{ - Q_UNUSED(newText) - Q_UNUSED(selectionStart) - Q_UNUSED(selectionLength) - EditorManager::openEditor(selection); -} diff --git a/src/plugins/qmljstools/qmljsfunctionfilter.h b/src/plugins/qmljstools/qmljsfunctionfilter.h index 83b93e8f361..4334d5d9fca 100644 --- a/src/plugins/qmljstools/qmljsfunctionfilter.h +++ b/src/plugins/qmljstools/qmljsfunctionfilter.h @@ -20,9 +20,6 @@ public: QList matchesFor(QFutureInterface &future, const QString &entry) override; - void accept(const Core::LocatorFilterEntry &selection, - QString *newText, int *selectionStart, int *selectionLength) const override; - private: LocatorData *m_data = nullptr; };