forked from qt-creator/qt-creator
ILocatorFilter: Refactor ILocatorFilter::matchers() function
Introduce LocatorStorage::storage() method, to be used from the bodies of locator task handlers. Replace the return value of ILocatorFilter::matchers() with a list of ExecutableItems. Change-Id: I467bb9f217465af74a017095d4fffdf74c4ba7bd Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -15,34 +15,35 @@
|
|||||||
|
|
||||||
#include <solutions/tasking/tasktree.h>
|
#include <solutions/tasking/tasktree.h>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
|
using namespace Tasking;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Autotest::Internal {
|
namespace Autotest::Internal {
|
||||||
|
|
||||||
static void linkAcceptor(const Utils::Link &link)
|
static void linkAcceptor(const Link &link)
|
||||||
{
|
{
|
||||||
if (link.hasValidTarget())
|
if (link.hasValidTarget())
|
||||||
Core::EditorManager::openEditorAt(link);
|
EditorManager::openEditorAt(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
using LinkAcceptor = std::function<void(const Utils::Link &)>;
|
using LinkAcceptor = std::function<void(const Link &)>;
|
||||||
|
|
||||||
static Core::LocatorMatcherTasks dataTagMatchers(const LinkAcceptor &acceptor)
|
static LocatorMatcherTasks dataTagMatchers(const LinkAcceptor &acceptor)
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [acceptor] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<Core::LocatorStorage> storage;
|
const QString input = storage.input();
|
||||||
|
|
||||||
const auto onSetup = [storage, acceptor] {
|
|
||||||
const QString input = storage->input();
|
|
||||||
const TestTreeItem *qtTestRoot = theQtTestFramework().rootNode();
|
const TestTreeItem *qtTestRoot = theQtTestFramework().rootNode();
|
||||||
if (!qtTestRoot)
|
if (!qtTestRoot)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Core::LocatorFilterEntries entries;
|
LocatorFilterEntries entries;
|
||||||
qtTestRoot->forAllChildItems([&entries, &input, acceptor = acceptor](TestTreeItem *it) {
|
qtTestRoot->forAllChildItems([&entries, &input, acceptor = acceptor](TestTreeItem *it) {
|
||||||
if (it->type() != TestTreeItem::TestDataTag)
|
if (it->type() != TestTreeItem::TestDataTag)
|
||||||
return;
|
return;
|
||||||
if (it->name().contains(input)) {
|
if (it->name().contains(input)) {
|
||||||
Core::LocatorFilterEntry entry;
|
LocatorFilterEntry entry;
|
||||||
entry.displayName = it->data(0, Qt::DisplayRole).toString();
|
entry.displayName = it->data(0, Qt::DisplayRole).toString();
|
||||||
{
|
{
|
||||||
const TestTreeItem *parent = it->parentItem();
|
const TestTreeItem *parent = it->parentItem();
|
||||||
@@ -52,18 +53,18 @@ static Core::LocatorMatcherTasks dataTagMatchers(const LinkAcceptor &acceptor)
|
|||||||
entry.displayExtra = grandParent->name() + "::" + parent->name();
|
entry.displayExtra = grandParent->name() + "::" + parent->name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entry.linkForEditor = std::make_optional(it->data(0, LinkRole).value<Utils::Link>());
|
entry.linkForEditor = std::make_optional(it->data(0, LinkRole).value<Link>());
|
||||||
entry.acceptor = [link = entry.linkForEditor, acceptor = acceptor] {
|
entry.acceptor = [link = entry.linkForEditor, acceptor = acceptor] {
|
||||||
if (link)
|
if (link)
|
||||||
acceptor(*link);
|
acceptor(*link);
|
||||||
return Core::AcceptResult();
|
return AcceptResult();
|
||||||
};
|
};
|
||||||
entries.append(entry);
|
entries.append(entry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
storage->reportOutput(entries);
|
storage.reportOutput(entries);
|
||||||
};
|
};
|
||||||
return {{Sync(onSetup), storage}};
|
return {Sync(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
DataTagLocatorFilter::DataTagLocatorFilter()
|
DataTagLocatorFilter::DataTagLocatorFilter()
|
||||||
@@ -79,7 +80,7 @@ DataTagLocatorFilter::DataTagLocatorFilter()
|
|||||||
setEnabled(ProjectManager::startupProject());
|
setEnabled(ProjectManager::startupProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::LocatorMatcherTasks DataTagLocatorFilter::matchers()
|
LocatorMatcherTasks DataTagLocatorFilter::matchers()
|
||||||
{
|
{
|
||||||
return dataTagMatchers(&linkAcceptor);
|
return dataTagMatchers(&linkAcceptor);
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ using namespace Core;
|
|||||||
using namespace LanguageClient;
|
using namespace LanguageClient;
|
||||||
using namespace LanguageServerProtocol;
|
using namespace LanguageServerProtocol;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -173,29 +174,23 @@ static void filterCurrentResults(QPromise<void> &promise, const LocatorStorage &
|
|||||||
|
|
||||||
static LocatorMatcherTask currentDocumentMatcher()
|
static LocatorMatcherTask currentDocumentMatcher()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
|
||||||
|
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
Storage<CurrentDocumentSymbolsData> resultStorage;
|
Storage<CurrentDocumentSymbolsData> resultStorage;
|
||||||
|
|
||||||
const auto onQuerySetup = [=](CurrentDocumentSymbolsRequest &request) {
|
|
||||||
Q_UNUSED(request)
|
|
||||||
};
|
|
||||||
const auto onQueryDone = [resultStorage](const CurrentDocumentSymbolsRequest &request) {
|
const auto onQueryDone = [resultStorage](const CurrentDocumentSymbolsRequest &request) {
|
||||||
*resultStorage = request.currentDocumentSymbolsData();
|
*resultStorage = request.currentDocumentSymbolsData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto onFilterSetup = [=](Async<void> &async) {
|
const auto onFilterSetup = [resultStorage](Async<void> &async) {
|
||||||
async.setConcurrentCallData(filterCurrentResults, *storage, *resultStorage,
|
async.setConcurrentCallData(filterCurrentResults, *LocatorStorage::storage(), *resultStorage,
|
||||||
TextDocument::currentTextDocument()->plainText());
|
TextDocument::currentTextDocument()->plainText());
|
||||||
};
|
};
|
||||||
|
|
||||||
const Group root {
|
const Group root {
|
||||||
resultStorage,
|
resultStorage,
|
||||||
CurrentDocumentSymbolsRequestTask(onQuerySetup, onQueryDone, CallDoneIf::Success),
|
CurrentDocumentSymbolsRequestTask({}, onQueryDone, CallDoneIf::Success),
|
||||||
AsyncTask<void>(onFilterSetup)
|
AsyncTask<void>(onFilterSetup)
|
||||||
};
|
};
|
||||||
return {root, storage};
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTasks ClangdCurrentDocumentFilter::matchers()
|
LocatorMatcherTasks ClangdCurrentDocumentFilter::matchers()
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CMakeProjectManager::Internal {
|
namespace CMakeProjectManager::Internal {
|
||||||
@@ -29,12 +30,9 @@ using BuildAcceptor = std::function<void(const BuildSystem *, const QString &)>;
|
|||||||
|
|
||||||
static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor)
|
static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor)
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [acceptor] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<LocatorStorage> storage;
|
const QString input = storage.input();
|
||||||
|
|
||||||
const auto onSetup = [storage, acceptor] {
|
|
||||||
const QString input = storage->input();
|
|
||||||
const QRegularExpression regexp
|
const QRegularExpression regexp
|
||||||
= ILocatorFilter::createRegExp(input, ILocatorFilter::caseSensitivity(input));
|
= ILocatorFilter::createRegExp(input, ILocatorFilter::caseSensitivity(input));
|
||||||
if (!regexp.isValid())
|
if (!regexp.isValid())
|
||||||
@@ -90,10 +88,10 @@ static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storage->reportOutput(
|
storage.reportOutput(
|
||||||
std::accumulate(std::begin(entries), std::end(entries), LocatorFilterEntries()));
|
std::accumulate(std::begin(entries), std::end(entries), LocatorFilterEntries()));
|
||||||
};
|
};
|
||||||
return {{Sync(onSetup), storage}};
|
return {Sync(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setupFilter(ILocatorFilter *filter)
|
static void setupFilter(ILocatorFilter *filter)
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
|
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
static const char lastTriggeredC[] = "LastTriggeredActions";
|
static const char lastTriggeredC[] = "LastTriggeredActions";
|
||||||
@@ -174,11 +175,7 @@ static void matches(QPromise<void> &promise, const LocatorStorage &storage,
|
|||||||
|
|
||||||
LocatorMatcherTasks ActionsFilter::matchers()
|
LocatorMatcherTasks ActionsFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [this](Async<void> &async) {
|
||||||
|
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
|
|
||||||
const auto onSetup = [this, storage](Async<void> &async) {
|
|
||||||
m_entries.clear();
|
m_entries.clear();
|
||||||
m_indexes.clear();
|
m_indexes.clear();
|
||||||
QList<const QMenu *> processedMenus;
|
QList<const QMenu *> processedMenus;
|
||||||
@@ -186,15 +183,16 @@ LocatorMatcherTasks ActionsFilter::matchers()
|
|||||||
for (QAction* action : menuBarActions())
|
for (QAction* action : menuBarActions())
|
||||||
collectEntriesForAction(action, {}, processedMenus);
|
collectEntriesForAction(action, {}, processedMenus);
|
||||||
collectEntriesForCommands();
|
collectEntriesForCommands();
|
||||||
if (storage->input().simplified().isEmpty()) {
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
storage->reportOutput(m_entries);
|
if (storage.input().simplified().isEmpty()) {
|
||||||
|
storage.reportOutput(m_entries);
|
||||||
return SetupResult::StopWithSuccess;
|
return SetupResult::StopWithSuccess;
|
||||||
}
|
}
|
||||||
async.setConcurrentCallData(matches, *storage, m_entries);
|
async.setConcurrentCallData(matches, storage, m_entries);
|
||||||
return SetupResult::Continue;
|
return SetupResult::Continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
return {{AsyncTask<void>(onSetup), storage}};
|
return {AsyncTask<void>(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorFilterEntry::Acceptor ActionsFilter::acceptor(const ActionFilterEntryData &data) const
|
LocatorFilterEntry::Acceptor ActionsFilter::acceptor(const ActionFilterEntryData &data) const
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
@@ -25,12 +26,9 @@ CommandLocator::CommandLocator(Id id, const QString &displayName, const QString
|
|||||||
|
|
||||||
LocatorMatcherTasks CommandLocator::matchers()
|
LocatorMatcherTasks CommandLocator::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [commands = m_commands] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<LocatorStorage> storage;
|
const QString input = storage.input();
|
||||||
|
|
||||||
const auto onSetup = [storage, commands = m_commands] {
|
|
||||||
const QString input = storage->input();
|
|
||||||
const Qt::CaseSensitivity inputCaseSensitivity = caseSensitivity(input);
|
const Qt::CaseSensitivity inputCaseSensitivity = caseSensitivity(input);
|
||||||
LocatorFilterEntries goodEntries;
|
LocatorFilterEntries goodEntries;
|
||||||
LocatorFilterEntries betterEntries;
|
LocatorFilterEntries betterEntries;
|
||||||
@@ -63,9 +61,9 @@ LocatorMatcherTasks CommandLocator::matchers()
|
|||||||
goodEntries.append(entry);
|
goodEntries.append(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storage->reportOutput(betterEntries + goodEntries);
|
storage.reportOutput(betterEntries + goodEntries);
|
||||||
};
|
};
|
||||||
return {{Sync(onSetup), storage}};
|
return {Sync(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core::Internal {
|
namespace Core::Internal {
|
||||||
@@ -40,12 +41,9 @@ ExecuteFilter::~ExecuteFilter()
|
|||||||
|
|
||||||
LocatorMatcherTasks ExecuteFilter::matchers()
|
LocatorMatcherTasks ExecuteFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [this] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<LocatorStorage> storage;
|
const QString input = storage.input();
|
||||||
|
|
||||||
const auto onSetup = [this, storage] {
|
|
||||||
const QString input = storage->input();
|
|
||||||
LocatorFilterEntries entries;
|
LocatorFilterEntries entries;
|
||||||
if (!input.isEmpty()) { // avoid empty entry
|
if (!input.isEmpty()) { // avoid empty entry
|
||||||
LocatorFilterEntry entry;
|
LocatorFilterEntry entry;
|
||||||
@@ -69,9 +67,9 @@ LocatorMatcherTasks ExecuteFilter::matchers()
|
|||||||
others.append(entry);
|
others.append(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storage->reportOutput(entries + others);
|
storage.reportOutput(entries + others);
|
||||||
};
|
};
|
||||||
return {{Sync(onSetup), storage}};
|
return {Sync(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecuteFilter::acceptCommand(const QString &cmd)
|
void ExecuteFilter::acceptCommand(const QString &cmd)
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
using namespace Tasking;
|
||||||
|
|
||||||
namespace Core::Internal {
|
namespace Core::Internal {
|
||||||
|
|
||||||
ExternalToolsFilter::ExternalToolsFilter()
|
ExternalToolsFilter::ExternalToolsFilter()
|
||||||
@@ -27,12 +29,9 @@ ExternalToolsFilter::ExternalToolsFilter()
|
|||||||
|
|
||||||
LocatorMatcherTasks ExternalToolsFilter::matchers()
|
LocatorMatcherTasks ExternalToolsFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<LocatorStorage> storage;
|
const QString input = storage.input();
|
||||||
|
|
||||||
const auto onSetup = [storage] {
|
|
||||||
const QString input = storage->input();
|
|
||||||
|
|
||||||
LocatorFilterEntries bestEntries;
|
LocatorFilterEntries bestEntries;
|
||||||
LocatorFilterEntries betterEntries;
|
LocatorFilterEntries betterEntries;
|
||||||
@@ -77,10 +76,10 @@ LocatorMatcherTasks ExternalToolsFilter::matchers()
|
|||||||
return AcceptResult();
|
return AcceptResult();
|
||||||
};
|
};
|
||||||
|
|
||||||
storage->reportOutput(bestEntries + betterEntries + goodEntries
|
storage.reportOutput(bestEntries + betterEntries + goodEntries
|
||||||
+ LocatorFilterEntries{configEntry});
|
+ LocatorFilterEntries{configEntry});
|
||||||
};
|
};
|
||||||
return {{Sync(onSetup), storage}};
|
return {Sync(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Core::Internal
|
} // Core::Internal
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core::Internal {
|
namespace Core::Internal {
|
||||||
@@ -304,17 +305,13 @@ static void matches(QPromise<void> &promise, const LocatorStorage &storage,
|
|||||||
|
|
||||||
LocatorMatcherTasks FileSystemFilter::matchers()
|
LocatorMatcherTasks FileSystemFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [includeHidden = m_includeHidden, shortcut = shortcutString()]
|
||||||
|
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
|
|
||||||
const auto onSetup = [storage, includeHidden = m_includeHidden, shortcut = shortcutString()]
|
|
||||||
(Async<void> &async) {
|
(Async<void> &async) {
|
||||||
async.setConcurrentCallData(matches, *storage, shortcut,
|
async.setConcurrentCallData(matches, *LocatorStorage::storage(), shortcut,
|
||||||
DocumentManager::fileDialogInitialDirectory(), includeHidden);
|
DocumentManager::fileDialogInitialDirectory(), includeHidden);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {{AsyncTask<void>(onSetup), storage}};
|
return {AsyncTask<void>(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileSystemFilterOptions : public QDialog
|
class FileSystemFilterOptions : public QDialog
|
||||||
|
@@ -291,6 +291,14 @@ void LocatorStorage::reportOutput(const LocatorFilterEntries &outputData) const
|
|||||||
d->reportOutput(outputData);
|
d->reportOutput(outputData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Please note the thread_local keyword below guarantees a separate instance per thread.
|
||||||
|
static thread_local Storage<LocatorStorage> s_locatorStorage = {};
|
||||||
|
|
||||||
|
Storage<LocatorStorage> &LocatorStorage::storage()
|
||||||
|
{
|
||||||
|
return s_locatorStorage;
|
||||||
|
}
|
||||||
|
|
||||||
void LocatorStorage::finalize() const
|
void LocatorStorage::finalize() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d, return);
|
QTC_ASSERT(d, return);
|
||||||
@@ -366,16 +374,16 @@ void LocatorMatcher::start()
|
|||||||
|
|
||||||
const auto onTaskTreeSetup = [iterator, input = d->m_input, collectorStorage](TaskTree &taskTree) {
|
const auto onTaskTreeSetup = [iterator, input = d->m_input, collectorStorage](TaskTree &taskTree) {
|
||||||
const std::shared_ptr<ResultsDeduplicator> deduplicator = collectorStorage->m_deduplicator;
|
const std::shared_ptr<ResultsDeduplicator> deduplicator = collectorStorage->m_deduplicator;
|
||||||
const Storage<LocatorStorage> storage = iterator->storage;
|
const auto onSetup = [input, index = iterator.iteration(), deduplicator] {
|
||||||
const auto onSetup = [storage, input, index = iterator.iteration(), deduplicator] {
|
*LocatorStorage::storage()
|
||||||
*storage = std::make_shared<LocatorStoragePrivate>(input, index, deduplicator);
|
= std::make_shared<LocatorStoragePrivate>(input, index, deduplicator);
|
||||||
};
|
};
|
||||||
taskTree.setRecipe({
|
taskTree.setRecipe({
|
||||||
finishAllAndSuccess,
|
finishAllAndSuccess,
|
||||||
storage,
|
LocatorStorage::storage(),
|
||||||
onGroupSetup(onSetup),
|
onGroupSetup(onSetup),
|
||||||
iterator->task,
|
*iterator,
|
||||||
onGroupDone([storage] { storage->finalize(); })
|
onGroupDone([] { LocatorStorage::storage()->finalize(); })
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1359,10 +1367,9 @@ static void filter(QPromise<LocatorFileCachePrivate> &promise, const LocatorStor
|
|||||||
*/
|
*/
|
||||||
LocatorMatcherTask LocatorFileCache::matcher() const
|
LocatorMatcherTask LocatorFileCache::matcher() const
|
||||||
{
|
{
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
std::weak_ptr<LocatorFileCachePrivate> weak = d;
|
std::weak_ptr<LocatorFileCachePrivate> weak = d;
|
||||||
|
|
||||||
const auto onSetup = [storage, weak](Async<LocatorFileCachePrivate> &async) {
|
const auto onSetup = [weak](Async<LocatorFileCachePrivate> &async) {
|
||||||
auto that = weak.lock();
|
auto that = weak.lock();
|
||||||
if (!that) // LocatorMatcher is running after *this LocatorFileCache was destructed.
|
if (!that) // LocatorMatcher is running after *this LocatorFileCache was destructed.
|
||||||
return SetupResult::StopWithSuccess;
|
return SetupResult::StopWithSuccess;
|
||||||
@@ -1372,7 +1379,7 @@ LocatorMatcherTask LocatorFileCache::matcher() const
|
|||||||
// no provider is set or it returned empty generator
|
// no provider is set or it returned empty generator
|
||||||
that->bumpExecutionId();
|
that->bumpExecutionId();
|
||||||
|
|
||||||
async.setConcurrentCallData(&filter, *storage, *that);
|
async.setConcurrentCallData(&filter, *LocatorStorage::storage(), *that);
|
||||||
return SetupResult::Continue;
|
return SetupResult::Continue;
|
||||||
};
|
};
|
||||||
const auto onDone = [weak](const Async<LocatorFileCachePrivate> &async) {
|
const auto onDone = [weak](const Async<LocatorFileCachePrivate> &async) {
|
||||||
@@ -1392,7 +1399,7 @@ LocatorMatcherTask LocatorFileCache::matcher() const
|
|||||||
that->update(async.result());
|
that->update(async.result());
|
||||||
};
|
};
|
||||||
|
|
||||||
return {AsyncTask<LocatorFileCachePrivate>(onSetup, onDone, CallDoneIf::Success), storage};
|
return AsyncTask<LocatorFileCachePrivate>(onSetup, onDone, CallDoneIf::Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Core
|
} // Core
|
||||||
|
@@ -126,6 +126,8 @@ public:
|
|||||||
LocatorStorage() = default;
|
LocatorStorage() = default;
|
||||||
QString input() const;
|
QString input() const;
|
||||||
void reportOutput(const LocatorFilterEntries &outputData) const;
|
void reportOutput(const LocatorFilterEntries &outputData) const;
|
||||||
|
// Only use it from inside the bodies of Task handlers.
|
||||||
|
static Tasking::Storage<LocatorStorage> &storage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class LocatorMatcher;
|
friend class LocatorMatcher;
|
||||||
@@ -134,17 +136,7 @@ private:
|
|||||||
std::shared_ptr<LocatorStoragePrivate> d;
|
std::shared_ptr<LocatorStoragePrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CORE_EXPORT LocatorMatcherTask final
|
using LocatorMatcherTask = Tasking::GroupItem;
|
||||||
{
|
|
||||||
public:
|
|
||||||
// The main task. Initial data (searchTerm) should be taken from storage.input().
|
|
||||||
// Results reporting is done via the storage.reportOutput().
|
|
||||||
Tasking::GroupItem task = Tasking::Group{};
|
|
||||||
|
|
||||||
// When constructing the task, don't place the storage inside the task above.
|
|
||||||
Tasking::Storage<LocatorStorage> storage;
|
|
||||||
};
|
|
||||||
|
|
||||||
using LocatorMatcherTasks = QList<LocatorMatcherTask>;
|
using LocatorMatcherTasks = QList<LocatorMatcherTask>;
|
||||||
using LocatorMatcherTaskCreator = std::function<LocatorMatcherTasks()>;
|
using LocatorMatcherTaskCreator = std::function<LocatorMatcherTasks()>;
|
||||||
class LocatorMatcherPrivate;
|
class LocatorMatcherPrivate;
|
||||||
|
@@ -366,15 +366,15 @@ JavaScriptFilter::~JavaScriptFilter() = default;
|
|||||||
|
|
||||||
LocatorMatcherTasks JavaScriptFilter::matchers()
|
LocatorMatcherTasks JavaScriptFilter::matchers()
|
||||||
{
|
{
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
if (!m_javaScriptEngine)
|
if (!m_javaScriptEngine)
|
||||||
m_javaScriptEngine.reset(new JavaScriptEngine);
|
m_javaScriptEngine.reset(new JavaScriptEngine);
|
||||||
QPointer<JavaScriptEngine> engine = m_javaScriptEngine.get();
|
QPointer<JavaScriptEngine> engine = m_javaScriptEngine.get();
|
||||||
|
|
||||||
const auto onSetup = [storage, engine] {
|
const auto onSetup = [engine] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
if (!engine)
|
if (!engine)
|
||||||
return SetupResult::StopWithError;
|
return SetupResult::StopWithError;
|
||||||
if (storage->input().trimmed().isEmpty()) {
|
if (storage.input().trimmed().isEmpty()) {
|
||||||
LocatorFilterEntry entry;
|
LocatorFilterEntry entry;
|
||||||
entry.displayName = Tr::tr("Reset Engine");
|
entry.displayName = Tr::tr("Reset Engine");
|
||||||
entry.acceptor = [engine] {
|
entry.acceptor = [engine] {
|
||||||
@@ -385,21 +385,22 @@ LocatorMatcherTasks JavaScriptFilter::matchers()
|
|||||||
}
|
}
|
||||||
return AcceptResult();
|
return AcceptResult();
|
||||||
};
|
};
|
||||||
storage->reportOutput({entry});
|
storage.reportOutput({entry});
|
||||||
return SetupResult::StopWithSuccess;
|
return SetupResult::StopWithSuccess;
|
||||||
}
|
}
|
||||||
return SetupResult::Continue;
|
return SetupResult::Continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto onJavaScriptSetup = [storage, engine](JavaScriptRequest &request) {
|
const auto onJavaScriptSetup = [engine](JavaScriptRequest &request) {
|
||||||
request.setEngine(engine);
|
request.setEngine(engine);
|
||||||
request.setEvaluateData(storage->input());
|
request.setEvaluateData(LocatorStorage::storage()->input());
|
||||||
};
|
};
|
||||||
const auto onJavaScriptDone = [storage](const JavaScriptRequest &request, DoneWith result) {
|
const auto onJavaScriptDone = [](const JavaScriptRequest &request, DoneWith result) {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
if (result != DoneWith::Success) {
|
if (result != DoneWith::Success) {
|
||||||
LocatorFilterEntry entry;
|
LocatorFilterEntry entry;
|
||||||
entry.displayName = request.output().m_output;
|
entry.displayName = request.output().m_output;
|
||||||
storage->reportOutput({entry});
|
storage.reportOutput({entry});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto acceptor = [](const QString &clipboardContents) {
|
const auto acceptor = [](const QString &clipboardContents) {
|
||||||
@@ -408,7 +409,7 @@ LocatorMatcherTasks JavaScriptFilter::matchers()
|
|||||||
return AcceptResult();
|
return AcceptResult();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const QString input = storage->input();
|
const QString input = storage.input();
|
||||||
const QString output = request.output().m_output;
|
const QString output = request.output().m_output;
|
||||||
const QString expression = input + " = " + output;
|
const QString expression = input + " = " + output;
|
||||||
|
|
||||||
@@ -423,7 +424,7 @@ LocatorMatcherTasks JavaScriptFilter::matchers()
|
|||||||
copyExpressionEntry.displayName = Tr::tr("Copy to clipboard: %1").arg(expression);
|
copyExpressionEntry.displayName = Tr::tr("Copy to clipboard: %1").arg(expression);
|
||||||
copyExpressionEntry.acceptor = acceptor(expression);
|
copyExpressionEntry.acceptor = acceptor(expression);
|
||||||
|
|
||||||
storage->reportOutput({entry, copyResultEntry, copyExpressionEntry});
|
storage.reportOutput({entry, copyResultEntry, copyExpressionEntry});
|
||||||
};
|
};
|
||||||
|
|
||||||
const Group root {
|
const Group root {
|
||||||
@@ -431,7 +432,7 @@ LocatorMatcherTasks JavaScriptFilter::matchers()
|
|||||||
JavaScriptRequestTask(onJavaScriptSetup, onJavaScriptDone)
|
JavaScriptRequestTask(onJavaScriptSetup, onJavaScriptDone)
|
||||||
};
|
};
|
||||||
|
|
||||||
return {{root, storage}};
|
return {root};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Core::Internal
|
} // namespace Core::Internal
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core::Internal {
|
namespace Core::Internal {
|
||||||
@@ -26,12 +27,9 @@ LocatorFiltersFilter::LocatorFiltersFilter():
|
|||||||
|
|
||||||
LocatorMatcherTasks LocatorFiltersFilter::matchers()
|
LocatorMatcherTasks LocatorFiltersFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [icon = m_icon] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<LocatorStorage> storage;
|
if (!storage.input().isEmpty())
|
||||||
|
|
||||||
const auto onSetup = [storage, icon = m_icon] {
|
|
||||||
if (!storage->input().isEmpty())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMap<QString, ILocatorFilter *> uniqueFilters;
|
QMap<QString, ILocatorFilter *> uniqueFilters;
|
||||||
@@ -60,9 +58,9 @@ LocatorMatcherTasks LocatorFiltersFilter::matchers()
|
|||||||
entries.append(entry);
|
entries.append(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storage->reportOutput(entries);
|
storage.reportOutput(entries);
|
||||||
};
|
};
|
||||||
return {{Sync(onSetup), storage}};
|
return {Sync(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Core::Internal
|
} // Core::Internal
|
||||||
|
@@ -70,15 +70,13 @@ static void matchEditors(QPromise<void> &promise, const LocatorStorage &storage,
|
|||||||
|
|
||||||
LocatorMatcherTasks OpenDocumentsFilter::matchers()
|
LocatorMatcherTasks OpenDocumentsFilter::matchers()
|
||||||
{
|
{
|
||||||
Storage<LocatorStorage> storage;
|
const auto onSetup = [](Async<void> &async) {
|
||||||
|
|
||||||
const auto onSetup = [storage](Async<void> &async) {
|
|
||||||
const QList<Entry> editorsData = Utils::transform(DocumentModel::entries(),
|
const QList<Entry> editorsData = Utils::transform(DocumentModel::entries(),
|
||||||
[](const DocumentModel::Entry *e) { return Entry{e->filePath(), e->displayName()}; });
|
[](const DocumentModel::Entry *e) { return Entry{e->filePath(), e->displayName()}; });
|
||||||
async.setConcurrentCallData(matchEditors, *storage, editorsData);
|
async.setConcurrentCallData(matchEditors, *LocatorStorage::storage(), editorsData);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {{AsyncTask<void>(onSetup), storage}};
|
return {AsyncTask<void>(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Core::Internal
|
} // namespace Core::Internal
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core::Internal {
|
namespace Core::Internal {
|
||||||
@@ -176,16 +177,12 @@ static void matches(QPromise<void> &promise,
|
|||||||
|
|
||||||
LocatorMatcherTasks SpotlightLocatorFilter::matchers()
|
LocatorMatcherTasks SpotlightLocatorFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [command = m_command,
|
||||||
|
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
|
|
||||||
const auto onSetup = [storage,
|
|
||||||
command = m_command,
|
|
||||||
insensArgs = m_arguments,
|
insensArgs = m_arguments,
|
||||||
sensArgs = m_caseSensitiveArguments,
|
sensArgs = m_caseSensitiveArguments,
|
||||||
sortResults = m_sortResults](Async<void> &async) {
|
sortResults = m_sortResults](Async<void> &async) {
|
||||||
const Link link = Link::fromString(storage->input(), true);
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
|
const Link link = Link::fromString(storage.input(), true);
|
||||||
const FilePath input = link.targetFilePath;
|
const FilePath input = link.targetFilePath;
|
||||||
if (input.isEmpty())
|
if (input.isEmpty())
|
||||||
return SetupResult::StopWithSuccess;
|
return SetupResult::StopWithSuccess;
|
||||||
@@ -196,11 +193,11 @@ LocatorMatcherTasks SpotlightLocatorFilter::matchers()
|
|||||||
? insensArgs : sensArgs;
|
? insensArgs : sensArgs;
|
||||||
const CommandLine cmd(FilePath::fromString(command), expander->expand(args),
|
const CommandLine cmd(FilePath::fromString(command), expander->expand(args),
|
||||||
CommandLine::Raw);
|
CommandLine::Raw);
|
||||||
async.setConcurrentCallData(matches, *storage, cmd, sortResults);
|
async.setConcurrentCallData(matches, storage, cmd, sortResults);
|
||||||
return SetupResult::Continue;
|
return SetupResult::Continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
return {{AsyncTask<void>(onSetup), storage}};
|
return {AsyncTask<void>(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpotlightLocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
bool SpotlightLocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
@@ -163,12 +164,9 @@ UrlLocatorFilter::UrlLocatorFilter(const QString &displayName, Id id)
|
|||||||
|
|
||||||
LocatorMatcherTasks UrlLocatorFilter::matchers()
|
LocatorMatcherTasks UrlLocatorFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [urls = remoteUrls()] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<LocatorStorage> storage;
|
const QString input = storage.input();
|
||||||
|
|
||||||
const auto onSetup = [storage, urls = remoteUrls()] {
|
|
||||||
const QString input = storage->input();
|
|
||||||
LocatorFilterEntries entries;
|
LocatorFilterEntries entries;
|
||||||
for (const QString &url : urls) {
|
for (const QString &url : urls) {
|
||||||
const QString name = url.arg(input);
|
const QString name = url.arg(input);
|
||||||
@@ -182,9 +180,9 @@ LocatorMatcherTasks UrlLocatorFilter::matchers()
|
|||||||
entry.highlightInfo = {int(name.lastIndexOf(input)), int(input.length())};
|
entry.highlightInfo = {int(name.lastIndexOf(input)), int(input.length())};
|
||||||
entries.append(entry);
|
entries.append(entry);
|
||||||
}
|
}
|
||||||
storage->reportOutput(entries);
|
storage.reportOutput(entries);
|
||||||
};
|
};
|
||||||
return {{Sync(onSetup), storage}};
|
return {Sync(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
const char kDisplayNameKey[] = "displayName";
|
const char kDisplayNameKey[] = "displayName";
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace CppEditor {
|
namespace CppEditor {
|
||||||
@@ -101,14 +102,10 @@ void matchesFor(QPromise<void> &promise, const LocatorStorage &storage,
|
|||||||
|
|
||||||
LocatorMatcherTask locatorMatcher(IndexItem::ItemType type, const EntryFromIndex &converter)
|
LocatorMatcherTask locatorMatcher(IndexItem::ItemType type, const EntryFromIndex &converter)
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [type, converter](Async<void> &async) {
|
||||||
|
async.setConcurrentCallData(matchesFor, *LocatorStorage::storage(), type, converter);
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
|
|
||||||
const auto onSetup = [=](Async<void> &async) {
|
|
||||||
async.setConcurrentCallData(matchesFor, *storage, type, converter);
|
|
||||||
};
|
};
|
||||||
return {AsyncTask<void>(onSetup), storage};
|
return AsyncTask<void>(onSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask allSymbolsMatcher()
|
LocatorMatcherTask allSymbolsMatcher()
|
||||||
@@ -298,14 +295,10 @@ FilePath currentFileName()
|
|||||||
|
|
||||||
LocatorMatcherTask currentDocumentMatcher()
|
LocatorMatcherTask currentDocumentMatcher()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [](Async<void> &async) {
|
||||||
|
async.setConcurrentCallData(matchesForCurrentDocument, *LocatorStorage::storage(), currentFileName());
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
|
|
||||||
const auto onSetup = [=](Async<void> &async) {
|
|
||||||
async.setConcurrentCallData(matchesForCurrentDocument, *storage, currentFileName());
|
|
||||||
};
|
};
|
||||||
return {AsyncTask<void>(onSetup), storage};
|
return AsyncTask<void>(onSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
using MatcherCreator = std::function<Core::LocatorMatcherTask()>;
|
using MatcherCreator = std::function<Core::LocatorMatcherTask()>;
|
||||||
|
@@ -82,9 +82,7 @@ static void matches(QPromise<QStringList> &promise, const LocatorStorage &storag
|
|||||||
|
|
||||||
LocatorMatcherTasks HelpIndexFilter::matchers()
|
LocatorMatcherTasks HelpIndexFilter::matchers()
|
||||||
{
|
{
|
||||||
Storage<LocatorStorage> storage;
|
const auto onSetup = [this](Async<QStringList> &async) {
|
||||||
|
|
||||||
const auto onSetup = [this, storage](Async<QStringList> &async) {
|
|
||||||
if (m_needsUpdate) {
|
if (m_needsUpdate) {
|
||||||
m_needsUpdate = false;
|
m_needsUpdate = false;
|
||||||
LocalHelpManager::setupGuiHelpEngine();
|
LocalHelpManager::setupGuiHelpEngine();
|
||||||
@@ -92,18 +90,19 @@ LocatorMatcherTasks HelpIndexFilter::matchers()
|
|||||||
m_lastIndicesCache.clear();
|
m_lastIndicesCache.clear();
|
||||||
m_lastEntry.clear();
|
m_lastEntry.clear();
|
||||||
}
|
}
|
||||||
const QStringList cache = m_lastEntry.isEmpty() || !storage->input().contains(m_lastEntry)
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
|
const QStringList cache = m_lastEntry.isEmpty() || !storage.input().contains(m_lastEntry)
|
||||||
? m_allIndicesCache : m_lastIndicesCache;
|
? m_allIndicesCache : m_lastIndicesCache;
|
||||||
async.setConcurrentCallData(matches, *storage, cache, m_icon);
|
async.setConcurrentCallData(matches, storage, cache, m_icon);
|
||||||
};
|
};
|
||||||
const auto onDone = [this, storage](const Async<QStringList> &async) {
|
const auto onDone = [this](const Async<QStringList> &async) {
|
||||||
if (async.isResultAvailable()) {
|
if (async.isResultAvailable()) {
|
||||||
m_lastIndicesCache = async.result();
|
m_lastIndicesCache = async.result();
|
||||||
m_lastEntry = storage->input();
|
m_lastEntry = LocatorStorage::storage()->input();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return {{AsyncTask<QStringList>(onSetup, onDone, CallDoneIf::Success), storage}};
|
return {AsyncTask<QStringList>(onSetup, onDone, CallDoneIf::Success)};
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpIndexFilter::invalidateCache()
|
void HelpIndexFilter::invalidateCache()
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace LanguageServerProtocol;
|
using namespace LanguageServerProtocol;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace LanguageClient {
|
namespace LanguageClient {
|
||||||
@@ -44,15 +45,12 @@ void filterResults(QPromise<void> &promise, const LocatorStorage &storage, Clien
|
|||||||
LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount,
|
LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount,
|
||||||
const QList<SymbolKind> &filter)
|
const QList<SymbolKind> &filter)
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
|
||||||
|
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
Storage<QList<SymbolInformation>> resultStorage;
|
Storage<QList<SymbolInformation>> resultStorage;
|
||||||
|
|
||||||
const auto onQuerySetup = [storage, client, maxResultCount](ClientWorkspaceSymbolRequest &request) {
|
const auto onQuerySetup = [client, maxResultCount](ClientWorkspaceSymbolRequest &request) {
|
||||||
request.setClient(client);
|
request.setClient(client);
|
||||||
WorkspaceSymbolParams params;
|
WorkspaceSymbolParams params;
|
||||||
params.setQuery(storage->input());
|
params.setQuery(LocatorStorage::storage()->input());
|
||||||
if (maxResultCount > 0)
|
if (maxResultCount > 0)
|
||||||
params.setLimit(maxResultCount);
|
params.setLimit(maxResultCount);
|
||||||
request.setParams(params);
|
request.setParams(params);
|
||||||
@@ -64,11 +62,12 @@ LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount,
|
|||||||
*resultStorage = result->toList();
|
*resultStorage = result->toList();
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto onFilterSetup = [storage, resultStorage, client, filter](Async<void> &async) {
|
const auto onFilterSetup = [resultStorage, client, filter](Async<void> &async) {
|
||||||
const QList<SymbolInformation> results = *resultStorage;
|
const QList<SymbolInformation> results = *resultStorage;
|
||||||
if (results.isEmpty())
|
if (results.isEmpty())
|
||||||
return SetupResult::StopWithSuccess;
|
return SetupResult::StopWithSuccess;
|
||||||
async.setConcurrentCallData(filterResults, *storage, client, results, filter);
|
async.setConcurrentCallData(filterResults, *LocatorStorage::storage(), client, results,
|
||||||
|
filter);
|
||||||
return SetupResult::Continue;
|
return SetupResult::Continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,7 +76,7 @@ LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount,
|
|||||||
ClientWorkspaceSymbolRequestTask(onQuerySetup, onQueryDone, CallDoneIf::Success),
|
ClientWorkspaceSymbolRequestTask(onQuerySetup, onQueryDone, CallDoneIf::Success),
|
||||||
AsyncTask<void>(onFilterSetup)
|
AsyncTask<void>(onFilterSetup)
|
||||||
};
|
};
|
||||||
return {root, storage};
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask allSymbolsMatcher(Client *client, int maxResultCount)
|
LocatorMatcherTask allSymbolsMatcher(Client *client, int maxResultCount)
|
||||||
@@ -114,28 +113,23 @@ static void filterCurrentResults(QPromise<void> &promise, const LocatorStorage &
|
|||||||
|
|
||||||
LocatorMatcherTask currentDocumentMatcher()
|
LocatorMatcherTask currentDocumentMatcher()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
|
||||||
|
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
Storage<CurrentDocumentSymbolsData> resultStorage;
|
Storage<CurrentDocumentSymbolsData> resultStorage;
|
||||||
|
|
||||||
const auto onQuerySetup = [](CurrentDocumentSymbolsRequest &request) {
|
|
||||||
Q_UNUSED(request)
|
|
||||||
};
|
|
||||||
const auto onQueryDone = [resultStorage](const CurrentDocumentSymbolsRequest &request) {
|
const auto onQueryDone = [resultStorage](const CurrentDocumentSymbolsRequest &request) {
|
||||||
*resultStorage = request.currentDocumentSymbolsData();
|
*resultStorage = request.currentDocumentSymbolsData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto onFilterSetup = [storage, resultStorage](Async<void> &async) {
|
const auto onFilterSetup = [resultStorage](Async<void> &async) {
|
||||||
async.setConcurrentCallData(filterCurrentResults, *storage, *resultStorage);
|
async.setConcurrentCallData(filterCurrentResults, *LocatorStorage::storage(),
|
||||||
|
*resultStorage);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Group root {
|
const Group root {
|
||||||
resultStorage,
|
resultStorage,
|
||||||
CurrentDocumentSymbolsRequestTask(onQuerySetup, onQueryDone, CallDoneIf::Success),
|
CurrentDocumentSymbolsRequestTask({}, onQueryDone, CallDoneIf::Success),
|
||||||
AsyncTask<void>(onFilterSetup)
|
AsyncTask<void>(onFilterSetup)
|
||||||
};
|
};
|
||||||
return {root, storage};
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
using MatcherCreator = std::function<Core::LocatorMatcherTask(Client *, int)>;
|
using MatcherCreator = std::function<Core::LocatorMatcherTask(Client *, int)>;
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Macros;
|
using namespace Macros;
|
||||||
using namespace Macros::Internal;
|
using namespace Macros::Internal;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
MacroLocatorFilter::MacroLocatorFilter()
|
MacroLocatorFilter::MacroLocatorFilter()
|
||||||
@@ -28,12 +29,9 @@ MacroLocatorFilter::MacroLocatorFilter()
|
|||||||
|
|
||||||
LocatorMatcherTasks MacroLocatorFilter::matchers()
|
LocatorMatcherTasks MacroLocatorFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [icon = m_icon] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<LocatorStorage> storage;
|
const QString input = storage.input();
|
||||||
|
|
||||||
const auto onSetup = [storage, icon = m_icon] {
|
|
||||||
const QString input = storage->input();
|
|
||||||
const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(input);
|
const Qt::CaseSensitivity entryCaseSensitivity = caseSensitivity(input);
|
||||||
const QMap<QString, Macro *> ¯os = MacroManager::macros();
|
const QMap<QString, Macro *> ¯os = MacroManager::macros();
|
||||||
LocatorFilterEntries goodEntries;
|
LocatorFilterEntries goodEntries;
|
||||||
@@ -69,7 +67,7 @@ LocatorMatcherTasks MacroLocatorFilter::matchers()
|
|||||||
goodEntries.append(filterEntry);
|
goodEntries.append(filterEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storage->reportOutput(betterEntries + goodEntries);
|
storage.reportOutput(betterEntries + goodEntries);
|
||||||
};
|
};
|
||||||
return {{Sync(onSetup), storage}};
|
return {Sync(onSetup)};
|
||||||
}
|
}
|
||||||
|
@@ -4253,14 +4253,13 @@ static RunConfiguration *runConfigurationForDisplayName(const QString &displayNa
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
using namespace Tasking;
|
||||||
|
|
||||||
static LocatorMatcherTasks runConfigurationMatchers(const RunAcceptor &acceptor)
|
static LocatorMatcherTasks runConfigurationMatchers(const RunAcceptor &acceptor)
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [acceptor] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<LocatorStorage> storage;
|
const QString input = storage.input();
|
||||||
|
|
||||||
const auto onSetup = [storage, acceptor] {
|
|
||||||
const QString input = storage->input();
|
|
||||||
const Target *target = ProjectManager::startupTarget();
|
const Target *target = ProjectManager::startupTarget();
|
||||||
if (!target)
|
if (!target)
|
||||||
return;
|
return;
|
||||||
@@ -4280,9 +4279,9 @@ static LocatorMatcherTasks runConfigurationMatchers(const RunAcceptor &acceptor)
|
|||||||
entries.append(entry);
|
entries.append(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storage->reportOutput(entries);
|
storage.reportOutput(entries);
|
||||||
};
|
};
|
||||||
return {{Sync(onSetup), storage}};
|
return {Sync(onSetup)};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void runAcceptor(RunConfiguration *config)
|
static void runAcceptor(RunConfiguration *config)
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace QmlJSTools::Internal;
|
using namespace QmlJSTools::Internal;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(LocatorData::Entry)
|
Q_DECLARE_METATYPE(LocatorData::Entry)
|
||||||
@@ -74,13 +75,9 @@ static void matches(QPromise<void> &promise, const LocatorStorage &storage,
|
|||||||
|
|
||||||
LocatorMatcherTasks QmlJSFunctionsFilter::matchers()
|
LocatorMatcherTasks QmlJSFunctionsFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [entries = m_data->entries()](Async<void> &async) {
|
||||||
|
async.setConcurrentCallData(matches, *LocatorStorage::storage(), entries);
|
||||||
Storage<LocatorStorage> storage;
|
|
||||||
|
|
||||||
const auto onSetup = [storage, entries = m_data->entries()](Async<void> &async) {
|
|
||||||
async.setConcurrentCallData(matches, *storage, entries);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {{AsyncTask<void>(onSetup), storage}};
|
return {AsyncTask<void>(onSetup)};
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace TextEditor::Internal {
|
namespace TextEditor::Internal {
|
||||||
@@ -36,12 +37,11 @@ private:
|
|||||||
|
|
||||||
LocatorMatcherTasks BookmarkFilter::matchers()
|
LocatorMatcherTasks BookmarkFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [this] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<LocatorStorage> storage;
|
storage.reportOutput(match(storage.input()));
|
||||||
|
};
|
||||||
const auto onSetup = [this, storage] { storage->reportOutput(match(storage->input())); };
|
return {Sync(onSetup)};
|
||||||
return {{Sync(onSetup), storage}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorFilterEntries BookmarkFilter::match(const QString &input) const
|
LocatorFilterEntries BookmarkFilter::match(const QString &input) const
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace TextEditor::Internal {
|
namespace TextEditor::Internal {
|
||||||
@@ -29,12 +30,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
LocatorMatcherTasks matchers() final
|
LocatorMatcherTasks matchers() final
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
const auto onSetup = [] {
|
||||||
|
const LocatorStorage &storage = *LocatorStorage::storage();
|
||||||
Storage<LocatorStorage> storage;
|
const QStringList lineAndColumn = storage.input().split(':');
|
||||||
|
|
||||||
const auto onSetup = [storage] {
|
|
||||||
const QStringList lineAndColumn = storage->input().split(':');
|
|
||||||
int sectionCount = lineAndColumn.size();
|
int sectionCount = lineAndColumn.size();
|
||||||
int line = 0;
|
int line = 0;
|
||||||
int column = 0;
|
int column = 0;
|
||||||
@@ -64,10 +62,10 @@ private:
|
|||||||
EditorManager::activateEditor(editor);
|
EditorManager::activateEditor(editor);
|
||||||
return AcceptResult();
|
return AcceptResult();
|
||||||
};
|
};
|
||||||
storage->reportOutput({entry});
|
storage.reportOutput({entry});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return {{Sync(onSetup), storage}};
|
return {Sync(onSetup)};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user