forked from qt-creator/qt-creator
CppEditor: FilePath-ify SymbolSearcher
Change-Id: Iff29c4c6287d12a361174264332e8734e914050a Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -30,10 +30,10 @@ namespace CppEditor {
|
||||
static Q_LOGGING_CATEGORY(indexerLog, "qtc.cppeditor.indexer", QtWarningMsg)
|
||||
|
||||
SymbolSearcher::SymbolSearcher(const SymbolSearcher::Parameters ¶meters,
|
||||
const QSet<QString> &fileNames)
|
||||
const QSet<FilePath> &filePaths)
|
||||
: m_snapshot(CppModelManager::snapshot())
|
||||
, m_parameters(parameters)
|
||||
, m_fileNames(fileNames)
|
||||
, m_filePaths(filePaths)
|
||||
{}
|
||||
|
||||
namespace {
|
||||
@@ -261,7 +261,7 @@ void SymbolSearcher::runSearch(QPromise<SearchResultItem> &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()) {
|
||||
|
@@ -43,13 +43,15 @@ public:
|
||||
SearchScope scope;
|
||||
};
|
||||
|
||||
SymbolSearcher(const SymbolSearcher::Parameters ¶meters, const QSet<QString> &fileNames);
|
||||
SymbolSearcher(const SymbolSearcher::Parameters ¶meters,
|
||||
const QSet<Utils::FilePath> &filePaths);
|
||||
|
||||
void runSearch(QPromise<Utils::SearchResultItem> &promise);
|
||||
|
||||
private:
|
||||
const CPlusPlus::Snapshot m_snapshot;
|
||||
const Parameters m_parameters;
|
||||
const QSet<QString> m_fileNames;
|
||||
const QSet<Utils::FilePath> m_filePaths;
|
||||
};
|
||||
|
||||
class CPPEDITOR_EXPORT CppIndexingSupport
|
||||
|
@@ -14,6 +14,8 @@
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace {
|
||||
|
||||
QTC_DECLARE_MYTESTDATADIR("../../../tests/cppsymbolsearcher/")
|
||||
@@ -76,7 +78,7 @@ public:
|
||||
QVERIFY(parseFiles(testFile));
|
||||
|
||||
const QScopedPointer<SymbolSearcher> symbolSearcher(
|
||||
new SymbolSearcher(searchParameters, QSet<QString>{testFile}));
|
||||
new SymbolSearcher(searchParameters, QSet<FilePath>{FilePath::fromString(testFile)}));
|
||||
QFuture<Utils::SearchResultItem> search
|
||||
= Utils::asyncRun(&SymbolSearcher::runSearch, symbolSearcher.data());
|
||||
search.waitForFinished();
|
||||
|
@@ -107,10 +107,10 @@ void SymbolsFindFilter::findAll(const QString &txt, FindFlags findFlags)
|
||||
void SymbolsFindFilter::startSearch(SearchResult *search)
|
||||
{
|
||||
SymbolSearcher::Parameters parameters = search->userData().value<SymbolSearcher::Parameters>();
|
||||
QSet<QString> projectFileNames;
|
||||
QSet<FilePath> projectFileNames;
|
||||
if (parameters.scope == SymbolSearcher::SearchProjectsOnly) {
|
||||
for (ProjectExplorer::Project *project : ProjectExplorer::ProjectManager::projects())
|
||||
projectFileNames += Utils::transform<QSet>(project->files(ProjectExplorer::Project::AllFiles), &Utils::FilePath::toString);
|
||||
projectFileNames += Utils::toSet(project->files(ProjectExplorer::Project::AllFiles));
|
||||
}
|
||||
|
||||
auto watcher = new QFutureWatcher<SearchResultItem>;
|
||||
|
Reference in New Issue
Block a user