forked from qt-creator/qt-creator
ILocatorFilter: Remove LocatorMatcherTask typedef
Use ExecutableItem directly instead. Add some static specifiers. Change-Id: Ie5ef467d428f8bee7fc800241357be38c85faa15 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -172,7 +172,7 @@ static void filterCurrentResults(QPromise<void> &promise, const LocatorStorage &
|
|||||||
[](const Entry &entry) { return entry.entry; }));
|
[](const Entry &entry) { return entry.entry; }));
|
||||||
}
|
}
|
||||||
|
|
||||||
static LocatorMatcherTask currentDocumentMatcher()
|
static ExecutableItem currentDocumentMatcher()
|
||||||
{
|
{
|
||||||
Storage<CurrentDocumentSymbolsData> resultStorage;
|
Storage<CurrentDocumentSymbolsData> resultStorage;
|
||||||
|
|
||||||
|
@@ -1365,7 +1365,7 @@ static void filter(QPromise<LocatorFileCachePrivate> &promise, const LocatorStor
|
|||||||
When this cache started a new search in meantime, the cache was invalidated or even deleted,
|
When this cache started a new search in meantime, the cache was invalidated or even deleted,
|
||||||
the update of the cache after a successful run of the task is ignored.
|
the update of the cache after a successful run of the task is ignored.
|
||||||
*/
|
*/
|
||||||
LocatorMatcherTask LocatorFileCache::matcher() const
|
ExecutableItem LocatorFileCache::matcher() const
|
||||||
{
|
{
|
||||||
std::weak_ptr<LocatorFileCachePrivate> weak = d;
|
std::weak_ptr<LocatorFileCachePrivate> weak = d;
|
||||||
|
|
||||||
|
@@ -136,8 +136,7 @@ private:
|
|||||||
std::shared_ptr<LocatorStoragePrivate> d;
|
std::shared_ptr<LocatorStoragePrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
using LocatorMatcherTask = Tasking::GroupItem;
|
using LocatorMatcherTasks = QList<Tasking::ExecutableItem>;
|
||||||
using LocatorMatcherTasks = QList<LocatorMatcherTask>;
|
|
||||||
using LocatorMatcherTaskCreator = std::function<LocatorMatcherTasks()>;
|
using LocatorMatcherTaskCreator = std::function<LocatorMatcherTasks()>;
|
||||||
class LocatorMatcherPrivate;
|
class LocatorMatcherPrivate;
|
||||||
|
|
||||||
@@ -307,7 +306,7 @@ public:
|
|||||||
std::optional<Utils::FilePaths> filePaths() const;
|
std::optional<Utils::FilePaths> filePaths() const;
|
||||||
|
|
||||||
static FilePathsGenerator filePathsGenerator(const Utils::FilePaths &filePaths);
|
static FilePathsGenerator filePathsGenerator(const Utils::FilePaths &filePaths);
|
||||||
LocatorMatcherTask matcher() const;
|
Tasking::ExecutableItem matcher() const;
|
||||||
|
|
||||||
using MatchedEntries = std::array<LocatorFilterEntries, int(ILocatorFilter::MatchLevel::Count)>;
|
using MatchedEntries = std::array<LocatorFilterEntries, int(ILocatorFilter::MatchLevel::Count)>;
|
||||||
static Utils::FilePaths processFilePaths(const QFuture<void> &future,
|
static Utils::FilePaths processFilePaths(const QFuture<void> &future,
|
||||||
|
@@ -26,7 +26,7 @@ namespace CppEditor {
|
|||||||
|
|
||||||
using EntryFromIndex = std::function<LocatorFilterEntry(const IndexItem::Ptr &)>;
|
using EntryFromIndex = std::function<LocatorFilterEntry(const IndexItem::Ptr &)>;
|
||||||
|
|
||||||
void matchesFor(QPromise<void> &promise, const LocatorStorage &storage,
|
static void matchesFor(QPromise<void> &promise, const LocatorStorage &storage,
|
||||||
IndexItem::ItemType wantedType, const EntryFromIndex &converter)
|
IndexItem::ItemType wantedType, const EntryFromIndex &converter)
|
||||||
{
|
{
|
||||||
const QString input = storage.input();
|
const QString input = storage.input();
|
||||||
@@ -100,7 +100,7 @@ void matchesFor(QPromise<void> &promise, const LocatorStorage &storage,
|
|||||||
LocatorFilterEntries()));
|
LocatorFilterEntries()));
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask locatorMatcher(IndexItem::ItemType type, const EntryFromIndex &converter)
|
static ExecutableItem locatorMatcher(IndexItem::ItemType type, const EntryFromIndex &converter)
|
||||||
{
|
{
|
||||||
const auto onSetup = [type, converter](Async<void> &async) {
|
const auto onSetup = [type, converter](Async<void> &async) {
|
||||||
async.setConcurrentCallData(matchesFor, *LocatorStorage::storage(), type, converter);
|
async.setConcurrentCallData(matchesFor, *LocatorStorage::storage(), type, converter);
|
||||||
@@ -108,7 +108,7 @@ LocatorMatcherTask locatorMatcher(IndexItem::ItemType type, const EntryFromIndex
|
|||||||
return AsyncTask<void>(onSetup);
|
return AsyncTask<void>(onSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask allSymbolsMatcher()
|
static ExecutableItem allSymbolsMatcher()
|
||||||
{
|
{
|
||||||
const auto converter = [](const IndexItem::Ptr &info) {
|
const auto converter = [](const IndexItem::Ptr &info) {
|
||||||
LocatorFilterEntry filterEntry;
|
LocatorFilterEntry filterEntry;
|
||||||
@@ -126,7 +126,7 @@ LocatorMatcherTask allSymbolsMatcher()
|
|||||||
return locatorMatcher(IndexItem::All, converter);
|
return locatorMatcher(IndexItem::All, converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask classMatcher()
|
static ExecutableItem classMatcher()
|
||||||
{
|
{
|
||||||
const auto converter = [](const IndexItem::Ptr &info) {
|
const auto converter = [](const IndexItem::Ptr &info) {
|
||||||
LocatorFilterEntry filterEntry;
|
LocatorFilterEntry filterEntry;
|
||||||
@@ -142,7 +142,7 @@ LocatorMatcherTask classMatcher()
|
|||||||
return locatorMatcher(IndexItem::Class, converter);
|
return locatorMatcher(IndexItem::Class, converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask functionMatcher()
|
static ExecutableItem functionMatcher()
|
||||||
{
|
{
|
||||||
const auto converter = [](const IndexItem::Ptr &info) {
|
const auto converter = [](const IndexItem::Ptr &info) {
|
||||||
QString name = info->symbolName();
|
QString name = info->symbolName();
|
||||||
@@ -163,7 +163,7 @@ LocatorMatcherTask functionMatcher()
|
|||||||
return locatorMatcher(IndexItem::Function, converter);
|
return locatorMatcher(IndexItem::Function, converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<IndexItem::Ptr> itemsOfCurrentDocument(const FilePath ¤tFileName)
|
static QList<IndexItem::Ptr> itemsOfCurrentDocument(const FilePath ¤tFileName)
|
||||||
{
|
{
|
||||||
if (currentFileName.isEmpty())
|
if (currentFileName.isEmpty())
|
||||||
return {};
|
return {};
|
||||||
@@ -185,7 +185,7 @@ QList<IndexItem::Ptr> itemsOfCurrentDocument(const FilePath ¤tFileName)
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorFilterEntry::HighlightInfo highlightInfo(const QRegularExpressionMatch &match,
|
static LocatorFilterEntry::HighlightInfo highlightInfo(const QRegularExpressionMatch &match,
|
||||||
LocatorFilterEntry::HighlightInfo::DataType dataType)
|
LocatorFilterEntry::HighlightInfo::DataType dataType)
|
||||||
{
|
{
|
||||||
const FuzzyMatcher::HighlightingPositions positions =
|
const FuzzyMatcher::HighlightingPositions positions =
|
||||||
@@ -194,7 +194,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<void> &promise, const LocatorStorage &storage,
|
static void matchesForCurrentDocument(QPromise<void> &promise, const LocatorStorage &storage,
|
||||||
const FilePath ¤tFileName)
|
const FilePath ¤tFileName)
|
||||||
{
|
{
|
||||||
const QString input = storage.input();
|
const QString input = storage.input();
|
||||||
@@ -287,13 +287,13 @@ void matchesForCurrentDocument(QPromise<void> &promise, const LocatorStorage &st
|
|||||||
[](const Entry &entry) { return entry.entry; }));
|
[](const Entry &entry) { return entry.entry; }));
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath currentFileName()
|
static FilePath currentFileName()
|
||||||
{
|
{
|
||||||
IEditor *currentEditor = EditorManager::currentEditor();
|
IEditor *currentEditor = EditorManager::currentEditor();
|
||||||
return currentEditor ? currentEditor->document()->filePath() : FilePath();
|
return currentEditor ? currentEditor->document()->filePath() : FilePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask currentDocumentMatcher()
|
static ExecutableItem currentDocumentMatcher()
|
||||||
{
|
{
|
||||||
const auto onSetup = [](Async<void> &async) {
|
const auto onSetup = [](Async<void> &async) {
|
||||||
async.setConcurrentCallData(matchesForCurrentDocument, *LocatorStorage::storage(), currentFileName());
|
async.setConcurrentCallData(matchesForCurrentDocument, *LocatorStorage::storage(), currentFileName());
|
||||||
@@ -301,7 +301,7 @@ LocatorMatcherTask currentDocumentMatcher()
|
|||||||
return AsyncTask<void>(onSetup);
|
return AsyncTask<void>(onSetup);
|
||||||
}
|
}
|
||||||
|
|
||||||
using MatcherCreator = std::function<Core::LocatorMatcherTask()>;
|
using MatcherCreator = std::function<ExecutableItem()>;
|
||||||
|
|
||||||
static MatcherCreator creatorForType(MatcherType type)
|
static MatcherCreator creatorForType(MatcherType type)
|
||||||
{
|
{
|
||||||
|
@@ -28,7 +28,7 @@ QTC_DECLARE_MYTESTDATADIR("../../../tests/cpplocators/")
|
|||||||
class CppLocatorFilterTestCase : public CppEditor::Tests::TestCase
|
class CppLocatorFilterTestCase : public CppEditor::Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppLocatorFilterTestCase(const QList<LocatorMatcherTask> &matchers,
|
CppLocatorFilterTestCase(const LocatorMatcherTasks &matchers,
|
||||||
const QString &fileName,
|
const QString &fileName,
|
||||||
const QString &searchText,
|
const QString &searchText,
|
||||||
const ResultDataList &expectedResults)
|
const ResultDataList &expectedResults)
|
||||||
@@ -54,7 +54,7 @@ class CppCurrentDocumentFilterTestCase : public CppEditor::Tests::TestCase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppCurrentDocumentFilterTestCase(const FilePath &filePath,
|
CppCurrentDocumentFilterTestCase(const FilePath &filePath,
|
||||||
const QList<LocatorMatcherTask> &matchers,
|
const LocatorMatcherTasks &matchers,
|
||||||
const ResultDataList &expectedResults,
|
const ResultDataList &expectedResults,
|
||||||
const QString &searchText = QString())
|
const QString &searchText = QString())
|
||||||
{
|
{
|
||||||
|
@@ -20,7 +20,7 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace LanguageClient {
|
namespace LanguageClient {
|
||||||
|
|
||||||
void filterResults(QPromise<void> &promise, const LocatorStorage &storage, Client *client,
|
static void filterResults(QPromise<void> &promise, const LocatorStorage &storage, 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) {
|
||||||
@@ -42,7 +42,7 @@ void filterResults(QPromise<void> &promise, const LocatorStorage &storage, Clien
|
|||||||
storage.reportOutput(Utils::transform(filteredResults, generateEntry));
|
storage.reportOutput(Utils::transform(filteredResults, generateEntry));
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount,
|
static ExecutableItem locatorMatcher(Client *client, int maxResultCount,
|
||||||
const QList<SymbolKind> &filter)
|
const QList<SymbolKind> &filter)
|
||||||
{
|
{
|
||||||
Storage<QList<SymbolInformation>> resultStorage;
|
Storage<QList<SymbolInformation>> resultStorage;
|
||||||
@@ -79,17 +79,17 @@ LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount,
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask allSymbolsMatcher(Client *client, int maxResultCount)
|
static ExecutableItem allSymbolsMatcher(Client *client, int maxResultCount)
|
||||||
{
|
{
|
||||||
return locatorMatcher(client, maxResultCount, {});
|
return locatorMatcher(client, maxResultCount, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask classMatcher(Client *client, int maxResultCount)
|
static ExecutableItem classMatcher(Client *client, int maxResultCount)
|
||||||
{
|
{
|
||||||
return locatorMatcher(client, maxResultCount, {SymbolKind::Class, SymbolKind::Struct});
|
return locatorMatcher(client, maxResultCount, {SymbolKind::Class, SymbolKind::Struct});
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask functionMatcher(Client *client, int maxResultCount)
|
static ExecutableItem functionMatcher(Client *client, int maxResultCount)
|
||||||
{
|
{
|
||||||
return locatorMatcher(client, maxResultCount,
|
return locatorMatcher(client, maxResultCount,
|
||||||
{SymbolKind::Method, SymbolKind::Function, SymbolKind::Constructor});
|
{SymbolKind::Method, SymbolKind::Function, SymbolKind::Constructor});
|
||||||
@@ -111,7 +111,7 @@ static void filterCurrentResults(QPromise<void> &promise, const LocatorStorage &
|
|||||||
docSymbolModifier));
|
docSymbolModifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
LocatorMatcherTask currentDocumentMatcher()
|
static ExecutableItem currentDocumentMatcher()
|
||||||
{
|
{
|
||||||
Storage<CurrentDocumentSymbolsData> resultStorage;
|
Storage<CurrentDocumentSymbolsData> resultStorage;
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ LocatorMatcherTask currentDocumentMatcher()
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
using MatcherCreator = std::function<Core::LocatorMatcherTask(Client *, int)>;
|
using MatcherCreator = std::function<ExecutableItem(Client *, int)>;
|
||||||
|
|
||||||
static MatcherCreator creatorForType(MatcherType type)
|
static MatcherCreator creatorForType(MatcherType type)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user