ILocatorFilter: Provide default implementation for accept()

Change-Id: Ide3c65ac78da60c9634b8f1c3009e947e8f1e2f3
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2023-02-22 23:08:19 +01:00
parent 215f79f580
commit 6efecebb10
19 changed files with 22 additions and 164 deletions

View File

@@ -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

View File

@@ -168,16 +168,6 @@ QList<LocatorFilterEntry> 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<LocatorFilterEntry> 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

View File

@@ -22,9 +22,6 @@ private:
void prepareSearch(const QString &entry) override;
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &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<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry) override;
void accept(const Core::LocatorFilterEntry &selection, QString *newText,
int *selectionStart, int *selectionLength) const override;
class Private;
Private * const d;
};

View File

@@ -8,8 +8,6 @@
#include "cmakeproject.h"
#include "cmakeprojectmanagertr.h"
#include <coreplugin/editormanager/editormanager.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/projectmanager.h>
@@ -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

View File

@@ -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

View File

@@ -3,10 +3,8 @@
#include "basefilefilter.h"
#include <coreplugin/editormanager/editormanager.h>
#include <utils/algorithm.h>
#include <utils/filepath.h>
#include <utils/linecolumn.h>
#include <utils/link.h>
#include <utils/qtcassert.h>
@@ -192,18 +190,6 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<LocatorFil
return std::accumulate(std::begin(entries), std::end(entries), QList<LocatorFilterEntry>());
}
/*!
\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.

View File

@@ -46,9 +46,6 @@ public:
void prepareSearch(const QString &entry) override;
QList<LocatorFilterEntry> matchesFor(QFutureInterface<LocatorFilterEntry> &future,
const QString &entry) override;
void accept(const LocatorFilterEntry &selection,
QString *newText, int *selectionStart, int *selectionLength) const override;
protected:
void setFileIterator(Iterator *iterator);
QSharedPointer<Iterator> fileIterator();

View File

@@ -4,6 +4,7 @@
#include "ilocatorfilter.h"
#include "../coreplugintr.h"
#include "../editormanager/editormanager.h"
#include <utils/fuzzymatcher.h>
@@ -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<void> &future)

View File

@@ -154,8 +154,8 @@ public:
virtual QList<LocatorFilterEntry> matchesFor(QFutureInterface<LocatorFilterEntry> &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<void> &future) { Q_UNUSED(future) };

View File

@@ -4,11 +4,9 @@
#include "opendocumentsfilter.h"
#include "../coreplugintr.h"
#include "../editormanager/editormanager.h"
#include <utils/filepath.h>
#include <utils/link.h>
#include <utils/linecolumn.h>
#include <QAbstractItemModel>
#include <QMutexLocker>
@@ -117,13 +115,4 @@ QList<OpenDocumentsFilter::Entry> 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

View File

@@ -23,9 +23,6 @@ public:
OpenDocumentsFilter();
QList<LocatorFilterEntry> matchesFor(QFutureInterface<LocatorFilterEntry> &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<int> &roles);

View File

@@ -9,7 +9,6 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/idocument.h>
#include <utils/algorithm.h>
#include <QHash>
@@ -138,15 +137,6 @@ QList<LocatorFilterEntry> 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);

View File

@@ -27,9 +27,6 @@ public:
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &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);

View File

@@ -6,14 +6,10 @@
#include "cppeditorconstants.h"
#include "cppeditortr.h"
#include <coreplugin/editormanager/editormanager.h>
#include <utils/algorithm.h>
#include <QRegularExpression>
#include <algorithm>
#include <numeric>
using namespace Core;
namespace CppEditor {
@@ -116,15 +112,6 @@ QList<LocatorFilterEntry> CppLocatorFilter::matchesFor(
return std::accumulate(std::begin(entries), std::end(entries), QList<LocatorFilterEntry>());
}
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)
{

View File

@@ -5,7 +5,6 @@
#include "cppeditor_global.h"
#include "cpplocatordata.h"
#include "searchsymbols.h"
#include <coreplugin/locator/ilocatorfilter.h>
@@ -21,9 +20,6 @@ public:
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &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);

View File

@@ -7,18 +7,14 @@
#include "languageclient_global.h"
#include "languageclientmanager.h"
#include "languageclienttr.h"
#include "languageclientutils.h"
#include <coreplugin/editormanager/editormanager.h>
#include <languageserverprotocol/lsptypes.h>
#include <languageserverprotocol/servercapabilities.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditor.h>
#include <utils/fuzzymatcher.h>
#include <utils/linecolumn.h>
#include <QFutureWatcher>
#include <QRegularExpression>
@@ -204,15 +200,6 @@ QList<LocatorFilterEntry> 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<SymbolKind>())
{}
@@ -302,14 +289,6 @@ QList<LocatorFilterEntry> 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)
{

View File

@@ -29,11 +29,6 @@ public:
void prepareSearch(const QString &entry) override;
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &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<Client *> &clients);
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry) override;
void accept(const Core::LocatorFilterEntry &selection,
QString *newText,
int *selectionStart,
int *selectionLength) const override;
signals:
void allRequestsFinished(QPrivateSignal);

View File

@@ -5,13 +5,10 @@
#include "qmljslocatordata.h"
#include "qmljstoolstr.h"
#include <coreplugin/editormanager/editormanager.h>
#include <utils/algorithm.h>
#include <QRegularExpression>
#include <numeric>
using namespace Core;
using namespace QmlJSTools::Internal;
@@ -72,12 +69,3 @@ QList<LocatorFilterEntry> FunctionFilter::matchesFor(QFutureInterface<LocatorFil
}
return std::accumulate(std::begin(entries), std::end(entries), QList<LocatorFilterEntry>());
}
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);
}

View File

@@ -20,9 +20,6 @@ public:
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry) override;
void accept(const Core::LocatorFilterEntry &selection,
QString *newText, int *selectionStart, int *selectionLength) const override;
private:
LocatorData *m_data = nullptr;
};