forked from qt-creator/qt-creator
QmlJSFunctionsFilter: Remove the old matchesFor() implementation
Rename the filter to QmlJSFunctionsFilter, to conform to the other naming (CppFunctionsFilter, LanguageFunctionsFilter, ClangdFunctionsFilter). Change-Id: I6859c5c8f6d133d1f4dd49d4ee2742b5744c1463 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -18,9 +18,8 @@ using namespace Utils;
|
||||
|
||||
Q_DECLARE_METATYPE(LocatorData::Entry)
|
||||
|
||||
FunctionFilter::FunctionFilter(LocatorData *data, QObject *parent)
|
||||
: ILocatorFilter(parent)
|
||||
, m_data(data)
|
||||
QmlJSFunctionsFilter::QmlJSFunctionsFilter(LocatorData *data)
|
||||
: m_data(data)
|
||||
{
|
||||
setId("Functions");
|
||||
setDisplayName(Tr::tr("QML Functions"));
|
||||
@@ -76,7 +75,7 @@ static void matches(QPromise<void> &promise, const LocatorStorage &storage,
|
||||
LocatorFilterEntries()));
|
||||
}
|
||||
|
||||
LocatorMatcherTasks FunctionFilter::matchers()
|
||||
LocatorMatcherTasks QmlJSFunctionsFilter::matchers()
|
||||
{
|
||||
using namespace Tasking;
|
||||
|
||||
@@ -89,47 +88,3 @@ LocatorMatcherTasks FunctionFilter::matchers()
|
||||
|
||||
return {{AsyncTask<void>(onSetup), storage}};
|
||||
}
|
||||
|
||||
QList<LocatorFilterEntry> FunctionFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future,
|
||||
const QString &entry)
|
||||
{
|
||||
QList<LocatorFilterEntry> entries[int(MatchLevel::Count)];
|
||||
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
|
||||
|
||||
const QRegularExpression regexp = createRegExp(entry);
|
||||
if (!regexp.isValid())
|
||||
return {};
|
||||
|
||||
const QHash<Utils::FilePath, QList<LocatorData::Entry>> locatorEntries = m_data->entries();
|
||||
for (const QList<LocatorData::Entry> &items : locatorEntries) {
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
|
||||
for (const LocatorData::Entry &info : items) {
|
||||
if (info.type != LocatorData::Function)
|
||||
continue;
|
||||
|
||||
const QRegularExpressionMatch match = regexp.match(info.symbolName);
|
||||
if (match.hasMatch()) {
|
||||
LocatorFilterEntry filterEntry;
|
||||
filterEntry.displayName = info.displayName;
|
||||
filterEntry.linkForEditor = {info.fileName, info.line, info.column};
|
||||
filterEntry.extraInfo = info.extraInfo;
|
||||
filterEntry.highlightInfo = highlightInfo(match);
|
||||
|
||||
if (filterEntry.displayName.startsWith(entry, caseSensitivityForPrefix))
|
||||
entries[int(MatchLevel::Best)].append(filterEntry);
|
||||
else if (filterEntry.displayName.contains(entry, caseSensitivityForPrefix))
|
||||
entries[int(MatchLevel::Better)].append(filterEntry);
|
||||
else
|
||||
entries[int(MatchLevel::Good)].append(filterEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &entry : entries) {
|
||||
if (entry.size() < 1000)
|
||||
Utils::sort(entry, LocatorFilterEntry::compareLexigraphically);
|
||||
}
|
||||
return std::accumulate(std::begin(entries), std::end(entries), QList<LocatorFilterEntry>());
|
||||
}
|
||||
|
||||
@@ -5,25 +5,19 @@
|
||||
|
||||
#include <coreplugin/locator/ilocatorfilter.h>
|
||||
|
||||
namespace QmlJSTools {
|
||||
namespace Internal {
|
||||
namespace QmlJSTools::Internal {
|
||||
|
||||
class LocatorData;
|
||||
|
||||
class FunctionFilter : public Core::ILocatorFilter
|
||||
class QmlJSFunctionsFilter : public Core::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FunctionFilter(LocatorData *data, QObject *parent = nullptr);
|
||||
QmlJSFunctionsFilter(LocatorData *data);
|
||||
|
||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||
const QString &entry) override;
|
||||
private:
|
||||
Core::LocatorMatcherTasks matchers() final;
|
||||
|
||||
LocatorData *m_data = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlJSTools
|
||||
} // namespace QmlJSTools::Internal
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
QAction resetCodeModelAction{Tr::tr("Reset Code Model"), nullptr};
|
||||
|
||||
LocatorData locatorData;
|
||||
FunctionFilter functionFilter{&locatorData};
|
||||
QmlJSFunctionsFilter functionsFilter{&locatorData};
|
||||
QmlJSCodeStyleSettingsPage codeStyleSettingsPage;
|
||||
BasicBundleProvider basicBundleProvider;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user