From 0dbd951654d044de483501377cfa48083038c9b7 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 6 Nov 2023 16:03:49 +0100 Subject: [PATCH] CppEditor: FilePath-ify SymbolSearcher Change-Id: Iff29c4c6287d12a361174264332e8734e914050a Reviewed-by: Reviewed-by: Christian Kandeler --- src/plugins/cppeditor/cppindexingsupport.cpp | 6 +++--- src/plugins/cppeditor/cppindexingsupport.h | 6 ++++-- src/plugins/cppeditor/symbolsearcher_test.cpp | 4 +++- src/plugins/cppeditor/symbolsfindfilter.cpp | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/plugins/cppeditor/cppindexingsupport.cpp b/src/plugins/cppeditor/cppindexingsupport.cpp index ada400556e5..21a5da4109f 100644 --- a/src/plugins/cppeditor/cppindexingsupport.cpp +++ b/src/plugins/cppeditor/cppindexingsupport.cpp @@ -30,10 +30,10 @@ namespace CppEditor { static Q_LOGGING_CATEGORY(indexerLog, "qtc.cppeditor.indexer", QtWarningMsg) SymbolSearcher::SymbolSearcher(const SymbolSearcher::Parameters ¶meters, - const QSet &fileNames) + const QSet &filePaths) : m_snapshot(CppModelManager::snapshot()) , m_parameters(parameters) - , m_fileNames(fileNames) + , m_filePaths(filePaths) {} namespace { @@ -261,7 +261,7 @@ void SymbolSearcher::runSearch(QPromise &promise) promise.suspendIfRequested(); if (promise.isCanceled()) break; - if (m_fileNames.isEmpty() || m_fileNames.contains(it.value()->filePath().path())) { + if (m_filePaths.isEmpty() || m_filePaths.contains(it.value()->filePath())) { SearchResultItems resultItems; auto filter = [&](const IndexItem::Ptr &info) -> IndexItem::VisitorResult { if (matcher.match(info->symbolName()).hasMatch()) { diff --git a/src/plugins/cppeditor/cppindexingsupport.h b/src/plugins/cppeditor/cppindexingsupport.h index 9995ca631cd..c04eb8ba76f 100644 --- a/src/plugins/cppeditor/cppindexingsupport.h +++ b/src/plugins/cppeditor/cppindexingsupport.h @@ -43,13 +43,15 @@ public: SearchScope scope; }; - SymbolSearcher(const SymbolSearcher::Parameters ¶meters, const QSet &fileNames); + SymbolSearcher(const SymbolSearcher::Parameters ¶meters, + const QSet &filePaths); + void runSearch(QPromise &promise); private: const CPlusPlus::Snapshot m_snapshot; const Parameters m_parameters; - const QSet m_fileNames; + const QSet m_filePaths; }; class CPPEDITOR_EXPORT CppIndexingSupport diff --git a/src/plugins/cppeditor/symbolsearcher_test.cpp b/src/plugins/cppeditor/symbolsearcher_test.cpp index 688df3d924f..a429dd186f1 100644 --- a/src/plugins/cppeditor/symbolsearcher_test.cpp +++ b/src/plugins/cppeditor/symbolsearcher_test.cpp @@ -14,6 +14,8 @@ #include +using namespace Utils; + namespace { QTC_DECLARE_MYTESTDATADIR("../../../tests/cppsymbolsearcher/") @@ -76,7 +78,7 @@ public: QVERIFY(parseFiles(testFile)); const QScopedPointer symbolSearcher( - new SymbolSearcher(searchParameters, QSet{testFile})); + new SymbolSearcher(searchParameters, QSet{FilePath::fromString(testFile)})); QFuture search = Utils::asyncRun(&SymbolSearcher::runSearch, symbolSearcher.data()); search.waitForFinished(); diff --git a/src/plugins/cppeditor/symbolsfindfilter.cpp b/src/plugins/cppeditor/symbolsfindfilter.cpp index bd05107c646..f53fd34c4d1 100644 --- a/src/plugins/cppeditor/symbolsfindfilter.cpp +++ b/src/plugins/cppeditor/symbolsfindfilter.cpp @@ -107,10 +107,10 @@ void SymbolsFindFilter::findAll(const QString &txt, FindFlags findFlags) void SymbolsFindFilter::startSearch(SearchResult *search) { SymbolSearcher::Parameters parameters = search->userData().value(); - QSet projectFileNames; + QSet projectFileNames; if (parameters.scope == SymbolSearcher::SearchProjectsOnly) { for (ProjectExplorer::Project *project : ProjectExplorer::ProjectManager::projects()) - projectFileNames += Utils::transform(project->files(ProjectExplorer::Project::AllFiles), &Utils::FilePath::toString); + projectFileNames += Utils::toSet(project->files(ProjectExplorer::Project::AllFiles)); } auto watcher = new QFutureWatcher;