forked from qt-creator/qt-creator
LocatorMatcherTask: Get rid of Input/OutputData typedefs
Introduce LocatorFilterEntries instead. Change-Id: I082e0405441aa4b70a5e8fb796aa5c4fa3879265 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "../coreplugin.h"
|
#include "../coreplugin.h"
|
||||||
#include "../coreplugintr.h"
|
#include "../coreplugintr.h"
|
||||||
#include "../editormanager/editormanager.h"
|
|
||||||
|
|
||||||
#include <utils/asynctask.h>
|
#include <utils/asynctask.h>
|
||||||
#include <utils/fuzzymatcher.h>
|
#include <utils/fuzzymatcher.h>
|
||||||
@@ -22,6 +21,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include <QWaitCondition>
|
||||||
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
@@ -61,29 +61,29 @@ class OutputDataProvider
|
|||||||
|
|
||||||
struct WorkingData {
|
struct WorkingData {
|
||||||
WorkingData() = default;
|
WorkingData() = default;
|
||||||
WorkingData(const LocatorMatcherTask::OutputData &entries, std::atomic<State> &state) {
|
WorkingData(const LocatorFilterEntries &entries, std::atomic<State> &state) {
|
||||||
mergeWith(entries, state);
|
mergeWith(entries, state);
|
||||||
}
|
}
|
||||||
LocatorMatcherTask::OutputData mergeWith(const LocatorMatcherTask::OutputData &entries,
|
LocatorFilterEntries mergeWith(const LocatorFilterEntries &entries,
|
||||||
std::atomic<State> &state) {
|
std::atomic<State> &state) {
|
||||||
LocatorMatcherTask::OutputData results;
|
LocatorFilterEntries results;
|
||||||
results.reserve(entries.size());
|
results.reserve(entries.size());
|
||||||
for (const LocatorFilterEntry &entry : entries) {
|
for (const LocatorFilterEntry &entry : entries) {
|
||||||
if (state == State::Canceled)
|
if (state == State::Canceled)
|
||||||
return LocatorMatcherTask::OutputData();
|
return {};
|
||||||
const auto &link = entry.linkForEditor;
|
const auto &link = entry.linkForEditor;
|
||||||
if (!link || m_cache.emplace(*link).second)
|
if (!link || m_cache.emplace(*link).second)
|
||||||
results.append(entry);
|
results.append(entry);
|
||||||
}
|
}
|
||||||
if (state == State::Canceled)
|
if (state == State::Canceled)
|
||||||
return LocatorMatcherTask::OutputData();
|
return {};
|
||||||
|
|
||||||
m_data += results;
|
m_data += results;
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
LocatorMatcherTask::OutputData entries() const { return m_data; }
|
LocatorFilterEntries entries() const { return m_data; }
|
||||||
private:
|
private:
|
||||||
LocatorMatcherTask::OutputData m_data;
|
LocatorFilterEntries m_data;
|
||||||
std::unordered_set<Utils::Link> m_cache;
|
std::unordered_set<Utils::Link> m_cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ public:
|
|||||||
, m_outputData(filterCount, {})
|
, m_outputData(filterCount, {})
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void addOutputData(int index, const LocatorMatcherTask::OutputData &outputData)
|
void addOutputData(int index, const LocatorFilterEntries &outputData)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(index >= 0, return);
|
QTC_ASSERT(index >= 0, return);
|
||||||
|
|
||||||
@@ -115,9 +115,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Called from separate thread (OutputFilter's thread)
|
// Called from separate thread (OutputFilter's thread)
|
||||||
void run(QPromise<LocatorMatcherTask::OutputData> &promise)
|
void run(QPromise<LocatorFilterEntries> &promise)
|
||||||
{
|
{
|
||||||
QList<std::optional<LocatorMatcherTask::OutputData>> data;
|
QList<std::optional<LocatorFilterEntries>> data;
|
||||||
QList<std::optional<WorkingData>> workingList(m_filterCount, {});
|
QList<std::optional<WorkingData>> workingList(m_filterCount, {});
|
||||||
while (waitForData(&data)) {
|
while (waitForData(&data)) {
|
||||||
// Emit new results only when new data is reachable from the beginning (i.e. no gaps)
|
// Emit new results only when new data is reachable from the beginning (i.e. no gaps)
|
||||||
@@ -137,13 +137,13 @@ public:
|
|||||||
const auto &workingData = workingList.at(currentIndex);
|
const auto &workingData = workingList.at(currentIndex);
|
||||||
if (!workingData.has_value()) {
|
if (!workingData.has_value()) {
|
||||||
const bool mergeToCurrent = currentIndex == mergeToIndex;
|
const bool mergeToCurrent = currentIndex == mergeToIndex;
|
||||||
const LocatorMatcherTask::OutputData dataForIndex = mergeToCurrent
|
const LocatorFilterEntries dataForIndex = mergeToCurrent ? *outputData
|
||||||
? *outputData : LocatorMatcherTask::OutputData();
|
: LocatorFilterEntries();
|
||||||
workingList[currentIndex] = std::make_optional(WorkingData(dataForIndex,
|
workingList[currentIndex] = std::make_optional(WorkingData(dataForIndex,
|
||||||
m_state));
|
m_state));
|
||||||
if (m_state == State::Canceled)
|
if (m_state == State::Canceled)
|
||||||
return;
|
return;
|
||||||
const LocatorMatcherTask::OutputData newData = mergeToCurrent
|
const LocatorFilterEntries newData = mergeToCurrent
|
||||||
? workingList[currentIndex]->entries()
|
? workingList[currentIndex]->entries()
|
||||||
: workingList[mergeToIndex]->mergeWith(*outputData, m_state);
|
: workingList[mergeToIndex]->mergeWith(*outputData, m_state);
|
||||||
if (m_state == State::Canceled)
|
if (m_state == State::Canceled)
|
||||||
@@ -151,7 +151,7 @@ public:
|
|||||||
if (!hasGap && !newData.isEmpty())
|
if (!hasGap && !newData.isEmpty())
|
||||||
promise.addResult(newData);
|
promise.addResult(newData);
|
||||||
} else if (currentIndex != mergeToIndex) {
|
} else if (currentIndex != mergeToIndex) {
|
||||||
const LocatorMatcherTask::OutputData newData
|
const LocatorFilterEntries newData
|
||||||
= workingList[mergeToIndex]->mergeWith(workingData->entries(), m_state);
|
= workingList[mergeToIndex]->mergeWith(workingData->entries(), m_state);
|
||||||
workingList[currentIndex] = std::make_optional<WorkingData>({});
|
workingList[currentIndex] = std::make_optional<WorkingData>({});
|
||||||
if (m_state == State::Canceled)
|
if (m_state == State::Canceled)
|
||||||
@@ -168,7 +168,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool waitForData(QList<std::optional<LocatorMatcherTask::OutputData>> *data)
|
bool waitForData(QList<std::optional<LocatorFilterEntries>> *data)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
if (m_state == State::Canceled)
|
if (m_state == State::Canceled)
|
||||||
@@ -191,7 +191,7 @@ private:
|
|||||||
QWaitCondition m_waitCondition;
|
QWaitCondition m_waitCondition;
|
||||||
const int m_filterCount = 0;
|
const int m_filterCount = 0;
|
||||||
std::atomic<State> m_state = State::Awaiting;
|
std::atomic<State> m_state = State::Awaiting;
|
||||||
QList<std::optional<LocatorMatcherTask::OutputData>> m_outputData;
|
QList<std::optional<LocatorFilterEntries>> m_outputData;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OutputFilter : public QObject
|
class OutputFilter : public QObject
|
||||||
@@ -202,18 +202,18 @@ public:
|
|||||||
~OutputFilter();
|
~OutputFilter();
|
||||||
void setFilterCount(int count);
|
void setFilterCount(int count);
|
||||||
// When last index is added it ends automatically (asynchronously)
|
// When last index is added it ends automatically (asynchronously)
|
||||||
void addOutputData(int index, const LocatorMatcherTask::OutputData &outputData);
|
void addOutputData(int index, const LocatorFilterEntries &outputData);
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
bool isRunning() const { return m_watcher.get(); }
|
bool isRunning() const { return m_watcher.get(); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void serialOutputDataReady(const LocatorMatcherTask::OutputData &serialOutputData);
|
void serialOutputDataReady(const LocatorFilterEntries &serialOutputData);
|
||||||
void done();
|
void done();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_filterCount = 0;
|
int m_filterCount = 0;
|
||||||
std::unique_ptr<QFutureWatcher<LocatorMatcherTask::OutputData>> m_watcher;
|
std::unique_ptr<QFutureWatcher<LocatorFilterEntries>> m_watcher;
|
||||||
std::shared_ptr<OutputDataProvider> m_dataProvider;
|
std::shared_ptr<OutputDataProvider> m_dataProvider;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ void OutputFilter::setFilterCount(int count)
|
|||||||
m_filterCount = count;
|
m_filterCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputFilter::addOutputData(int index, const LocatorMatcherTask::OutputData &outputData)
|
void OutputFilter::addOutputData(int index, const LocatorFilterEntries &outputData)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(isRunning(), return);
|
QTC_ASSERT(isRunning(), return);
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ void OutputFilter::start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_dataProvider.reset(new OutputDataProvider(m_filterCount));
|
m_dataProvider.reset(new OutputDataProvider(m_filterCount));
|
||||||
m_watcher.reset(new QFutureWatcher<LocatorMatcherTask::OutputData>);
|
m_watcher.reset(new QFutureWatcher<LocatorFilterEntries>);
|
||||||
connect(m_watcher.get(), &QFutureWatcherBase::resultReadyAt, this, [this](int index) {
|
connect(m_watcher.get(), &QFutureWatcherBase::resultReadyAt, this, [this](int index) {
|
||||||
emit serialOutputDataReady(m_watcher->resultAt(index));
|
emit serialOutputDataReady(m_watcher->resultAt(index));
|
||||||
});
|
});
|
||||||
@@ -262,7 +262,7 @@ void OutputFilter::start()
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO: When filterCount == 1, deliver results directly and finish?
|
// TODO: When filterCount == 1, deliver results directly and finish?
|
||||||
auto filter = [](QPromise<LocatorMatcherTask::OutputData> &promise,
|
auto filter = [](QPromise<LocatorFilterEntries> &promise,
|
||||||
const std::shared_ptr<OutputDataProvider> &dataProvider) {
|
const std::shared_ptr<OutputDataProvider> &dataProvider) {
|
||||||
dataProvider->run(promise);
|
dataProvider->run(promise);
|
||||||
};
|
};
|
||||||
@@ -303,7 +303,7 @@ void LocatorMatcher::setTasks(const QList<LocatorMatcherTask> &tasks)
|
|||||||
d->m_tasks = tasks;
|
d->m_tasks = tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocatorMatcher::setInputData(const LocatorMatcherTask::InputData &inputData)
|
void LocatorMatcher::setInputData(const QString &inputData)
|
||||||
{
|
{
|
||||||
d->m_storage.input = inputData;
|
d->m_storage.input = inputData;
|
||||||
}
|
}
|
||||||
@@ -331,7 +331,7 @@ void LocatorMatcher::start()
|
|||||||
filterStorage->m_filter = &filter;
|
filterStorage->m_filter = &filter;
|
||||||
filter.setFilterCount(filterCount);
|
filter.setFilterCount(filterCount);
|
||||||
connect(&filter, &OutputFilter::serialOutputDataReady,
|
connect(&filter, &OutputFilter::serialOutputDataReady,
|
||||||
this, [this](const LocatorMatcherTask::OutputData &serialOutputData) {
|
this, [this](const LocatorFilterEntries &serialOutputData) {
|
||||||
d->m_storage.output += serialOutputData;
|
d->m_storage.output += serialOutputData;
|
||||||
emit serialOutputDataReady(serialOutputData);
|
emit serialOutputDataReady(serialOutputData);
|
||||||
});
|
});
|
||||||
@@ -406,13 +406,13 @@ bool LocatorMatcher::isRunning() const
|
|||||||
return d->m_taskTree.get() && d->m_taskTree->isRunning();
|
return d->m_taskTree.get() && d->m_taskTree->isRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask::OutputData LocatorMatcher::outputData() const
|
LocatorFilterEntries LocatorMatcher::outputData() const
|
||||||
{
|
{
|
||||||
return d->m_storage.output;
|
return d->m_storage.output;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask::OutputData LocatorMatcher::runBlocking(const QList<LocatorMatcherTask> &tasks,
|
LocatorFilterEntries LocatorMatcher::runBlocking(const QList<LocatorMatcherTask> &tasks,
|
||||||
const LocatorMatcherTask::InputData &input, int parallelLimit)
|
const QString &input, int parallelLimit)
|
||||||
{
|
{
|
||||||
LocatorMatcher tree;
|
LocatorMatcher tree;
|
||||||
tree.setTasks(tasks);
|
tree.setTasks(tasks);
|
||||||
|
@@ -112,16 +112,16 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using LocatorFilterEntries = QList<LocatorFilterEntry>;
|
||||||
|
|
||||||
class CORE_EXPORT LocatorMatcherTask final
|
class CORE_EXPORT LocatorMatcherTask final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using InputData = QString;
|
|
||||||
using OutputData = QList<LocatorFilterEntry>;
|
|
||||||
class Storage
|
class Storage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputData input;
|
QString input;
|
||||||
OutputData output;
|
LocatorFilterEntries output;
|
||||||
};
|
};
|
||||||
// The main task. Initial data taken from storage.input field.
|
// The main task. Initial data taken from storage.input field.
|
||||||
// Results reporting is done through the storage.output field.
|
// Results reporting is done through the storage.output field.
|
||||||
@@ -150,25 +150,24 @@ public:
|
|||||||
LocatorMatcher();
|
LocatorMatcher();
|
||||||
~LocatorMatcher();
|
~LocatorMatcher();
|
||||||
void setTasks(const QList<LocatorMatcherTask> &tasks);
|
void setTasks(const QList<LocatorMatcherTask> &tasks);
|
||||||
void setInputData(const LocatorMatcherTask::InputData &inputData);
|
void setInputData(const QString &inputData);
|
||||||
void setParallelLimit(int limit); // by default 0 = parallel
|
void setParallelLimit(int limit); // by default 0 = parallel
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
bool isRunning() const;
|
bool isRunning() const;
|
||||||
// Total data collected so far, even when running.
|
// Total data collected so far, even when running.
|
||||||
LocatorMatcherTask::OutputData outputData() const;
|
LocatorFilterEntries outputData() const;
|
||||||
|
|
||||||
// Note: Starts internal event loop.
|
// Note: Starts internal event loop.
|
||||||
static LocatorMatcherTask::OutputData runBlocking(const QList<LocatorMatcherTask> &tasks,
|
static LocatorFilterEntries runBlocking(const QList<LocatorMatcherTask> &tasks,
|
||||||
const LocatorMatcherTask::InputData &input,
|
const QString &input, int parallelLimit = 0);
|
||||||
int parallelLimit = 0);
|
|
||||||
|
|
||||||
static void addMatcherCreator(MatcherType type, const LocatorMatcherTaskCreator &creator);
|
static void addMatcherCreator(MatcherType type, const LocatorMatcherTaskCreator &creator);
|
||||||
static QList<LocatorMatcherTask> matchers(MatcherType type);
|
static QList<LocatorMatcherTask> matchers(MatcherType type);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void serialOutputDataReady(const LocatorMatcherTask::OutputData &serialOutputData);
|
void serialOutputDataReady(const LocatorFilterEntries &serialOutputData);
|
||||||
void done(bool success);
|
void done(bool success);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -26,10 +26,10 @@ namespace CppEditor {
|
|||||||
|
|
||||||
using EntryFromIndex = std::function<LocatorFilterEntry(const IndexItem::Ptr &)>;
|
using EntryFromIndex = std::function<LocatorFilterEntry(const IndexItem::Ptr &)>;
|
||||||
|
|
||||||
void matchesFor(QPromise<LocatorMatcherTask::OutputData> &promise, const QString &entry,
|
void matchesFor(QPromise<LocatorFilterEntries> &promise, const QString &entry,
|
||||||
IndexItem::ItemType wantedType, const EntryFromIndex &converter)
|
IndexItem::ItemType wantedType, const EntryFromIndex &converter)
|
||||||
{
|
{
|
||||||
QList<LocatorFilterEntry> entries[int(ILocatorFilter::MatchLevel::Count)];
|
LocatorFilterEntries entries[int(ILocatorFilter::MatchLevel::Count)];
|
||||||
const Qt::CaseSensitivity caseSensitivityForPrefix = ILocatorFilter::caseSensitivity(entry);
|
const Qt::CaseSensitivity caseSensitivityForPrefix = ILocatorFilter::caseSensitivity(entry);
|
||||||
const QRegularExpression regexp = ILocatorFilter::createRegExp(entry);
|
const QRegularExpression regexp = ILocatorFilter::createRegExp(entry);
|
||||||
if (!regexp.isValid())
|
if (!regexp.isValid())
|
||||||
@@ -96,7 +96,7 @@ void matchesFor(QPromise<LocatorMatcherTask::OutputData> &promise, const QString
|
|||||||
}
|
}
|
||||||
|
|
||||||
promise.addResult(std::accumulate(std::begin(entries), std::end(entries),
|
promise.addResult(std::accumulate(std::begin(entries), std::end(entries),
|
||||||
QList<LocatorFilterEntry>()));
|
LocatorFilterEntries()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask locatorMatcher(IndexItem::ItemType type, const EntryFromIndex &converter)
|
LocatorMatcherTask locatorMatcher(IndexItem::ItemType type, const EntryFromIndex &converter)
|
||||||
@@ -105,15 +105,15 @@ LocatorMatcherTask locatorMatcher(IndexItem::ItemType type, const EntryFromIndex
|
|||||||
|
|
||||||
TreeStorage<LocatorMatcherTask::Storage> storage;
|
TreeStorage<LocatorMatcherTask::Storage> storage;
|
||||||
|
|
||||||
const auto onSetup = [=](AsyncTask<LocatorMatcherTask::OutputData> &async) {
|
const auto onSetup = [=](AsyncTask<LocatorFilterEntries> &async) {
|
||||||
async.setFutureSynchronizer(Internal::CppEditorPlugin::futureSynchronizer());
|
async.setFutureSynchronizer(Internal::CppEditorPlugin::futureSynchronizer());
|
||||||
async.setConcurrentCallData(matchesFor, storage->input, type, converter);
|
async.setConcurrentCallData(matchesFor, storage->input, type, converter);
|
||||||
};
|
};
|
||||||
const auto onDone = [storage](const AsyncTask<LocatorMatcherTask::OutputData> &async) {
|
const auto onDone = [storage](const AsyncTask<LocatorFilterEntries> &async) {
|
||||||
if (async.isResultAvailable())
|
if (async.isResultAvailable())
|
||||||
storage->output = async.result();
|
storage->output = async.result();
|
||||||
};
|
};
|
||||||
return {Async<LocatorMatcherTask::OutputData>(onSetup, onDone, onDone), storage};
|
return {Async<LocatorFilterEntries>(onSetup, onDone, onDone), storage};
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask cppAllSymbolsMatcher()
|
LocatorMatcherTask cppAllSymbolsMatcher()
|
||||||
@@ -200,7 +200,7 @@ LocatorFilterEntry::HighlightInfo highlightInfo(const QRegularExpressionMatch &m
|
|||||||
return LocatorFilterEntry::HighlightInfo(positions.starts, positions.lengths, dataType);
|
return LocatorFilterEntry::HighlightInfo(positions.starts, positions.lengths, dataType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void matchesForCurrentDocument(QPromise<LocatorMatcherTask::OutputData> &promise,
|
void matchesForCurrentDocument(QPromise<LocatorFilterEntries> &promise,
|
||||||
const QString &entry, const FilePath ¤tFileName)
|
const QString &entry, const FilePath ¤tFileName)
|
||||||
{
|
{
|
||||||
const QRegularExpression regexp = FuzzyMatcher::createRegExp(entry, Qt::CaseInsensitive, false);
|
const QRegularExpression regexp = FuzzyMatcher::createRegExp(entry, Qt::CaseInsensitive, false);
|
||||||
@@ -304,15 +304,15 @@ LocatorMatcherTask cppCurrentDocumentMatcher()
|
|||||||
|
|
||||||
TreeStorage<LocatorMatcherTask::Storage> storage;
|
TreeStorage<LocatorMatcherTask::Storage> storage;
|
||||||
|
|
||||||
const auto onSetup = [=](AsyncTask<LocatorMatcherTask::OutputData> &async) {
|
const auto onSetup = [=](AsyncTask<LocatorFilterEntries> &async) {
|
||||||
async.setFutureSynchronizer(Internal::CppEditorPlugin::futureSynchronizer());
|
async.setFutureSynchronizer(Internal::CppEditorPlugin::futureSynchronizer());
|
||||||
async.setConcurrentCallData(matchesForCurrentDocument, storage->input, currentFileName());
|
async.setConcurrentCallData(matchesForCurrentDocument, storage->input, currentFileName());
|
||||||
};
|
};
|
||||||
const auto onDone = [storage](const AsyncTask<LocatorMatcherTask::OutputData> &async) {
|
const auto onDone = [storage](const AsyncTask<LocatorFilterEntries> &async) {
|
||||||
if (async.isResultAvailable())
|
if (async.isResultAvailable())
|
||||||
storage->output = async.result();
|
storage->output = async.result();
|
||||||
};
|
};
|
||||||
return {Async<LocatorMatcherTask::OutputData>(onSetup, onDone, onDone), storage};
|
return {Async<LocatorFilterEntries>(onSetup, onDone, onDone), storage};
|
||||||
}
|
}
|
||||||
|
|
||||||
CppLocatorFilter::CppLocatorFilter()
|
CppLocatorFilter::CppLocatorFilter()
|
||||||
|
@@ -53,7 +53,7 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const QList<LocatorFilterEntry> entries = filter ? matchesFor(searchText) : runMatcher();
|
const LocatorFilterEntries entries = filter ? matchesFor(searchText) : runMatcher();
|
||||||
const ResultDataList results = ResultData::fromFilterEntryList(entries);
|
const ResultDataList results = ResultData::fromFilterEntryList(entries);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
ResultData::printFilterEntries(expectedResults, "Expected:");
|
ResultData::printFilterEntries(expectedResults, "Expected:");
|
||||||
@@ -93,7 +93,7 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const QList<LocatorFilterEntry> entries = matchers.isEmpty() ? matchesFor(searchText)
|
const LocatorFilterEntries entries = matchers.isEmpty() ? matchesFor(searchText)
|
||||||
: runMatcher();
|
: runMatcher();
|
||||||
ResultDataList results = ResultData::fromFilterEntryList(entries);
|
ResultDataList results = ResultData::fromFilterEntryList(entries);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
@@ -28,7 +28,7 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace LanguageClient {
|
namespace LanguageClient {
|
||||||
|
|
||||||
void filterResults(QPromise<LocatorMatcherTask::OutputData> &promise, Client *client,
|
void filterResults(QPromise<LocatorFilterEntries> &promise, Client *client,
|
||||||
const QList<SymbolInformation> &results, const QList<SymbolKind> &filter)
|
const QList<SymbolInformation> &results, const QList<SymbolKind> &filter)
|
||||||
{
|
{
|
||||||
const auto doFilter = [&](const SymbolInformation &info) {
|
const auto doFilter = [&](const SymbolInformation &info) {
|
||||||
@@ -71,7 +71,7 @@ LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount,
|
|||||||
*resultStorage = result->toList();
|
*resultStorage = result->toList();
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto onFilterSetup = [=](AsyncTask<LocatorMatcherTask::OutputData> &async) {
|
const auto onFilterSetup = [=](AsyncTask<LocatorFilterEntries> &async) {
|
||||||
const QList<SymbolInformation> results = *resultStorage;
|
const QList<SymbolInformation> results = *resultStorage;
|
||||||
if (results.isEmpty())
|
if (results.isEmpty())
|
||||||
return TaskAction::StopWithDone;
|
return TaskAction::StopWithDone;
|
||||||
@@ -79,7 +79,7 @@ LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount,
|
|||||||
async.setConcurrentCallData(filterResults, client, results, filter);
|
async.setConcurrentCallData(filterResults, client, results, filter);
|
||||||
return TaskAction::Continue;
|
return TaskAction::Continue;
|
||||||
};
|
};
|
||||||
const auto onFilterDone = [storage](const AsyncTask<LocatorMatcherTask::OutputData> &async) {
|
const auto onFilterDone = [storage](const AsyncTask<LocatorFilterEntries> &async) {
|
||||||
if (async.isResultAvailable())
|
if (async.isResultAvailable())
|
||||||
storage->output = async.result();
|
storage->output = async.result();
|
||||||
};
|
};
|
||||||
@@ -87,7 +87,7 @@ LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount,
|
|||||||
const Group root {
|
const Group root {
|
||||||
Storage(resultStorage),
|
Storage(resultStorage),
|
||||||
SymbolRequest(onQuerySetup, onQueryDone),
|
SymbolRequest(onQuerySetup, onQueryDone),
|
||||||
Async<LocatorMatcherTask::OutputData>(onFilterSetup, onFilterDone)
|
Async<LocatorFilterEntries>(onFilterSetup, onFilterDone)
|
||||||
};
|
};
|
||||||
return {root, storage};
|
return {root, storage};
|
||||||
}
|
}
|
||||||
|
@@ -599,7 +599,7 @@ void LineEditField::setupCompletion(FancyLineEdit *lineEdit)
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
if (m_completion == Completion::None)
|
if (m_completion == Completion::None)
|
||||||
return;
|
return;
|
||||||
const auto handleResults = [this, lineEdit](const QList<LocatorFilterEntry> &entries) {
|
const auto handleResults = [this, lineEdit](const LocatorFilterEntries &entries) {
|
||||||
QSet<QString> namespaces;
|
QSet<QString> namespaces;
|
||||||
QStringList classes;
|
QStringList classes;
|
||||||
Project * const project = ProjectTree::currentProject();
|
Project * const project = ProjectTree::currentProject();
|
||||||
|
Reference in New Issue
Block a user