LocatorFilter: Introduce LocatorMatcherTasks

Change-Id: I775c88b8ac7d7bb0719a6b20d1e5171dbd62a94d
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2023-04-12 20:12:57 +02:00
parent 422d422deb
commit 38d4f3fef3
3 changed files with 11 additions and 10 deletions

View File

@@ -209,7 +209,7 @@ ClangModelManagerSupport::ClangModelManagerSupport()
using WorkspaceMatcherCreator = std::function<Core::LocatorMatcherTask(Client *, int)>; using WorkspaceMatcherCreator = std::function<Core::LocatorMatcherTask(Client *, int)>;
const auto matcherCreator = [](const WorkspaceMatcherCreator &creator) { const auto matcherCreator = [](const WorkspaceMatcherCreator &creator) {
const QList<Client *> clients = clientsForOpenProjects(); const QList<Client *> clients = clientsForOpenProjects();
QList<LocatorMatcherTask> matchers; LocatorMatcherTasks matchers;
for (Client *client : clients) for (Client *client : clients)
matchers << creator(client, 10000); matchers << creator(client, 10000);
return matchers; return matchers;

View File

@@ -287,7 +287,7 @@ namespace Core {
class LocatorMatcherPrivate class LocatorMatcherPrivate
{ {
public: public:
QList<LocatorMatcherTask> m_tasks; LocatorMatcherTasks m_tasks;
LocatorMatcherTask::Storage m_storage; LocatorMatcherTask::Storage m_storage;
int m_parallelLimit = 0; int m_parallelLimit = 0;
std::unique_ptr<TaskTree> m_taskTree; std::unique_ptr<TaskTree> m_taskTree;
@@ -298,7 +298,7 @@ LocatorMatcher::LocatorMatcher()
LocatorMatcher::~LocatorMatcher() = default; LocatorMatcher::~LocatorMatcher() = default;
void LocatorMatcher::setTasks(const QList<LocatorMatcherTask> &tasks) void LocatorMatcher::setTasks(const LocatorMatcherTasks &tasks)
{ {
d->m_tasks = tasks; d->m_tasks = tasks;
} }
@@ -411,7 +411,7 @@ LocatorFilterEntries LocatorMatcher::outputData() const
return d->m_storage.output; return d->m_storage.output;
} }
LocatorFilterEntries LocatorMatcher::runBlocking(const QList<LocatorMatcherTask> &tasks, LocatorFilterEntries LocatorMatcher::runBlocking(const LocatorMatcherTasks &tasks,
const QString &input, int parallelLimit) const QString &input, int parallelLimit)
{ {
LocatorMatcher tree; LocatorMatcher tree;
@@ -435,10 +435,10 @@ void LocatorMatcher::addMatcherCreator(MatcherType type, const LocatorMatcherTas
s_matcherCreators[type].append(creator); s_matcherCreators[type].append(creator);
} }
QList<LocatorMatcherTask> LocatorMatcher::matchers(MatcherType type) LocatorMatcherTasks LocatorMatcher::matchers(MatcherType type)
{ {
const QList<LocatorMatcherTaskCreator> creators = s_matcherCreators.value(type); const QList<LocatorMatcherTaskCreator> creators = s_matcherCreators.value(type);
QList<LocatorMatcherTask> result; LocatorMatcherTasks result;
for (const LocatorMatcherTaskCreator &creator : creators) for (const LocatorMatcherTaskCreator &creator : creators)
result << creator(); result << creator();
return result; return result;

View File

@@ -132,7 +132,8 @@ public:
Utils::Tasking::TreeStorage<Storage> storage; Utils::Tasking::TreeStorage<Storage> storage;
}; };
using LocatorMatcherTaskCreator = std::function<QList<LocatorMatcherTask>()>; using LocatorMatcherTasks = QList<LocatorMatcherTask>;
using LocatorMatcherTaskCreator = std::function<LocatorMatcherTasks()>;
class LocatorMatcherPrivate; class LocatorMatcherPrivate;
enum class MatcherType { enum class MatcherType {
@@ -149,7 +150,7 @@ class CORE_EXPORT LocatorMatcher final : public QObject
public: public:
LocatorMatcher(); LocatorMatcher();
~LocatorMatcher(); ~LocatorMatcher();
void setTasks(const QList<LocatorMatcherTask> &tasks); void setTasks(const LocatorMatcherTasks &tasks);
void setInputData(const QString &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();
@@ -160,11 +161,11 @@ public:
LocatorFilterEntries outputData() const; LocatorFilterEntries outputData() const;
// Note: Starts internal event loop. // Note: Starts internal event loop.
static LocatorFilterEntries runBlocking(const QList<LocatorMatcherTask> &tasks, static LocatorFilterEntries runBlocking(const LocatorMatcherTasks &tasks,
const QString &input, int parallelLimit = 0); const QString &input, 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 LocatorMatcherTasks matchers(MatcherType type);
signals: signals:
void serialOutputDataReady(const LocatorFilterEntries &serialOutputData); void serialOutputDataReady(const LocatorFilterEntries &serialOutputData);