forked from qt-creator/qt-creator
QmljsFunctionFilter: Simplify priority handling
Change-Id: Ib3cb7f597256a3d19cc6cab3a2efa3961ac0c478 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
committed by
André Hartmann
parent
56948e75d8
commit
1f82f86167
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <numeric>
|
||||
|
||||
using namespace QmlJSTools::Internal;
|
||||
|
||||
Q_DECLARE_METATYPE(LocatorData::Entry)
|
||||
@@ -56,14 +58,13 @@ QList<Core::LocatorFilterEntry> FunctionFilter::matchesFor(
|
||||
QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||
const QString &entry)
|
||||
{
|
||||
QList<Core::LocatorFilterEntry> goodEntries;
|
||||
QList<Core::LocatorFilterEntry> betterEntries;
|
||||
QList<Core::LocatorFilterEntry> bestEntries;
|
||||
enum { Best = 0, Better, Good, EntryNumber };
|
||||
QList<Core::LocatorFilterEntry> entries[EntryNumber];
|
||||
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
|
||||
|
||||
const QRegularExpression regexp = createRegExp(entry);
|
||||
if (!regexp.isValid())
|
||||
return goodEntries;
|
||||
return {};
|
||||
|
||||
const QHash<QString, QList<LocatorData::Entry> > entries = m_data->entries();
|
||||
for (const QList<LocatorData::Entry> &items : entries) {
|
||||
@@ -82,25 +83,21 @@ QList<Core::LocatorFilterEntry> FunctionFilter::matchesFor(
|
||||
filterEntry.highlightInfo = highlightInfo(match);
|
||||
|
||||
if (filterEntry.displayName.startsWith(entry, caseSensitivityForPrefix))
|
||||
bestEntries.append(filterEntry);
|
||||
entries[Best].append(filterEntry);
|
||||
else if (filterEntry.displayName.contains(entry, caseSensitivityForPrefix))
|
||||
betterEntries.append(filterEntry);
|
||||
entries[Better].append(filterEntry);
|
||||
else
|
||||
goodEntries.append(filterEntry);
|
||||
entries[Good].append(filterEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (goodEntries.size() < 1000)
|
||||
Utils::sort(goodEntries, Core::LocatorFilterEntry::compareLexigraphically);
|
||||
if (betterEntries.size() < 1000)
|
||||
Utils::sort(betterEntries, Core::LocatorFilterEntry::compareLexigraphically);
|
||||
if (bestEntries.size() < 1000)
|
||||
Utils::sort(bestEntries, Core::LocatorFilterEntry::compareLexigraphically);
|
||||
for (auto &entry : entries) {
|
||||
if (entry.size() < 1000)
|
||||
Utils::sort(entry, Core::LocatorFilterEntry::compareLexigraphically);
|
||||
}
|
||||
|
||||
bestEntries += betterEntries;
|
||||
bestEntries += goodEntries;
|
||||
return bestEntries;
|
||||
return std::accumulate(std::begin(entries), std::end(entries), QList<Core::LocatorFilterEntry>());
|
||||
}
|
||||
|
||||
void FunctionFilter::accept(Core::LocatorFilterEntry selection,
|
||||
|
Reference in New Issue
Block a user