From a2d21502614f18a62d73a27fc211deadfda3cdda Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 24 Nov 2022 17:20:48 +0100 Subject: [PATCH] CppEditor: Re-use Symbol::filePath() Change-Id: Ic958fc0b8916c1afe8b955b140a5cf76e971623d Reviewed-by: Qt CI Bot Reviewed-by: Christian Kandeler Reviewed-by: --- src/plugins/cppeditor/cppfindreferences.cpp | 5 ++--- src/plugins/cppeditor/typehierarchybuilder.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/plugins/cppeditor/cppfindreferences.cpp b/src/plugins/cppeditor/cppfindreferences.cpp index 85092ea9c0c..f2c5a1382fc 100644 --- a/src/plugins/cppeditor/cppfindreferences.cpp +++ b/src/plugins/cppeditor/cppfindreferences.cpp @@ -329,9 +329,8 @@ static void find_helper(QFutureInterface &future, const CPlusPlus::Snapshot snapshot = context.snapshot(); - const Utils::FilePath sourceFile = Utils::FilePath::fromUtf8(symbol->fileName(), - symbol->fileNameLength()); - Utils::FilePaths files{sourceFile}; + const FilePath sourceFile = symbol->filePath(); + FilePaths files{sourceFile}; if (symbol->asClass() || symbol->asForwardClassDeclaration() diff --git a/src/plugins/cppeditor/typehierarchybuilder.cpp b/src/plugins/cppeditor/typehierarchybuilder.cpp index 94400b61a51..5f3aae00e79 100644 --- a/src/plugins/cppeditor/typehierarchybuilder.cpp +++ b/src/plugins/cppeditor/typehierarchybuilder.cpp @@ -6,6 +6,7 @@ #include using namespace CPlusPlus; +using namespace Utils; namespace CppEditor::Internal { namespace { @@ -162,14 +163,13 @@ LookupItem TypeHierarchyBuilder::followTypedef(const LookupContext &context, con return matchingItem; } -static Utils::FilePaths filesDependingOn(const Snapshot &snapshot, - Symbol *symbol) +static FilePaths filesDependingOn(const Snapshot &snapshot, Symbol *symbol) { if (!symbol) - return Utils::FilePaths(); + return {}; - const Utils::FilePath file = Utils::FilePath::fromUtf8(symbol->fileName(), symbol->fileNameLength()); - return Utils::FilePaths { file } + snapshot.filesDependingOn(file); + const FilePath file = symbol->filePath(); + return FilePaths{file} + snapshot.filesDependingOn(file); } void TypeHierarchyBuilder::buildDerived(QFutureInterfaceBase &futureInterface, @@ -187,12 +187,12 @@ void TypeHierarchyBuilder::buildDerived(QFutureInterfaceBase &futureInterface, const QString &symbolName = _overview.prettyName(LookupContext::fullyQualifiedName(symbol)); DerivedHierarchyVisitor visitor(symbolName, cache); - const Utils::FilePaths &dependingFiles = filesDependingOn(snapshot, symbol); + const FilePaths dependingFiles = filesDependingOn(snapshot, symbol); if (depth == 0) futureInterface.setProgressRange(0, dependingFiles.size()); int i = -1; - for (const Utils::FilePath &fileName : dependingFiles) { + for (const FilePath &fileName : dependingFiles) { if (futureInterface.isCanceled()) return; if (depth == 0)