diff options
author | hjk <hjk@qt.io> | 2022-11-21 16:48:50 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2022-11-22 15:30:00 +0000 |
commit | fa1adf4d4001207902a5572b39da4f1cbc8752f1 (patch) | |
tree | ff9cbc1c951ab862f03902d38fc4495c3e1a3ae9 /src | |
parent | 822e2a224a283581b38948d4626f873c6b38c044 (diff) |
CPlusPlus: Proliferate FilePath use
The starts with CppDocument::filePath(), plus a bit of the fallout
This is one patch of potentially many. It is hard to draw the
line where to stop this kind of chunk, this here converts a few
additional functions for which including it in the patch looked
like less churn than without.
Converting is mostly fromString/toString, with a few exceptions
for "already seem" like caches, that use cheaper "path()" to
avoid likely performance regressions (on Windows FilePath
comparison is currently case-insenstive, and more expensive).
There should be no difference for local operation with this patch.
Change-Id: I7b35f98a0a6f0bfed4ea0f8f987faf586f7a8f2b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
66 files changed, 340 insertions, 308 deletions
diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 12ce8ea0cd3..6362bf06593 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -205,7 +205,7 @@ public: const QString fileName = QString::fromUtf8(fileId->chars(), fileId->size()); - if (fileName != doc->fileName()) + if (fileName != doc->filePath().pathView()) return; const QString message = QString::vasprintf(format, ap); @@ -220,7 +220,7 @@ public: } #endif // DO_NOT_DUMP_ALL_PARSER_ERRORS - Document::DiagnosticMessage m(convertLevel(level), doc->fileName(), + Document::DiagnosticMessage m(convertLevel(level), doc->filePath(), line, column, message); messages->append(m); } @@ -244,7 +244,7 @@ private: Document::Document(const QString &fileName) - : _fileName(QDir::cleanPath(fileName)), + : _filePath(Utils::FilePath::fromUserInput(QDir::cleanPath(fileName))), _globalNamespace(nullptr), _revision(0), _editorRevision(0), @@ -652,7 +652,7 @@ bool Document::DiagnosticMessage::operator==(const Document::DiagnosticMessage & _column == other._column && _length == other._length && _level == other._level && - _fileName == other._fileName && + _filePath == other._filePath && _text == other._text; } @@ -697,7 +697,7 @@ bool Snapshot::contains(const Utils::FilePath &fileName) const void Snapshot::insert(Document::Ptr doc) { if (doc) { - _documents.insert(Utils::FilePath::fromString(doc->fileName()), doc); + _documents.insert(doc->filePath(), doc); m_deps.files.clear(); // Will trigger re-build when accessed. } } @@ -848,7 +848,7 @@ Snapshot Snapshot::simplified(Document::Ptr doc) const if (doc) { snapshot.insert(doc); - const QSet<QString> fileNames = allIncludesForDocument(doc->fileName()); + const QSet<QString> fileNames = allIncludesForDocument(doc->filePath().toString()); for (const QString &fileName : fileNames) if (Document::Ptr inc = document(fileName)) snapshot.insert(inc); diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h index c3ee363f261..fd98098763f 100644 --- a/src/libs/cplusplus/CppDocument.h +++ b/src/libs/cplusplus/CppDocument.h @@ -49,7 +49,7 @@ public: const QDateTime &lastModified() const { return _lastModified; } void setLastModified(const QDateTime &lastModified); - const QString &fileName() const { return _fileName; } + const Utils::FilePath &filePath() const { return _filePath; } void appendMacro(const Macro ¯o); void addMacroUse(const Macro ¯o, @@ -125,13 +125,13 @@ public: }; public: - DiagnosticMessage(int level, const QString &fileName, + DiagnosticMessage(int level, const Utils::FilePath &filePath, int line, int column, const QString &text, int length = 0) : _level(level), _line(line), - _fileName(fileName), + _filePath(filePath), _column(column), _length(length), _text(text) @@ -149,8 +149,8 @@ public: bool isFatal() const { return _level == Fatal; } - const QString &fileName() const - { return _fileName; } + const Utils::FilePath &filePath() const + { return _filePath; } int line() const { return _line; } @@ -170,7 +170,7 @@ public: private: int _level; int _line; - QString _fileName; + Utils::FilePath _filePath; int _column; int _length; QString _text; @@ -334,7 +334,7 @@ public: { return static_cast<CheckMode>(_checkMode); } private: - QString _fileName; + Utils::FilePath _filePath; Control *_control; TranslationUnit *_translationUnit; Namespace *_globalNamespace; diff --git a/src/libs/cplusplus/FastPreprocessor.cpp b/src/libs/cplusplus/FastPreprocessor.cpp index fb89ed26bf3..607dd55364b 100644 --- a/src/libs/cplusplus/FastPreprocessor.cpp +++ b/src/libs/cplusplus/FastPreprocessor.cpp @@ -8,6 +8,7 @@ #include <QDir> +using namespace Utils; using namespace CPlusPlus; FastPreprocessor::FastPreprocessor(const Snapshot &snapshot) @@ -23,12 +24,12 @@ QByteArray FastPreprocessor::run(Document::Ptr newDoc, std::swap(newDoc, _currentDoc); _addIncludesToCurrentDoc = _currentDoc->resolvedIncludes().isEmpty() && _currentDoc->unresolvedIncludes().isEmpty(); - const QString fileName = _currentDoc->fileName(); + const FilePath filePath = _currentDoc->filePath(); _preproc.setExpandFunctionlikeMacros(false); _preproc.setKeepComments(true); - if (Document::Ptr doc = _snapshot.document(fileName)) { - _merged.insert(fileName); + if (Document::Ptr doc = _snapshot.document(filePath)) { + _merged.insert(filePath.toString()); for (Snapshot::const_iterator i = _snapshot.begin(), ei = _snapshot.end(); i != ei; ++i) { if (isInjectedFile(i.key().toString())) @@ -43,7 +44,7 @@ QByteArray FastPreprocessor::run(Document::Ptr newDoc, _env.addMacros(_currentDoc->definedMacros()); } - const QByteArray preprocessed = _preproc.run(fileName, source); + const QByteArray preprocessed = _preproc.run(filePath, source); // qDebug("FastPreprocessor::run for %s produced [[%s]]", fileName.toUtf8().constData(), preprocessed.constData()); std::swap(newDoc, _currentDoc); return preprocessed; diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp index 6e1731ca118..4928c4f7712 100644 --- a/src/libs/cplusplus/FindUsages.cpp +++ b/src/libs/cplusplus/FindUsages.cpp @@ -118,7 +118,7 @@ void FindUsages::reportResult(unsigned tokenIndex, const QList<LookupItem> &cand lineText = matchingLine(tk); const int len = tk.utf16chars(); - const Usage u(Utils::FilePath::fromString(_doc->fileName()), lineText, + const Usage u(_doc->filePath(), lineText, getContainingFunction(line, col), getTags(line, col, tokenIndex), line, col - 1, len); _usages.append(u); diff --git a/src/libs/cplusplus/SnapshotSymbolVisitor.cpp b/src/libs/cplusplus/SnapshotSymbolVisitor.cpp index 0c459aa373d..4692c25108b 100644 --- a/src/libs/cplusplus/SnapshotSymbolVisitor.cpp +++ b/src/libs/cplusplus/SnapshotSymbolVisitor.cpp @@ -20,8 +20,8 @@ void SnapshotSymbolVisitor::accept(Document::Ptr doc) void SnapshotSymbolVisitor::accept(Document::Ptr doc, QSet<QString> *processed) { - if (doc && doc->globalNamespace() && ! processed->contains(doc->fileName())) { - processed->insert(doc->fileName()); + if (doc && doc->globalNamespace() && ! processed->contains(doc->filePath().path())) { + processed->insert(doc->filePath().path()); const QList<Document::Include> includes = doc->resolvedIncludes(); for (const Document::Include &i : includes) { diff --git a/src/libs/cplusplus/TypeOfExpression.cpp b/src/libs/cplusplus/TypeOfExpression.cpp index 88efe41695d..2453ad829ff 100644 --- a/src/libs/cplusplus/TypeOfExpression.cpp +++ b/src/libs/cplusplus/TypeOfExpression.cpp @@ -13,7 +13,7 @@ #include <QSet> -using namespace CPlusPlus; +namespace CPlusPlus { TypeOfExpression::TypeOfExpression(): m_ast(nullptr), @@ -132,8 +132,8 @@ ExpressionAST *TypeOfExpression::expressionAST() const void TypeOfExpression::processEnvironment(Document::Ptr doc, Environment *env, QSet<QString> *processed) const { - if (doc && ! processed->contains(doc->fileName())) { - processed->insert(doc->fileName()); + if (doc && ! processed->contains(doc->filePath().path())) { + processed->insert(doc->filePath().path()); const QList<Document::Include> includes = doc->resolvedIncludes(); for (const Document::Include &incl : includes) @@ -158,11 +158,9 @@ QByteArray TypeOfExpression::preprocessedExpression(const QByteArray &utf8code) } Preprocessor preproc(nullptr, m_environment.data()); - return preproc.run(QLatin1String("<expression>"), utf8code); + return preproc.run(Utils::FilePath::fromParts({}, {}, u"<expression>"), utf8code); } -namespace CPlusPlus { - ExpressionAST *extractExpressionAST(Document::Ptr doc) { if (! doc->translationUnit()->ast()) diff --git a/src/libs/cplusplus/pp-engine.cpp b/src/libs/cplusplus/pp-engine.cpp index 836e2ad05b7..58fa33b0a9e 100644 --- a/src/libs/cplusplus/pp-engine.cpp +++ b/src/libs/cplusplus/pp-engine.cpp @@ -31,6 +31,7 @@ #include <cplusplus/cppassert.h> #include <utils/executeondestruction.h> +#include <utils/filepath.h> #include <utils/scopedswap.h> #include <QDebug> @@ -235,7 +236,6 @@ struct Value }; } // namespace Internal -} // namespace CPlusPlus using namespace CPlusPlus; using namespace CPlusPlus::Internal; @@ -251,7 +251,7 @@ Macro *macroDefinition(const ByteArrayRef &name, unsigned bytesOffset, unsigned utf16charsOffset, unsigned line, - Environment *env, + CPlusPlus::Environment *env, Client *client) { Macro *m = env->resolve(name); @@ -320,7 +320,7 @@ class ExpressionEvaluator void operator = (const ExpressionEvaluator &other); public: - ExpressionEvaluator(Client *client, Environment *env) + ExpressionEvaluator(Client *client, CPlusPlus::Environment *env) : client(client), env(env), _lex(nullptr) { } @@ -726,6 +726,14 @@ Preprocessor::Preprocessor(Client *client, Environment *env) { } +QByteArray Preprocessor::run(const Utils::FilePath &filePath, + const QByteArray &source, + bool noLines, + bool markGeneratedTokens) +{ + return run(filePath.toString(), source, noLines, markGeneratedTokens); +} + QByteArray Preprocessor::run(const QString &fileName, const QByteArray &source, bool noLines, @@ -2158,3 +2166,5 @@ void Preprocessor::maybeStartOutputLine() if (*ch == '\\') buffer.append('\n'); } + +} // namespace CPlusPlus diff --git a/src/libs/cplusplus/pp-engine.h b/src/libs/cplusplus/pp-engine.h index 4cbda7162c3..f5c2474ffc7 100644 --- a/src/libs/cplusplus/pp-engine.h +++ b/src/libs/cplusplus/pp-engine.h @@ -36,6 +36,8 @@ #include <functional> +namespace Utils { class FilePath; } + namespace CPlusPlus { class Environment; @@ -57,6 +59,8 @@ public: public: Preprocessor(Client *client, Environment *env); + QByteArray run(const Utils::FilePath &filePath, const QByteArray &source, + bool noLines = false, bool markGeneratedTokens = true); QByteArray run(const QString &filename, const QByteArray &source, bool noLines = false, bool markGeneratedTokens = true); diff --git a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp index 2e07d91f22c..427a73ef3f8 100644 --- a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp +++ b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp @@ -248,7 +248,7 @@ protected: translationUnit()->getTokenStartPosition(nameExp->firstToken(), &line, &column); _messages += Document::DiagnosticMessage( Document::DiagnosticMessage::Warning, - _doc->fileName(), + _doc->filePath(), line, column, QmlJS::FindExportedCppTypes::tr( "The type will only be available in the QML editors when the type name is a string literal.")); @@ -309,7 +309,7 @@ protected: translationUnit()->getTokenStartPosition(ast->firstToken(), &line, &column); _messages += Document::DiagnosticMessage( Document::DiagnosticMessage::Warning, - _doc->fileName(), + _doc->filePath(), line, column, QmlJS::FindExportedCppTypes::tr( "The module URI cannot be determined by static analysis. The type will not be available\n" @@ -491,7 +491,7 @@ protected: translationUnit()->getTokenStartPosition(ast->expression_list->value->firstToken(), &line, &column); _messages += Document::DiagnosticMessage( Document::DiagnosticMessage::Warning, - _doc->fileName(), + _doc->filePath(), line, column, QmlJS::FindExportedCppTypes::tr( "must be a string literal to be available in the QML editor")); @@ -840,7 +840,7 @@ QStringList FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &doc FindExportsVisitor finder(document); finder(); static const QString kindKey = QLatin1String("QmlJSTools.ExportedQmlTypesDiagnostic"); - CppModelManagerBase::trySetExtraDiagnostics(document->fileName(), kindKey, + CppModelManagerBase::trySetExtraDiagnostics(document->filePath().toString(), kindKey, finder.messages()); // if nothing was found, done @@ -852,7 +852,8 @@ QStringList FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &doc // context properties need lookup inside function scope, and thus require a full check CPlusPlus::Document::Ptr localDoc = document; if (document->checkMode() != CPlusPlus::Document::FullCheck && !contextPropertyDescriptions.isEmpty()) { - localDoc = m_snapshot.documentFromSource(document->utf8Source(), document->fileName()); + localDoc = m_snapshot.documentFromSource(document->utf8Source(), + document->filePath().toString()); localDoc->check(); } diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index 70eebf6faf6..71bd55119be 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -1350,10 +1350,10 @@ void ModelManagerInterface::maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document void ModelManagerInterface::queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan) { - QPair<CPlusPlus::Document::Ptr, bool> prev = m_queuedCppDocuments.value(doc->fileName()); + QPair<CPlusPlus::Document::Ptr, bool> prev = m_queuedCppDocuments.value(doc->filePath().path()); if (prev.first && prev.second) prev.first->releaseSourceAndAST(); - m_queuedCppDocuments.insert(doc->fileName(), {doc, scan}); + m_queuedCppDocuments.insert(doc->filePath().path(), {doc, scan}); m_updateCppQmlTypesTimer->start(); } @@ -1439,13 +1439,13 @@ void ModelManagerInterface::updateCppQmlTypes( CPlusPlus::Document::Ptr doc = pair.first; const bool scan = pair.second; - const QString fileName = doc->fileName(); + const FilePath filePath = doc->filePath(); if (!scan) { - hasNewInfo = newData.remove(fileName) || hasNewInfo; - const auto savedDocs = newDeclarations.value(fileName); + hasNewInfo = newData.remove(filePath.path()) || hasNewInfo; + const auto savedDocs = newDeclarations.value(filePath.path()); for (const CPlusPlus::Document::Ptr &savedDoc : savedDocs) { finder(savedDoc); - hasNewInfo = rescanExports(savedDoc->fileName(), finder, newData) || hasNewInfo; + hasNewInfo = rescanExports(savedDoc->filePath().path(), finder, newData) || hasNewInfo; } continue; } @@ -1453,7 +1453,7 @@ void ModelManagerInterface::updateCppQmlTypes( for (auto it = newDeclarations.begin(), end = newDeclarations.end(); it != end;) { for (auto docIt = it->begin(), endDocIt = it->end(); docIt != endDocIt;) { const CPlusPlus::Document::Ptr &savedDoc = *docIt; - if (savedDoc->fileName() == fileName) { + if (savedDoc->filePath() == filePath) { savedDoc->releaseSourceAndAST(); it->erase(docIt); break; @@ -1472,7 +1472,7 @@ void ModelManagerInterface::updateCppQmlTypes( doc->keepSourceAndAST(); // keep for later reparsing when dependent doc changes } - hasNewInfo = rescanExports(fileName, finder, newData) || hasNewInfo; + hasNewInfo = rescanExports(filePath.path(), finder, newData) || hasNewInfo; doc->releaseSourceAndAST(); } diff --git a/src/plugins/autotest/boost/boosttestparser.cpp b/src/plugins/autotest/boost/boosttestparser.cpp index f49abe98505..791fdb5b026 100644 --- a/src/plugins/autotest/boost/boosttestparser.cpp +++ b/src/plugins/autotest/boost/boosttestparser.cpp @@ -57,14 +57,12 @@ static bool includesBoostTest(const CPlusPlus::Document::Ptr &doc, return true; } - for (const QString &include : snapshot.allIncludesForDocument(doc->fileName())) { + for (const QString &include : snapshot.allIncludesForDocument(doc->filePath().toString())) { if (boostTestHpp.match(include).hasMatch()) return true; } - return CppParser::precompiledHeaderContains(snapshot, - Utils::FilePath::fromString(doc->fileName()), - boostTestHpp); + return CppParser::precompiledHeaderContains(snapshot, doc->filePath(), boostTestHpp); } static bool hasBoostTestMacros(const CPlusPlus::Document::Ptr &doc) diff --git a/src/plugins/autotest/catch/catchtestparser.cpp b/src/plugins/autotest/catch/catchtestparser.cpp index 122eb48c5ea..5c879474c3e 100644 --- a/src/plugins/autotest/catch/catchtestparser.cpp +++ b/src/plugins/autotest/catch/catchtestparser.cpp @@ -13,6 +13,8 @@ #include <QRegularExpression> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -59,7 +61,7 @@ static bool includesCatchHeader(const CPlusPlus::Document::Ptr &doc, } } - for (const QString &include : snapshot.allIncludesForDocument(doc->fileName())) { + for (const QString &include : snapshot.allIncludesForDocument(doc->filePath().toString())) { for (const QString &catchHeader : catchHeaders) { if (include.endsWith(catchHeader)) return true; @@ -67,9 +69,7 @@ static bool includesCatchHeader(const CPlusPlus::Document::Ptr &doc, } for (const QString &catchHeader : catchHeaders) { - if (CppParser::precompiledHeaderContains(snapshot, - Utils::FilePath::fromString(doc->fileName()), - catchHeader)) + if (CppParser::precompiledHeaderContains(snapshot, doc->filePath(), catchHeader)) return true; } return false; @@ -99,7 +99,7 @@ bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futu return false; const CppEditor::CppModelManager *modelManager = CppEditor::CppModelManager::instance(); - const QString &filePath = doc->fileName(); + const QString &filePath = doc->filePath().toString(); const QByteArray &fileContent = getFileContent(fileName); if (!hasCatchNames(doc)) { diff --git a/src/plugins/autotest/gtest/gtestparser.cpp b/src/plugins/autotest/gtest/gtestparser.cpp index d5eb7bfc09a..0f0e2aa3c0b 100644 --- a/src/plugins/autotest/gtest/gtestparser.cpp +++ b/src/plugins/autotest/gtest/gtestparser.cpp @@ -13,6 +13,8 @@ #include <QRegularExpression> #include <QRegularExpressionMatch> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -45,14 +47,12 @@ static bool includesGTest(const CPlusPlus::Document::Ptr &doc, return true; } - for (const QString &include : snapshot.allIncludesForDocument(doc->fileName())) { + for (const QString &include : snapshot.allIncludesForDocument(doc->filePath().toString())) { if (include.endsWith(gtestH)) return true; } - return CppParser::precompiledHeaderContains(snapshot, - Utils::FilePath::fromString(doc->fileName()), - gtestH); + return CppParser::precompiledHeaderContains(snapshot, doc->filePath(), gtestH); } static bool hasGTestNames(const CPlusPlus::Document::Ptr &document) @@ -84,7 +84,7 @@ bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> &futureIn return false; } - const QString &filePath = doc->fileName(); + const FilePath filePath = doc->filePath(); const CppEditor::CppModelManager *modelManager = CppEditor::CppModelManager::instance(); CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName); document->check(); diff --git a/src/plugins/autotest/qtest/qttestparser.cpp b/src/plugins/autotest/qtest/qttestparser.cpp index e5753a36a84..9bbb4d281d8 100644 --- a/src/plugins/autotest/qtest/qttestparser.cpp +++ b/src/plugins/autotest/qtest/qttestparser.cpp @@ -12,6 +12,8 @@ #include <QRegularExpressionMatchIterator> +using namespace Utils; + namespace Autotest { namespace Internal { @@ -51,7 +53,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus: } } - const QSet<QString> allIncludes = snapshot.allIncludesForDocument(doc->fileName()); + const QSet<QString> allIncludes = snapshot.allIncludesForDocument(doc->filePath().toString()); for (const QString &include : allIncludes) { for (const QString &prefix : expectedHeaderPrefixes) { if (include.endsWith(QString("%1/qtest.h").arg(prefix))) @@ -61,7 +63,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus: for (const QString &prefix : expectedHeaderPrefixes) { if (CppParser::precompiledHeaderContains(snapshot, - Utils::FilePath::fromString(doc->fileName()), + doc->filePath(), QString("%1/qtest.h").arg(prefix))) { return true; } @@ -82,10 +84,10 @@ static bool qtTestLibDefined(const Utils::FilePath &fileName) } TestCases QtTestParser::testCases(const CppEditor::CppModelManager *modelManager, - const Utils::FilePath &fileName) const + const Utils::FilePath &filePath) const { - const QByteArray &fileContent = getFileContent(fileName); - CPlusPlus::Document::Ptr document = modelManager->document(fileName.toString()); + const QByteArray &fileContent = getFileContent(filePath); + CPlusPlus::Document::Ptr document = modelManager->document(filePath); if (document.isNull()) return {}; @@ -101,7 +103,7 @@ TestCases QtTestParser::testCases(const CppEditor::CppModelManager *modelManager } } // check if one has used a self-defined macro or QTest::qExec() directly - document = m_cppSnapshot.preprocessedDocument(fileContent, fileName); + document = m_cppSnapshot.preprocessedDocument(fileContent, filePath); document->check(); CPlusPlus::AST *ast = document->translationUnit()->ast(); TestAstVisitor astVisitor(document, m_cppSnapshot); @@ -288,7 +290,7 @@ static QtTestCodeLocationList tagLocationsFor(const QtTestParseResult *func, static bool isQObject(const CPlusPlus::Document::Ptr &declaringDoc) { - const QString file = declaringDoc->fileName(); + const FilePath file = declaringDoc->filePath(); return (Utils::HostOsInfo::isMacHost() && file.endsWith("QtCore.framework/Headers/qobject.h")) || file.endsWith("QtCore/qobject.h") || file.endsWith("kernel/qobject.h"); } @@ -337,8 +339,7 @@ std::optional<bool> QtTestParser::fillTestCaseData( const QString &testCaseName, const CPlusPlus::Document::Ptr &doc, TestCaseData &data) const { - const Utils::FilePath filePath = Utils::FilePath::fromString(doc->fileName()); - const Utils::FilePaths &alternativeFiles = m_alternativeFiles.values(filePath); + const FilePaths &alternativeFiles = m_alternativeFiles.values(doc->filePath()); CPlusPlus::Document::Ptr declaringDoc = declaringDocument(doc, m_cppSnapshot, testCaseName, alternativeFiles, &(data.line), &(data.column)); @@ -364,7 +365,7 @@ std::optional<bool> QtTestParser::fillTestCaseData( for (const Utils::FilePath &file : files) Utils::addToHash(&(data.dataTags), checkForDataTags(file)); - data.fileName = Utils::FilePath::fromString(declaringDoc->fileName()); + data.fileName = declaringDoc->filePath(); data.valid = true; return std::optional<bool>(); } diff --git a/src/plugins/autotest/quick/quicktestparser.cpp b/src/plugins/autotest/quick/quicktestparser.cpp index b133938abc2..594b2364a07 100644 --- a/src/plugins/autotest/quick/quicktestparser.cpp +++ b/src/plugins/autotest/quick/quicktestparser.cpp @@ -20,6 +20,7 @@ #include <utils/qtcassert.h> using namespace QmlJS; +using namespace Utils; namespace Autotest { namespace Internal { @@ -59,7 +60,7 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc, } } - for (const QString &include : snapshot.allIncludesForDocument(doc->fileName())) { + for (const QString &include : snapshot.allIncludesForDocument(doc->filePath().toString())) { for (const QString &prefix : expectedHeaderPrefixes) { if (include.endsWith(QString("%1/quicktest.h").arg(prefix))) return true; @@ -68,7 +69,7 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc, for (const QString &prefix : expectedHeaderPrefixes) { if (CppParser::precompiledHeaderContains(snapshot, - Utils::FilePath::fromString(doc->fileName()), + doc->filePath(), QString("%1/quicktest.h").arg(prefix))) { return true; } @@ -101,7 +102,7 @@ static QString quickTestSrcDir(const CppEditor::CppModelManager *cppMM, QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) const { const QList<CPlusPlus::Document::MacroUse> macros = doc->macroUses(); - const Utils::FilePath filePath = Utils::FilePath::fromString(doc->fileName()); + const Utils::FilePath filePath = doc->filePath(); for (const CPlusPlus::Document::MacroUse ¯o : macros) { if (!macro.isFunctionLike() || macro.arguments().isEmpty()) @@ -253,11 +254,11 @@ bool QuickTestParser::handleQtQuickTest(QFutureInterface<TestParseResultPtr> &fu if (quickTestName(document).isEmpty()) return false; - QList<CppEditor::ProjectPart::ConstPtr> ppList = modelManager->projectPart(document->fileName()); + QList<CppEditor::ProjectPart::ConstPtr> ppList = modelManager->projectPart(document->filePath()); if (ppList.isEmpty()) // happens if shutting down while parsing return false; - const Utils::FilePath cppFileName = Utils::FilePath::fromString(document->fileName()); - const Utils::FilePath proFile = Utils::FilePath::fromString(ppList.at(0)->projectFile); + const FilePath cppFileName = document->filePath(); + const FilePath proFile = Utils::FilePath::fromString(ppList.at(0)->projectFile); m_mainCppFiles.insert(cppFileName, proFile); const Utils::FilePath srcDir = Utils::FilePath::fromString( quickTestSrcDir(modelManager, cppFileName)); diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index f9c13045d88..8edfea8a262 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -161,7 +161,7 @@ void TestCodeParser::onDocumentUpdated(const Utils::FilePath &fileName, bool isQ void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document) { - onDocumentUpdated(Utils::FilePath::fromString(document->fileName())); + onDocumentUpdated(document->filePath()); } void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document) diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index 46fb37ac456..d4c2e94bed1 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -41,7 +41,7 @@ ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(TextEditor::TextDocum connect(static_cast<CppEditor::BuiltinEditorDocumentParser *>(parser().data()), &CppEditor::BuiltinEditorDocumentParser::finished, this, [this] { - emit parserConfigChanged(Utils::FilePath::fromString(filePath()), parserConfig()); + emit parserConfigChanged(filePath(), parserConfig()); }); setSemanticHighlightingChecker([this] { return !ClangModelManagerSupport::clientForFile(m_document.filePath()); @@ -84,7 +84,7 @@ void ClangEditorDocumentProcessor::setParserConfig( const CppEditor::BaseEditorDocumentParser::Configuration &config) { CppEditor::BuiltinEditorDocumentProcessor::setParserConfig(config); - emit parserConfigChanged(Utils::FilePath::fromString(filePath()), config); + emit parserConfigChanged(filePath(), config); } CppEditor::BaseEditorDocumentParser::Configuration ClangEditorDocumentProcessor::parserConfig() diff --git a/src/plugins/classview/classviewmanager.cpp b/src/plugins/classview/classviewmanager.cpp index ee1f89c7c75..1e0cf89f719 100644 --- a/src/plugins/classview/classviewmanager.cpp +++ b/src/plugins/classview/classviewmanager.cpp @@ -275,7 +275,7 @@ void Manager::initialize() if (doc.data() == nullptr) return; - d->m_awaitingDocuments.insert(FilePath::fromString(doc->fileName())); + d->m_awaitingDocuments.insert(doc->filePath()); d->m_timer.start(400); // Accumulate multiple requests into one, restarts the timer }); diff --git a/src/plugins/classview/classviewparser.cpp b/src/plugins/classview/classviewparser.cpp index cbc90bf4fe9..821ec947992 100644 --- a/src/plugins/classview/classviewparser.cpp +++ b/src/plugins/classview/classviewparser.cpp @@ -215,7 +215,7 @@ ParserTreeItem::ConstPtr Parser::getParseDocumentTree(const CPlusPlus::Document: if (doc.isNull()) return ParserTreeItem::ConstPtr(); - const FilePath fileName = FilePath::fromString(doc->fileName()); + const FilePath fileName = doc->filePath(); ParserTreeItem::ConstPtr itemPtr = ParserTreeItem::parseDocument(doc); @@ -235,8 +235,7 @@ ParserTreeItem::ConstPtr Parser::getCachedOrParseDocumentTree(const CPlusPlus::D if (doc.isNull()) return ParserTreeItem::ConstPtr(); - const QString &fileName = doc->fileName(); - const auto it = d->m_documentCache.constFind(FilePath::fromString(fileName)); + const auto it = d->m_documentCache.constFind(doc->filePath()); if (it != d->m_documentCache.constEnd() && !it.value().tree.isNull() && it.value().treeRevision == doc->revision()) { return it.value().tree; diff --git a/src/plugins/cppeditor/baseeditordocumentprocessor.cpp b/src/plugins/cppeditor/baseeditordocumentprocessor.cpp index 97efb1c2584..252f0a49928 100644 --- a/src/plugins/cppeditor/baseeditordocumentprocessor.cpp +++ b/src/plugins/cppeditor/baseeditordocumentprocessor.cpp @@ -22,7 +22,7 @@ namespace CppEditor { */ BaseEditorDocumentProcessor::BaseEditorDocumentProcessor(QTextDocument *textDocument, - const QString &filePath) + const Utils::FilePath &filePath) : m_filePath(filePath), m_textDocument(textDocument) { diff --git a/src/plugins/cppeditor/baseeditordocumentprocessor.h b/src/plugins/cppeditor/baseeditordocumentprocessor.h index d49efd095fa..9461876f6bb 100644 --- a/src/plugins/cppeditor/baseeditordocumentprocessor.h +++ b/src/plugins/cppeditor/baseeditordocumentprocessor.h @@ -10,6 +10,7 @@ #include "cpptoolsreuse.h" #include <coreplugin/helpitem.h> + #include <texteditor/codeassist/assistinterface.h> #include <texteditor/quickfix.h> #include <texteditor/texteditor.h> @@ -18,7 +19,6 @@ #include <cplusplus/CppDocument.h> #include <QTextEdit> - #include <QVariant> #include <functional> @@ -45,7 +45,7 @@ class CPPEDITOR_EXPORT BaseEditorDocumentProcessor : public QObject Q_OBJECT public: - BaseEditorDocumentProcessor(QTextDocument *textDocument, const QString &filePath); + BaseEditorDocumentProcessor(QTextDocument *textDocument, const Utils::FilePath &filePath); ~BaseEditorDocumentProcessor() override; void run(bool projectsUpdated = false); @@ -65,7 +65,7 @@ public: virtual QFuture<CursorInfo> cursorInfo(const CursorInfoParams ¶ms) = 0; - QString filePath() const { return m_filePath; } + const Utils::FilePath &filePath() const { return m_filePath; } signals: // Signal interface to implement @@ -94,7 +94,7 @@ private: virtual void runImpl(const BaseEditorDocumentParser::UpdateParams &updateParams) = 0; private: - QString m_filePath; + Utils::FilePath m_filePath; QTextDocument *m_textDocument; }; diff --git a/src/plugins/cppeditor/builtincursorinfo.cpp b/src/plugins/cppeditor/builtincursorinfo.cpp index a0190a3b13c..870c9addbe5 100644 --- a/src/plugins/cppeditor/builtincursorinfo.cpp +++ b/src/plugins/cppeditor/builtincursorinfo.cpp @@ -270,7 +270,7 @@ bool handleMacroCase(const Document::Ptr document, const int length = macro->nameToQString().size(); // Macro definition - if (macro->fileName() == document->fileName()) + if (macro->fileName() == document->filePath().pathView()) ranges->append(toRange(textCursor, macro->utf16CharOffset(), length)); // Other macro uses diff --git a/src/plugins/cppeditor/builtineditordocumentparser.cpp b/src/plugins/cppeditor/builtineditordocumentparser.cpp index 7d3a2430e84..221b7d70c87 100644 --- a/src/plugins/cppeditor/builtineditordocumentparser.cpp +++ b/src/plugins/cppeditor/builtineditordocumentparser.cpp @@ -137,15 +137,15 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur // Remove changed files from the snapshot QSet<Utils::FilePath> toRemove; for (const Document::Ptr &doc : std::as_const(state.snapshot)) { - const Utils::FilePath fileName = Utils::FilePath::fromString(doc->fileName()); - if (workingCopy.contains(fileName)) { - if (workingCopy.get(fileName).second != doc->editorRevision()) - addFileAndDependencies(&state.snapshot, &toRemove, fileName); + const Utils::FilePath filePath = doc->filePath(); + if (workingCopy.contains(filePath)) { + if (workingCopy.get(filePath).second != doc->editorRevision()) + addFileAndDependencies(&state.snapshot, &toRemove, filePath); continue; } - Document::Ptr otherDoc = globalSnapshot.document(fileName); + Document::Ptr otherDoc = globalSnapshot.document(filePath); if (!otherDoc.isNull() && otherDoc->revision() != doc->revision()) - addFileAndDependencies(&state.snapshot, &toRemove, fileName); + addFileAndDependencies(&state.snapshot, &toRemove, filePath); } if (!toRemove.isEmpty()) { @@ -165,9 +165,8 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur state.snapshot.remove(filePath()); Internal::CppSourceProcessor sourceProcessor(state.snapshot, [&](const Document::Ptr &doc) { - const QString fileName = doc->fileName(); - const bool isInEditor = fileName == filePath(); - Document::Ptr otherDoc = modelManager->document(fileName); + const bool isInEditor = doc->filePath().toString() == filePath(); + Document::Ptr otherDoc = modelManager->document(doc->filePath()); unsigned newRev = otherDoc.isNull() ? 1U : otherDoc->revision() + 1; if (isInEditor) newRev = qMax(rev + 1, newRev); diff --git a/src/plugins/cppeditor/builtineditordocumentprocessor.cpp b/src/plugins/cppeditor/builtineditordocumentprocessor.cpp index 58947dcb634..fa74f71e6c4 100644 --- a/src/plugins/cppeditor/builtineditordocumentprocessor.cpp +++ b/src/plugins/cppeditor/builtineditordocumentprocessor.cpp @@ -136,7 +136,7 @@ QList<TextEditor::BlockRange> toTextEditorBlocks( } // anonymous namespace BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(TextEditor::TextDocument *document) - : BaseEditorDocumentProcessor(document->document(), document->filePath().toString()) + : BaseEditorDocumentProcessor(document->document(), document->filePath()) , m_parser(new BuiltinEditorDocumentParser(document->filePath().toString(), indexerFileSizeLimitInMb())) , m_codeWarningsUpdated(false) @@ -241,13 +241,13 @@ void BuiltinEditorDocumentProcessor::onParserFinished(CPlusPlus::Document::Ptr d if (document.isNull()) return; - if (document->fileName() != filePath()) + if (document->filePath() != filePath()) return; // some other document got updated if (document->editorRevision() != revision()) return; // outdated content, wait for a new document to be parsed - qCDebug(log) << "document parsed" << document->fileName() << document->editorRevision(); + qCDebug(log) << "document parsed" << document->filePath() << document->editorRevision(); // Emit ifdefed out blocks const auto ifdefoutBlocks = toTextEditorBlocks(document->skippedBlocks()); @@ -261,14 +261,14 @@ void BuiltinEditorDocumentProcessor::onParserFinished(CPlusPlus::Document::Ptr d m_documentSnapshot = snapshot; const auto source = createSemanticInfoSource(false); - QTC_CHECK(source.snapshot.contains(document->fileName())); + QTC_CHECK(source.snapshot.contains(document->filePath())); m_semanticInfoUpdater.updateDetached(source); } void BuiltinEditorDocumentProcessor::onSemanticInfoUpdated(const SemanticInfo semanticInfo) { qCDebug(log) << "semantic info updated" - << semanticInfo.doc->fileName() << semanticInfo.revision << semanticInfo.complete; + << semanticInfo.doc->filePath() << semanticInfo.revision << semanticInfo.complete; emit semanticInfoUpdated(semanticInfo); @@ -283,7 +283,7 @@ void BuiltinEditorDocumentProcessor::onCodeWarningsUpdated( if (document.isNull()) return; - if (document->fileName() != filePath()) + if (document->filePath() != filePath()) return; // some other document got updated if (document->editorRevision() != revision()) @@ -302,10 +302,9 @@ void BuiltinEditorDocumentProcessor::onCodeWarningsUpdated( SemanticInfo::Source BuiltinEditorDocumentProcessor::createSemanticInfoSource(bool force) const { const WorkingCopy workingCopy = CppModelManager::instance()->workingCopy(); - const QString path = filePath(); - return SemanticInfo::Source(path, - workingCopy.source(path), - workingCopy.revision(path), + return SemanticInfo::Source(filePath().toString(), + workingCopy.source(filePath()), + workingCopy.revision(filePath()), m_documentSnapshot, force); } diff --git a/src/plugins/cppeditor/builtinindexingsupport.cpp b/src/plugins/cppeditor/builtinindexingsupport.cpp index 81d8b11c2c5..474c410e147 100644 --- a/src/plugins/cppeditor/builtinindexingsupport.cpp +++ b/src/plugins/cppeditor/builtinindexingsupport.cpp @@ -71,7 +71,7 @@ public: void process(const CPlusPlus::Document::Ptr document) { using namespace CPlusPlus; - const QString fileName = document->fileName(); + const QString fileName = document->filePath().toString(); const QList<Document::DiagnosticMessage> messages = document->diagnosticMessages(); for (const Document::DiagnosticMessage &message : messages) { @@ -272,7 +272,7 @@ public: future.waitForResume(); if (future.isCanceled()) break; - if (m_fileNames.isEmpty() || m_fileNames.contains(it.value()->fileName())) { + if (m_fileNames.isEmpty() || m_fileNames.contains(it.value()->filePath().path())) { QVector<Core::SearchResultItem> resultItems; auto filter = [&](const IndexItem::Ptr &info) -> IndexItem::VisitorResult { if (matcher.match(info->symbolName()).hasMatch()) { diff --git a/src/plugins/cppeditor/cppchecksymbols.cpp b/src/plugins/cppeditor/cppchecksymbols.cpp index 1621f6ae51f..c0ca4020701 100644 --- a/src/plugins/cppeditor/cppchecksymbols.cpp +++ b/src/plugins/cppeditor/cppchecksymbols.cpp @@ -312,7 +312,7 @@ void CheckSymbols::run() { CollectSymbols collectTypes(_doc, _context.snapshot()); - _fileName = _doc->fileName(); + _filePath = _doc->filePath(); _potentialTypes = collectTypes.types(); _potentialFields = collectTypes.fields(); _potentialFunctions = collectTypes.functions(); @@ -334,7 +334,7 @@ void CheckSymbols::run() bool CheckSymbols::warning(unsigned line, unsigned column, const QString &text, unsigned length) { - Document::DiagnosticMessage m(Document::DiagnosticMessage::Warning, _fileName, line, column, text, length); + Document::DiagnosticMessage m(Document::DiagnosticMessage::Warning, _filePath, line, column, text, length); _diagMsgs.append(m); return false; } diff --git a/src/plugins/cppeditor/cppchecksymbols.h b/src/plugins/cppeditor/cppchecksymbols.h index 044dc76f4ca..c2416081ffa 100644 --- a/src/plugins/cppeditor/cppchecksymbols.h +++ b/src/plugins/cppeditor/cppchecksymbols.h @@ -170,7 +170,7 @@ private: CPlusPlus::Document::Ptr _doc; CPlusPlus::LookupContext _context; CPlusPlus::TypeOfExpression typeOfExpression; - QString _fileName; + Utils::FilePath _filePath; QSet<QByteArray> _potentialTypes; QSet<QByteArray> _potentialFields; QSet<QByteArray> _potentialFunctions; diff --git a/src/plugins/cppeditor/cppcodegen_test.cpp b/src/plugins/cppeditor/cppcodegen_test.cpp index 22791b08995..6b7e1b3cc58 100644 --- a/src/plugins/cppeditor/cppcodegen_test.cpp +++ b/src/plugins/cppeditor/cppcodegen_test.cpp @@ -18,6 +18,7 @@ tests the InsertionPointLocator. */ using namespace CPlusPlus; +using namespace Utils; using CppEditor::Tests::TemporaryDir; @@ -42,10 +43,10 @@ Document::Ptr createDocumentAndFile(TemporaryDir *temporaryDir, int expectedGlobalSymbolCount) { QTC_ASSERT(temporaryDir, return Document::Ptr()); - const QString absoluteFilePath = temporaryDir->createFile(relativeFilePath, text); + const FilePath absoluteFilePath = temporaryDir->createFile(relativeFilePath, text); QTC_ASSERT(!absoluteFilePath.isEmpty(), return Document::Ptr()); - return createDocument(absoluteFilePath, text, expectedGlobalSymbolCount); + return createDocument(absoluteFilePath.toString(), text, expectedGlobalSymbolCount); } } // anonymous namespace @@ -73,7 +74,7 @@ void CodegenTest::testPublicInEmptyClass() CppRefactoringChanges changes(snapshot); InsertionPointLocator find(changes); InsertionLocation loc = find.methodDeclarationInClass( - doc->fileName(), + doc->filePath(), foo, InsertionPointLocator::Public); QVERIFY(loc.isValid()); @@ -107,7 +108,7 @@ void CodegenTest::testPublicInNonemptyClass() CppRefactoringChanges changes(snapshot); InsertionPointLocator find(changes); InsertionLocation loc = find.methodDeclarationInClass( - doc->fileName(), + doc->filePath(), foo, InsertionPointLocator::Public); QVERIFY(loc.isValid()); @@ -141,7 +142,7 @@ void CodegenTest::testPublicBeforeProtected() CppRefactoringChanges changes(snapshot); InsertionPointLocator find(changes); InsertionLocation loc = find.methodDeclarationInClass( - doc->fileName(), + doc->filePath(), foo, InsertionPointLocator::Public); QVERIFY(loc.isValid()); @@ -176,7 +177,7 @@ void CodegenTest::testPrivateAfterProtected() CppRefactoringChanges changes(snapshot); InsertionPointLocator find(changes); InsertionLocation loc = find.methodDeclarationInClass( - doc->fileName(), + doc->filePath(), foo, InsertionPointLocator::Private); QVERIFY(loc.isValid()); @@ -211,7 +212,7 @@ void CodegenTest::testProtectedInNonemptyClass() CppRefactoringChanges changes(snapshot); InsertionPointLocator find(changes); InsertionLocation loc = find.methodDeclarationInClass( - doc->fileName(), + doc->filePath(), foo, InsertionPointLocator::Protected); QVERIFY(loc.isValid()); @@ -246,7 +247,7 @@ void CodegenTest::testProtectedBetweenPublicAndPrivate() CppRefactoringChanges changes(snapshot); InsertionPointLocator find(changes); InsertionLocation loc = find.methodDeclarationInClass( - doc->fileName(), + doc->filePath(), foo, InsertionPointLocator::Protected); QVERIFY(loc.isValid()); @@ -302,7 +303,7 @@ void CodegenTest::testQtdesignerIntegration() CppRefactoringChanges changes(snapshot); InsertionPointLocator find(changes); InsertionLocation loc = find.methodDeclarationInClass( - doc->fileName(), + doc->filePath(), foo, InsertionPointLocator::PrivateSlot); QVERIFY(loc.isValid()); @@ -351,7 +352,7 @@ void CodegenTest::testDefinitionEmptyClass() QList<InsertionLocation> locList = find.methodDefinition(decl); QVERIFY(locList.size() == 1); InsertionLocation loc = locList.first(); - QCOMPARE(loc.fileName(), sourceDocument->fileName()); + QCOMPARE(loc.fileName(), sourceDocument->filePath().toString()); QCOMPARE(loc.prefix(), QLatin1String("\n\n")); QCOMPARE(loc.suffix(), QString()); QCOMPARE(loc.line(), 3); @@ -387,7 +388,7 @@ void CodegenTest::testDefinitionFirstMember() Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3); QVERIFY(sourceDocument); sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"), - headerDocument->fileName(), 1, + headerDocument->filePath().toString(), 1, Client::IncludeLocal)); Snapshot snapshot; @@ -409,7 +410,7 @@ void CodegenTest::testDefinitionFirstMember() QList<InsertionLocation> locList = find.methodDefinition(decl); QVERIFY(locList.size() == 1); InsertionLocation loc = locList.first(); - QCOMPARE(loc.fileName(), sourceDocument->fileName()); + QCOMPARE(loc.fileName(), sourceDocument->filePath().toString()); QCOMPARE(loc.line(), 4); QCOMPARE(loc.column(), 1); QCOMPARE(loc.suffix(), QLatin1String("\n\n")); @@ -446,7 +447,7 @@ void CodegenTest::testDefinitionLastMember() Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3); QVERIFY(sourceDocument); sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"), - headerDocument->fileName(), 1, + headerDocument->filePath().toString(), 1, Client::IncludeLocal)); Snapshot snapshot; @@ -468,7 +469,7 @@ void CodegenTest::testDefinitionLastMember() QList<InsertionLocation> locList = find.methodDefinition(decl); QVERIFY(locList.size() == 1); InsertionLocation loc = locList.first(); - QCOMPARE(loc.fileName(), sourceDocument->fileName()); + QCOMPARE(loc.fileName(), sourceDocument->filePath().toString()); QCOMPARE(loc.line(), 7); QCOMPARE(loc.column(), 2); QCOMPARE(loc.prefix(), QLatin1String("\n\n")); @@ -512,7 +513,7 @@ void CodegenTest::testDefinitionMiddleMember() Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 4); QVERIFY(sourceDocument); sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"), - headerDocument->fileName(), 1, + headerDocument->filePath().toString(), 1, Client::IncludeLocal)); Snapshot snapshot; @@ -534,7 +535,7 @@ void CodegenTest::testDefinitionMiddleMember() QList<InsertionLocation> locList = find.methodDefinition(decl); QVERIFY(locList.size() == 1); InsertionLocation loc = locList.first(); - QCOMPARE(loc.fileName(), sourceDocument->fileName()); + QCOMPARE(loc.fileName(), sourceDocument->filePath().toString()); QCOMPARE(loc.line(), 7); QCOMPARE(loc.column(), 2); QCOMPARE(loc.prefix(), QLatin1String("\n\n")); @@ -572,7 +573,7 @@ void CodegenTest::testDefinitionMiddleMemberSurroundedByUndefined() Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3); QVERIFY(sourceDocument); sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"), - headerDocument->fileName(), 1, + headerDocument->filePath().toString(), 1, Client::IncludeLocal)); Snapshot snapshot; @@ -594,7 +595,7 @@ void CodegenTest::testDefinitionMiddleMemberSurroundedByUndefined() QList<InsertionLocation> locList = find.methodDefinition(decl); QVERIFY(locList.size() == 1); InsertionLocation loc = locList.first(); - QCOMPARE(loc.fileName(), sourceDocument->fileName()); + QCOMPARE(loc.fileName(), sourceDocument->filePath().toString()); QCOMPARE(loc.line(), 4); QCOMPARE(loc.column(), 1); QCOMPARE(loc.prefix(), QString()); @@ -635,7 +636,7 @@ void CodegenTest::testDefinitionMemberSpecificFile() Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3); QVERIFY(sourceDocument); sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"), - headerDocument->fileName(), 1, + headerDocument->filePath().toString(), 1, Client::IncludeLocal)); Snapshot snapshot; @@ -654,10 +655,11 @@ void CodegenTest::testDefinitionMemberSpecificFile() CppRefactoringChanges changes(snapshot); InsertionPointLocator find(changes); - QList<InsertionLocation> locList = find.methodDefinition(decl, true, sourceDocument->fileName()); + QList<InsertionLocation> locList = + find.methodDefinition(decl, true, sourceDocument->filePath().toString()); QVERIFY(locList.size() == 1); InsertionLocation loc = locList.first(); - QCOMPARE(loc.fileName(), sourceDocument->fileName()); + QCOMPARE(loc.fileName(), sourceDocument->filePath().toString()); QCOMPARE(loc.line(), 7); QCOMPARE(loc.column(), 2); QCOMPARE(loc.prefix(), QLatin1String("\n\n")); diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp index 0b5006e6bff..176bd9f4fcc 100644 --- a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp +++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp @@ -33,6 +33,8 @@ #include <numeric> using namespace CPlusPlus; +using namespace Utils; + namespace CMI = CppEditor::CppCodeModelInspector; namespace { @@ -48,11 +50,11 @@ TextEditor::BaseTextEditor *currentEditor() return qobject_cast<TextEditor::BaseTextEditor*>(Core::EditorManager::currentEditor()); } -QString fileInCurrentEditor() +Utils::FilePath fileInCurrentEditor() { if (TextEditor::BaseTextEditor *editor = currentEditor()) - return editor->document()->filePath().toString(); - return QString(); + return editor->document()->filePath(); + return {}; } QSizePolicy sizePolicyWithStretchFactor(int stretchFactor) @@ -435,7 +437,7 @@ public: void configure(const Snapshot &snapshot); void setGlobalSnapshot(const Snapshot &snapshot); - QModelIndex indexForDocument(const QString &filePath); + QModelIndex indexForDocument(const Utils::FilePath &filePath); enum Columns { SymbolCountColumn, SharedColumn, FilePathColumn, ColumnCount }; @@ -465,11 +467,11 @@ void SnapshotModel::setGlobalSnapshot(const Snapshot &snapshot) m_globalSnapshot = snapshot; } -QModelIndex SnapshotModel::indexForDocument(const QString &filePath) +QModelIndex SnapshotModel::indexForDocument(const FilePath &filePath) { for (int i = 0, total = m_documents.size(); i < total; ++i) { const Document::Ptr document = m_documents.at(i); - if (document->fileName() == filePath) + if (document->filePath() == filePath) return index(i, FilePathColumn); } return {}; @@ -493,12 +495,12 @@ QVariant SnapshotModel::data(const QModelIndex &index, int role) const if (column == SymbolCountColumn) { return document->control()->symbolCount(); } else if (column == SharedColumn) { - Document::Ptr globalDocument = m_globalSnapshot.document(document->fileName()); + Document::Ptr globalDocument = m_globalSnapshot.document(document->filePath()); const bool isShared = globalDocument && globalDocument->fingerprint() == document->fingerprint(); return CMI::Utils::toString(isShared); } else if (column == FilePathColumn) { - return QDir::toNativeSeparators(document->fileName()); + return document->filePath().toUserOutput(); } } return QVariant(); @@ -1200,7 +1202,7 @@ public: WorkingCopyModel(QObject *parent); void configure(const WorkingCopy &workingCopy); - QModelIndex indexForFile(const QString &filePath); + QModelIndex indexForFile(const Utils::FilePath &filePath); enum Columns { RevisionColumn, FilePathColumn, ColumnCount }; @@ -1211,11 +1213,11 @@ public: private: struct WorkingCopyEntry { - WorkingCopyEntry(const QString &filePath, const QByteArray &source, unsigned revision) + WorkingCopyEntry(const Utils::FilePath &filePath, const QByteArray &source, unsigned revision) : filePath(filePath), source(source), revision(revision) {} - QString filePath; + Utils::FilePath filePath; QByteArray source; unsigned revision; }; @@ -1232,14 +1234,13 @@ void WorkingCopyModel::configure(const WorkingCopy &workingCopy) emit layoutAboutToBeChanged(); m_workingCopyList.clear(); const WorkingCopy::Table &elements = workingCopy.elements(); - for (auto it = elements.cbegin(), end = elements.cend(); it != end; ++it) { - m_workingCopyList << WorkingCopyEntry(it.key().toString(), it.value().first, - it.value().second); - } + for (auto it = elements.cbegin(), end = elements.cend(); it != end; ++it) + m_workingCopyList << WorkingCopyEntry(it.key(), it.value().first, it.value().second); + emit layoutChanged(); } -QModelIndex WorkingCopyModel::indexForFile(const QString &filePath) +QModelIndex WorkingCopyModel::indexForFile(const Utils::FilePath &filePath) { for (int i = 0, total = m_workingCopyList.size(); i < total; ++i) { const WorkingCopyEntry entry = m_workingCopyList.at(i); @@ -1267,7 +1268,7 @@ QVariant WorkingCopyModel::data(const QModelIndex &index, int role) const if (column == RevisionColumn) return m_workingCopyList.at(row).revision; else if (column == FilePathColumn) - return m_workingCopyList.at(row).filePath; + return m_workingCopyList.at(row).filePath.toString(); } else if (role == Qt::UserRole) { return m_workingCopyList.at(row).source; } @@ -1659,14 +1660,14 @@ void CppCodeModelInspectorDialog::updateDocumentData(const Document::Ptr &docume // General const KeyValueModel::Table table = { - {QString::fromLatin1("File Path"), QDir::toNativeSeparators(document->fileName())}, + {QString::fromLatin1("File Path"), document->filePath().toUserOutput()}, {QString::fromLatin1("Last Modified"), CMI::Utils::toString(document->lastModified())}, {QString::fromLatin1("Revision"), CMI::Utils::toString(document->revision())}, {QString::fromLatin1("Editor Revision"), CMI::Utils::toString(document->editorRevision())}, {QString::fromLatin1("Check Mode"), CMI::Utils::toString(document->checkMode())}, {QString::fromLatin1("Tokenized"), CMI::Utils::toString(document->isTokenized())}, {QString::fromLatin1("Parsed"), CMI::Utils::toString(document->isParsed())}, - {QString::fromLatin1("Project Parts"), CMI::Utils::partsForFile(document->fileName())} + {QString::fromLatin1("Project Parts"), CMI::Utils::partsForFile(document->filePath())} }; m_docGenericInfoModel->configure(table); resizeColumns<KeyValueModel>(m_ui->docGeneralView); diff --git a/src/plugins/cppeditor/cppcodemodelinspectordumper.cpp b/src/plugins/cppeditor/cppcodemodelinspectordumper.cpp index b82c2a03e11..4341c746082 100644 --- a/src/plugins/cppeditor/cppcodemodelinspectordumper.cpp +++ b/src/plugins/cppeditor/cppcodemodelinspectordumper.cpp @@ -384,10 +384,10 @@ QString Utils::toString(const ProjectExplorer::Abi &abi) return QString("??"); } -QString Utils::partsForFile(const QString &fileName) +QString Utils::partsForFile(const ::Utils::FilePath &filePath) { const QList<ProjectPart::ConstPtr> parts - = CppModelManager::instance()->projectPart(fileName); + = CppModelManager::instance()->projectPart(filePath); QString result; for (const ProjectPart::ConstPtr &part : parts) result += part->displayName + QLatin1Char(','); @@ -580,7 +580,7 @@ void Dumper::dumpSnapshot(const CPlusPlus::Snapshot &snapshot, const QString &ti QList<CPlusPlus::Document::Ptr> globallyShared; QList<CPlusPlus::Document::Ptr> notGloballyShared; for (const CPlusPlus::Document::Ptr &document : documents) { - CPlusPlus::Document::Ptr globalDocument = m_globalSnapshot.document(document->fileName()); + CPlusPlus::Document::Ptr globalDocument = m_globalSnapshot.document(document->filePath()); if (globalDocument && globalDocument->fingerprint() == document->fingerprint()) globallyShared.append(document); else @@ -641,18 +641,18 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo const QByteArray i4 = indent(4); for (const CPlusPlus::Document::Ptr &document : documents) { if (skipDetails) { - m_out << i2 << "\"" << document->fileName() << "\"\n"; + m_out << i2 << "\"" << document->filePath() << "\"\n"; continue; } - m_out << i2 << "Document \"" << document->fileName() << "\"{{{3\n"; + m_out << i2 << "Document \"" << document->filePath() << "\"{{{3\n"; m_out << i3 << "Last Modified : " << Utils::toString(document->lastModified()) << "\n"; m_out << i3 << "Revision : " << Utils::toString(document->revision()) << "\n"; m_out << i3 << "Editor Revision: " << Utils::toString(document->editorRevision()) << "\n"; m_out << i3 << "Check Mode : " << Utils::toString(document->checkMode()) << "\n"; m_out << i3 << "Tokenized : " << Utils::toString(document->isTokenized()) << "\n"; m_out << i3 << "Parsed : " << Utils::toString(document->isParsed()) << "\n"; - m_out << i3 << "Project Parts : " << Utils::partsForFile(document->fileName()) << "\n"; + m_out << i3 << "Project Parts : " << Utils::partsForFile(document->filePath()) << "\n"; const QList<CPlusPlus::Document::Include> includes = document->unresolvedIncludes() + document->resolvedIncludes(); diff --git a/src/plugins/cppeditor/cppcodemodelinspectordumper.h b/src/plugins/cppeditor/cppcodemodelinspectordumper.h index 872c868fee0..03b3c7c703b 100644 --- a/src/plugins/cppeditor/cppcodemodelinspectordumper.h +++ b/src/plugins/cppeditor/cppcodemodelinspectordumper.h @@ -33,7 +33,7 @@ struct Utils static QString toString(ProjectFile::Kind kind); static QString toString(CPlusPlus::Kind kind); static QString toString(const ProjectExplorer::Abi &abi); - static QString partsForFile(const QString &fileName); + static QString partsForFile(const ::Utils::FilePath &filePath); static QString unresolvedFileNameWithDelimiters(const CPlusPlus::Document::Include &include); static QString pathListToString(const QStringList &pathList); static QString pathListToString(const ProjectExplorer::HeaderPaths &pathList); diff --git a/src/plugins/cppeditor/cppcodestylesettingspage.cpp b/src/plugins/cppeditor/cppcodestylesettingspage.cpp index 37cdc81c7f6..7f2f0709cc2 100644 --- a/src/plugins/cppeditor/cppcodestylesettingspage.cpp +++ b/src/plugins/cppeditor/cppcodestylesettingspage.cpp @@ -45,7 +45,8 @@ static void applyRefactorings(QTextDocument *textDocument, TextEditorWidget *edi Environment env; Preprocessor preprocess(nullptr, &env); const QByteArray preprocessedSource - = preprocess.run(QLatin1String("<no-file>"), textDocument->toPlainText().toUtf8()); + = preprocess.run(Utils::FilePath::fromParts({}, {}, u"<no-file>"), + textDocument->toPlainText().toUtf8()); Document::Ptr cppDocument = Document::create(QLatin1String("<no-file>")); cppDocument->setUtf8Source(preprocessedSource); diff --git a/src/plugins/cppeditor/cppcompletion_test.cpp b/src/plugins/cppeditor/cppcompletion_test.cpp index 4721b2775e7..7fa42a4be98 100644 --- a/src/plugins/cppeditor/cppcompletion_test.cpp +++ b/src/plugins/cppeditor/cppcompletion_test.cpp @@ -26,9 +26,11 @@ /*! Tests for code completion. */ + +using namespace Core; using namespace CPlusPlus; using namespace TextEditor; -using namespace Core; +using namespace Utils; namespace CppEditor::Internal { namespace { @@ -53,11 +55,11 @@ public: m_temporaryDir.reset(new CppEditor::Tests::TemporaryDir()); QVERIFY(m_temporaryDir->isValid()); const QByteArray fileExt = isObjC ? "mm" : "h"; - const QString fileName = m_temporaryDir->createFile("file." + fileExt, m_source); - QVERIFY(!fileName.isEmpty()); + const FilePath filePath = m_temporaryDir->createFile("file." + fileExt, m_source); + QVERIFY(!filePath.isEmpty()); // Open in editor - m_editor = EditorManager::openEditor(Utils::FilePath::fromString(fileName)); + m_editor = EditorManager::openEditor(filePath); QVERIFY(m_editor); closeEditorAtEndOfTestCase(m_editor); m_editorWidget = TextEditorWidget::fromEditor(m_editor); @@ -66,7 +68,7 @@ public: m_textDocument = m_editorWidget->document(); // Get Document - const Document::Ptr document = waitForFileInGlobalSnapshot(fileName); + const Document::Ptr document = waitForFileInGlobalSnapshot(filePath.toString()); QVERIFY(document); QVERIFY(document->diagnosticMessages().isEmpty()); diff --git a/src/plugins/cppeditor/cppcompletionassist.cpp b/src/plugins/cppeditor/cppcompletionassist.cpp index 6aa677aaba3..b8330aadb27 100644 --- a/src/plugins/cppeditor/cppcompletionassist.cpp +++ b/src/plugins/cppeditor/cppcompletionassist.cpp @@ -1480,7 +1480,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope) addKeywords(); addMacros(CppModelManager::configurationFileName(), context.snapshot()); - addMacros(context.thisDocument()->fileName(), context.snapshot()); + addMacros(context.thisDocument()->filePath().toString(), context.snapshot()); addSnippets(); return !m_completions.isEmpty(); } @@ -1860,10 +1860,10 @@ void InternalCppCompletionAssistProcessor::addMacros_helper(const Snapshot &snap { Document::Ptr doc = snapshot.document(fileName); - if (!doc || processed->contains(doc->fileName())) + if (!doc || processed->contains(doc->filePath().path())) return; - processed->insert(doc->fileName()); + processed->insert(doc->filePath().path()); const QList<Document::Include> includes = doc->resolvedIncludes(); for (const Document::Include &i : includes) diff --git a/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp b/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp index 597c289f85f..965c5d42260 100644 --- a/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp +++ b/src/plugins/cppeditor/cppcurrentdocumentfilter.cpp @@ -119,7 +119,7 @@ void CppCurrentDocumentFilter::accept(const Core::LocatorFilterEntry &selection, void CppCurrentDocumentFilter::onDocumentUpdated(Document::Ptr doc) { QMutexLocker locker(&m_mutex); - if (m_currentFileName == doc->fileName()) + if (m_currentFileName == doc->filePath()) m_itemsOfCurrentDoc.clear(); } @@ -127,7 +127,7 @@ void CppCurrentDocumentFilter::onCurrentEditorChanged(Core::IEditor *currentEdit { QMutexLocker locker(&m_mutex); if (currentEditor) - m_currentFileName = currentEditor->document()->filePath().toString(); + m_currentFileName = currentEditor->document()->filePath(); else m_currentFileName.clear(); m_itemsOfCurrentDoc.clear(); @@ -139,7 +139,7 @@ void CppCurrentDocumentFilter::onEditorAboutToClose(Core::IEditor *editorAboutTo return; QMutexLocker locker(&m_mutex); - if (m_currentFileName == editorAboutToClose->document()->filePath().toString()) { + if (m_currentFileName == editorAboutToClose->document()->filePath()) { m_currentFileName.clear(); m_itemsOfCurrentDoc.clear(); } diff --git a/src/plugins/cppeditor/cppcurrentdocumentfilter.h b/src/plugins/cppeditor/cppcurrentdocumentfilter.h index ab717dace69..26caa0bcbd5 100644 --- a/src/plugins/cppeditor/cppcurrentdocumentfilter.h +++ b/src/plugins/cppeditor/cppcurrentdocumentfilter.h @@ -41,7 +41,7 @@ private: SearchSymbols search; mutable QMutex m_mutex; - QString m_currentFileName; + Utils::FilePath m_currentFileName; QList<IndexItem::Ptr> m_itemsOfCurrentDoc; }; diff --git a/src/plugins/cppeditor/cppdoxygen_test.cpp b/src/plugins/cppeditor/cppdoxygen_test.cpp index 989c4b01cee..0b749d79063 100644 --- a/src/plugins/cppeditor/cppdoxygen_test.cpp +++ b/src/plugins/cppeditor/cppdoxygen_test.cpp @@ -21,6 +21,8 @@ using CppEditor::Tests::TemporaryDir; using CppEditor::Tests::TestCase; using CppEditor::Internal::Tests::VerifyCleanCppModelManager; +using namespace Utils; + namespace CppEditor { namespace Internal { namespace Tests { @@ -425,7 +427,7 @@ void DoxygenTest::runTest(const QByteArray &original, } // Update Code Model - QVERIFY(TestCase::parseFiles(testDocument.filePath())); + QVERIFY(TestCase::parseFiles(testDocument.filePath().toString())); // Open Editor QVERIFY(TestCase::openCppEditor(testDocument.filePath(), &testDocument.m_editor, diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp index 7aed0348ddf..a60cd9660ac 100644 --- a/src/plugins/cppeditor/cppeditordocument.cpp +++ b/src/plugins/cppeditor/cppeditordocument.cpp @@ -496,7 +496,7 @@ void CppEditorDocument::onDiagnosticsChanged(const QString &fileName, const QStr const Utils::Id category = Utils::Id::fromString(kind); for (const auto &diagnostic : mm()->diagnosticMessages()) { - if (FilePath::fromString(diagnostic.fileName()) == filePath()) { + if (diagnostic.filePath() == filePath()) { auto it = std::find_if(std::begin(removedMarks), std::end(removedMarks), [&category, &diagnostic](TextMark *existing) { diff --git a/src/plugins/cppeditor/cppfindreferences.cpp b/src/plugins/cppeditor/cppfindreferences.cpp index 5d100007b46..dc9cb0fd645 100644 --- a/src/plugins/cppeditor/cppfindreferences.cpp +++ b/src/plugins/cppeditor/cppfindreferences.cpp @@ -239,7 +239,7 @@ public: categorize(categorize) { } - QList<CPlusPlus::Usage> operator()(const Utils::FilePath &fileName) + QList<CPlusPlus::Usage> operator()(const Utils::FilePath &filePath) { QList<CPlusPlus::Usage> usages; if (future->isPaused()) @@ -248,18 +248,18 @@ public: return usages; const CPlusPlus::Identifier *symbolId = symbol->identifier(); - if (CPlusPlus::Document::Ptr previousDoc = snapshot.document(fileName)) { + if (CPlusPlus::Document::Ptr previousDoc = snapshot.document(filePath)) { CPlusPlus::Control *control = previousDoc->control(); if (!control->findIdentifier(symbolId->chars(), symbolId->size())) return usages; // skip this document, it's not using symbolId. } CPlusPlus::Document::Ptr doc; - const QByteArray unpreprocessedSource = getSource(fileName, workingCopy); + const QByteArray unpreprocessedSource = getSource(filePath, workingCopy); - if (symbolDocument && fileName == Utils::FilePath::fromString(symbolDocument->fileName())) { + if (symbolDocument && filePath == symbolDocument->filePath()) { doc = symbolDocument; } else { - doc = snapshot.preprocessedDocument(unpreprocessedSource, fileName); + doc = snapshot.preprocessedDocument(unpreprocessedSource, filePath); doc->tokenize(); } @@ -541,10 +541,9 @@ CPlusPlus::Symbol *CppFindReferences::findSymbol(const CppFindReferencesParamete CPlusPlus::Document::Ptr newSymbolDocument = snapshot.document(symbolFile); // document is not parsed and has no bindings yet, do it - QByteArray source = getSource(Utils::FilePath::fromString(newSymbolDocument->fileName()), - m_modelManager->workingCopy()); + QByteArray source = getSource(newSymbolDocument->filePath(), m_modelManager->workingCopy()); CPlusPlus::Document::Ptr doc = - snapshot.preprocessedDocument(source, FilePath::fromString(newSymbolDocument->fileName())); + snapshot.preprocessedDocument(source, newSymbolDocument->filePath()); doc->check(); // find matching symbol in new document and return the new parameters diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp index 499549638eb..7e86acfc123 100644 --- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp +++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp @@ -182,8 +182,8 @@ Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() con Link findMacroLink_helper(const QByteArray &name, Document::Ptr doc, const Snapshot &snapshot, QSet<QString> *processed) { - if (doc && !name.startsWith('<') && !processed->contains(doc->fileName())) { - processed->insert(doc->fileName()); + if (doc && !name.startsWith('<') && !processed->contains(doc->filePath().path())) { + processed->insert(doc->filePath().path()); for (const Macro ¯o : doc->definedMacros()) { if (macro.name() == name) { diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp index be78b1bffbc..c5d1b364cd3 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp @@ -198,8 +198,7 @@ void FunctionDeclDefLinkFinder::startFindLinkAt( // find the start/end offsets CppRefactoringChanges refactoringChanges(snapshot); - CppRefactoringFilePtr sourceFile = refactoringChanges.file( - Utils::FilePath::fromString(doc->fileName())); + CppRefactoringFilePtr sourceFile = refactoringChanges.file(doc->filePath()); sourceFile->setCppDocument(doc); int start, end; declDefLinkStartEnd(sourceFile, parent, funcDecl, &start, &end); diff --git a/src/plugins/cppeditor/cppincludehierarchy_test.cpp b/src/plugins/cppeditor/cppincludehierarchy_test.cpp index 1d3d69fad64..d3d0bf03976 100644 --- a/src/plugins/cppeditor/cppincludehierarchy_test.cpp +++ b/src/plugins/cppeditor/cppincludehierarchy_test.cpp @@ -17,6 +17,7 @@ #include <QtTest> using namespace CPlusPlus; +using namespace Utils; using CppEditor::Tests::TemporaryDir; @@ -56,7 +57,7 @@ public: { QVERIFY(succeededSoFar()); - QSet<QString> filePaths; + QSet<FilePath> filePaths; const int sourceListSize = sourceList.size(); TemporaryDir temporaryDir; @@ -67,14 +68,13 @@ public: // Write source to file const QString fileName = QString::fromLatin1("file%1.h").arg(i+1); - const QString absoluteFilePath = temporaryDir.createFile(fileName.toLatin1(), source); - filePaths << absoluteFilePath; + filePaths << temporaryDir.createFile(fileName.toLatin1(), source); } // Open Editor - const QString fileName = temporaryDir.path() + QLatin1String("/file1.h"); + const Utils::FilePath filePath = temporaryDir.filePath() / "file1.h"; TextEditor::BaseTextEditor *editor; - QVERIFY(openCppEditor(fileName, &editor)); + QVERIFY(openCppEditor(filePath, &editor)); closeEditorAtEndOfTestCase(editor); // Update Code Model diff --git a/src/plugins/cppeditor/cpplocatordata.cpp b/src/plugins/cppeditor/cpplocatordata.cpp index 3349011ce91..11eed8c74a8 100644 --- a/src/plugins/cppeditor/cpplocatordata.cpp +++ b/src/plugins/cppeditor/cpplocatordata.cpp @@ -25,7 +25,7 @@ void CppLocatorData::onDocumentUpdated(const CPlusPlus::Document::Ptr &document) bool isPending = false; for (int i = 0, ei = m_pendingDocuments.size(); i < ei; ++i) { const CPlusPlus::Document::Ptr &doc = m_pendingDocuments.at(i); - if (doc->fileName() == document->fileName()) { + if (doc->filePath() == document->filePath()) { isPending = true; if (document->revision() >= doc->revision()) m_pendingDocuments[i] = document; @@ -33,7 +33,7 @@ void CppLocatorData::onDocumentUpdated(const CPlusPlus::Document::Ptr &document) } } - if (!isPending && QFileInfo(document->fileName()).suffix() != "moc") + if (!isPending && document->filePath().suffix() != "moc") m_pendingDocuments.append(document); flushPendingDocument(false); @@ -50,7 +50,7 @@ void CppLocatorData::onAboutToRemoveFiles(const QStringList &files) m_infosByFile.remove(file); for (int i = 0; i < m_pendingDocuments.size(); ++i) { - if (m_pendingDocuments.at(i)->fileName() == file) { + if (m_pendingDocuments.at(i)->filePath().path() == file) { m_pendingDocuments.remove(i); break; } @@ -70,7 +70,7 @@ void CppLocatorData::flushPendingDocument(bool force) const return; for (CPlusPlus::Document::Ptr doc : std::as_const(m_pendingDocuments)) - m_infosByFile.insert(Internal::StringTable::insert(doc->fileName()), m_search(doc)); + m_infosByFile.insert(Internal::StringTable::insert(doc->filePath()), m_search(doc)); m_pendingDocuments.clear(); m_pendingDocuments.reserve(MaxPendingDocuments); diff --git a/src/plugins/cppeditor/cppmodelmanager.cpp b/src/plugins/cppeditor/cppmodelmanager.cpp index 3a066abcb4e..884e5d31755 100644 --- a/src/plugins/cppeditor/cppmodelmanager.cpp +++ b/src/plugins/cppeditor/cppmodelmanager.cpp @@ -263,10 +263,10 @@ QSet<QString> CppModelManager::timeStampModifiedFiles(const QList<Document::Ptr> const QDateTime lastModified = doc->lastModified(); if (!lastModified.isNull()) { - QFileInfo fileInfo(doc->fileName()); + const FilePath filePath = doc->filePath(); - if (fileInfo.exists() && fileInfo.lastModified() != lastModified) - sourceFiles.insert(doc->fileName()); + if (filePath.exists() && filePath.lastModified() != lastModified) + sourceFiles.insert(filePath.toString()); } } @@ -286,7 +286,7 @@ CppSourceProcessor *CppModelManager::createSourceProcessor() { CppModelManager *that = instance(); return new CppSourceProcessor(that->snapshot(), [that](const Document::Ptr &doc) { - const Document::Ptr previousDocument = that->document(doc->fileName()); + const Document::Ptr previousDocument = that->document(doc->filePath()); const unsigned newRevision = previousDocument.isNull() ? 1U : previousDocument->revision() + 1; @@ -816,10 +816,10 @@ Snapshot CppModelManager::snapshot() const return d->m_snapshot; } -Document::Ptr CppModelManager::document(const QString &fileName) const +Document::Ptr CppModelManager::document(const FilePath &filePath) const { QMutexLocker locker(&d->m_snapshotMutex); - return d->m_snapshot.document(fileName); + return d->m_snapshot.document(filePath); } /// Replace the document in the snapshot. @@ -829,7 +829,7 @@ bool CppModelManager::replaceDocument(Document::Ptr newDoc) { QMutexLocker locker(&d->m_snapshotMutex); - Document::Ptr previous = d->m_snapshot.document(newDoc->fileName()); + Document::Ptr previous = d->m_snapshot.document(newDoc->filePath()); if (previous && (newDoc->revision() != 0 && newDoc->revision() < previous->revision())) // the new document is outdated return false; @@ -1617,7 +1617,7 @@ void CppModelManager::renameIncludes(const Utils::FilePath &oldFilePath, const QList<Snapshot::IncludeLocation> locations = snapshot().includeLocationsOfDocument( isUiFile ? oldFileName : oldFilePath.toString()); for (const Snapshot::IncludeLocation &loc : locations) { - const auto filePath = FilePath::fromString(loc.first->fileName()); + const FilePath filePath = loc.first->filePath(); // Larger projects can easily have more than one ui file with the same name. // Replace only if ui file and including source file belong to the same product. diff --git a/src/plugins/cppeditor/cppmodelmanager.h b/src/plugins/cppeditor/cppmodelmanager.h index 221672d979a..5e5b19a3a1c 100644 --- a/src/plugins/cppeditor/cppmodelmanager.h +++ b/src/plugins/cppeditor/cppmodelmanager.h @@ -118,7 +118,7 @@ public: ProjectPart::ConstPtr fallbackProjectPart(); CPlusPlus::Snapshot snapshot() const override; - Document::Ptr document(const QString &fileName) const; + Document::Ptr document(const Utils::FilePath &filePath) const; bool replaceDocument(Document::Ptr newDoc); void emitDocumentUpdated(Document::Ptr doc); diff --git a/src/plugins/cppeditor/cppmodelmanager_test.cpp b/src/plugins/cppeditor/cppmodelmanager_test.cpp index 42ce1809472..ed1ac752682 100644 --- a/src/plugins/cppeditor/cppmodelmanager_test.cpp +++ b/src/plugins/cppeditor/cppmodelmanager_test.cpp @@ -33,6 +33,7 @@ QCOMPARE(document->revision(), expectedRevision); using namespace ProjectExplorer; +using namespace Utils; using CPlusPlus::Document; @@ -66,6 +67,11 @@ public: QString fileFromSourcesDir(const QString &fileName) const { return directory(_("sources")) + QLatin1Char('/') + fileName; } + + FilePath filePath(const QString &p) const + { + return FilePath::fromString(TestDataDir::file(p)); + } }; QStringList toAbsolutePaths(const QStringList &relativePathList, @@ -113,7 +119,7 @@ public: class FileChangerAndRestorer { public: - explicit FileChangerAndRestorer(const QString &filePath) + explicit FileChangerAndRestorer(const Utils::FilePath &filePath) : m_filePath(filePath) { } @@ -127,7 +133,7 @@ public: bool readContents(QByteArray *contents) { Utils::FileReader fileReader; - const bool isFetchOk = fileReader.fetch(Utils::FilePath::fromString(m_filePath)); + const bool isFetchOk = fileReader.fetch(m_filePath); if (isFetchOk) { m_originalFileContents = fileReader.data(); if (contents) @@ -148,7 +154,7 @@ private: } QByteArray m_originalFileContents; - const QString &m_filePath; + const Utils::FilePath m_filePath; }; ProjectPart::ConstPtr projectPartOfEditorDocument(const QString &filePath) @@ -216,7 +222,7 @@ void ModelManagerTest::testFrameworkHeaders() QCoreApplication::processEvents(); QVERIFY(mm->snapshot().contains(source)); - Document::Ptr doc = mm->document(source); + Document::Ptr doc = mm->document(Utils::FilePath::fromString(source)); QVERIFY(!doc.isNull()); CPlusPlus::Namespace *ns = doc->globalNamespace(); QVERIFY(ns); @@ -482,7 +488,7 @@ void ModelManagerTest::testRefreshTimeStampModifiedIfSourcefilesChange() // Modify the file QTest::qSleep(1000); // Make sure the timestamp is different - FileChangerAndRestorer fileChangerAndRestorer(fileToChange); + FileChangerAndRestorer fileChangerAndRestorer(FilePath::fromString(fileToChange)); QByteArray originalContents; QVERIFY(fileChangerAndRestorer.readContents(&originalContents)); const QByteArray newFileContentes = originalContents + "\nint addedOtherGlobal;"; @@ -762,16 +768,15 @@ void ModelManagerTest::testDefinesPerProject() for (auto &i : d) { const QString firstDeclarationName = i.firstDeclarationName; - const QString fileName = i.fileName; + const Utils::FilePath filePath = Utils::FilePath::fromString(i.fileName); - Core::IEditor *editor = Core::EditorManager::openEditor( - Utils::FilePath::fromString(fileName)); + Core::IEditor *editor = Core::EditorManager::openEditor(filePath); EditorCloser closer(editor); QVERIFY(editor); QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1); QVERIFY(mm->isCppEditor(editor)); - Document::Ptr doc = mm->document(fileName); + Document::Ptr doc = mm->document(filePath); QCOMPARE(nameOfFirstDeclaration(doc), firstDeclarationName); } } @@ -845,7 +850,7 @@ void ModelManagerTest::testPrecompiledHeaders() Utils::Language::Cxx, false}); // Check if defines from pch are considered - Document::Ptr document = mm->document(fileName); + Document::Ptr document = mm->document(Utils::FilePath::fromString(fileName)); QCOMPARE(nameOfFirstDeclaration(document), firstDeclarationName); // Check if declarations from pch are considered @@ -919,7 +924,7 @@ void ModelManagerTest::testDefinesPerEditor() parser->update({CppModelManager::instance()->workingCopy(), nullptr, Utils::Language::Cxx, false}); - Document::Ptr doc = mm->document(main1File); + Document::Ptr doc = mm->document(FilePath::fromString(main1File)); QCOMPARE(nameOfFirstDeclaration(doc), firstDeclarationName); } } @@ -1154,9 +1159,9 @@ void ModelManagerTest::testDocumentsAndRevisions() // Index two files const MyTestDataDir testDir(_("testdata_project1")); - const QString filePath1 = testDir.file(QLatin1String("foo.h")); - const QString filePath2 = testDir.file(QLatin1String("foo.cpp")); - const QSet<QString> filesToIndex = {filePath1,filePath2}; + const FilePath filePath1 = testDir.filePath(QLatin1String("foo.h")); + const FilePath filePath2 = testDir.filePath(QLatin1String("foo.cpp")); + const QSet<FilePath> filesToIndex = {filePath1,filePath2}; QVERIFY(TestCase::parseFiles(filesToIndex)); CppModelManager *modelManager = CppModelManager::instance(); @@ -1167,7 +1172,7 @@ void ModelManagerTest::testDocumentsAndRevisions() TextEditor::BaseTextEditor *editor1; QVERIFY(helper.openCppEditor(filePath1, &editor1)); helper.closeEditorAtEndOfTestCase(editor1); - QVERIFY(TestCase::waitForProcessedEditorDocument(filePath1)); + QVERIFY(TestCase::waitForProcessedEditorDocument(filePath1.toString())); VERIFY_DOCUMENT_REVISION(modelManager->document(filePath1), 2U); VERIFY_DOCUMENT_REVISION(modelManager->document(filePath2), 1U); @@ -1180,7 +1185,7 @@ void ModelManagerTest::testDocumentsAndRevisions() TextEditor::BaseTextEditor *editor2; QVERIFY(helper.openCppEditor(filePath2, &editor2)); helper.closeEditorAtEndOfTestCase(editor2); - QVERIFY(TestCase::waitForProcessedEditorDocument(filePath2)); + QVERIFY(TestCase::waitForProcessedEditorDocument(filePath2.toString())); VERIFY_DOCUMENT_REVISION(modelManager->document(filePath1), 3U); VERIFY_DOCUMENT_REVISION(modelManager->document(filePath2), 3U); diff --git a/src/plugins/cppeditor/cpppointerdeclarationformatter_test.cpp b/src/plugins/cppeditor/cpppointerdeclarationformatter_test.cpp index 06134ee3fcd..0a5f88ab9aa 100644 --- a/src/plugins/cppeditor/cpppointerdeclarationformatter_test.cpp +++ b/src/plugins/cppeditor/cpppointerdeclarationformatter_test.cpp @@ -24,6 +24,7 @@ #include <QtTest> using namespace CPlusPlus; +using namespace Utils; Q_DECLARE_METATYPE(CppEditor::Internal::Overview) @@ -63,15 +64,15 @@ public: // Write source to temprorary file CppEditor::Tests::TemporaryDir temporaryDir; QVERIFY(temporaryDir.isValid()); - const QString filePath = temporaryDir.createFile("file.h", sourceWithoutCursorMarker); + const FilePath filePath = temporaryDir.createFile("file.h", sourceWithoutCursorMarker); QVERIFY(!filePath.isEmpty()); // Preprocess source - Environment env; + CPlusPlus::Environment env; Preprocessor preprocess(nullptr, &env); const QByteArray preprocessedSource = preprocess.run(filePath, sourceWithoutCursorMarker); - Document::Ptr document = Document::create(filePath); + Document::Ptr document = Document::create(filePath.toString()); document->setUtf8Source(preprocessedSource); document->parse(parseMode); document->check(); @@ -83,9 +84,7 @@ public: QScopedPointer<TextEditor::BaseTextEditor> editor( TextEditor::PlainTextEditorFactory::createPlainTextEditor()); QString error; - editor->document()->open(&error, - Utils::FilePath::fromString(document->fileName()), - Utils::FilePath::fromString(document->fileName())); + editor->document()->open(&error, document->filePath(), document->filePath()); QVERIFY(error.isEmpty()); // Set cursor position diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index bbd192f7f74..1aaa4c8a5cb 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -25,6 +25,7 @@ using namespace Core; using namespace CPlusPlus; using namespace TextEditor; +using namespace Utils; using CppEditor::Tests::TemporaryDir; using CppEditor::Tests::Internal::TestIncludePaths; @@ -92,7 +93,7 @@ BaseQuickFixTestCase::BaseQuickFixTestCase(const QList<TestDocumentPtr> &testDoc } // Update Code Model - QSet<QString> filePaths; + QSet<FilePath> filePaths; for (const TestDocumentPtr &document : std::as_const(m_testDocuments)) filePaths << document->filePath(); QVERIFY(parseFiles(filePaths)); @@ -150,7 +151,7 @@ BaseQuickFixTestCase::~BaseQuickFixTestCase() // Remove created files from file system for (const TestDocumentPtr &testDocument : std::as_const(m_testDocuments)) - QVERIFY(QFile::remove(testDocument->filePath())); + QVERIFY(testDocument->filePath().removeFile()); } /// Leading whitespace is not removed, so we can check if the indetation ranges diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 0c33c377332..33819ec4455 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -80,7 +80,7 @@ using namespace CPlusPlus; using namespace TextEditor; -using Utils::ChangeSet; +using namespace Utils; namespace CppEditor { @@ -2056,7 +2056,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa QString className; QList<Core::LocatorFilterEntry> matches; - const QString currentDocumentFilePath = interface.semanticInfo().doc->fileName(); + const QString currentDocumentFilePath = interface.semanticInfo().doc->filePath().toString(); const ProjectExplorer::HeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath); QList<Utils::FilePath> headers; @@ -2530,7 +2530,7 @@ public: const QString &targetFileName, const Class *targetSymbol, InsertionPointLocator::AccessSpec xsSpec, const QString &decl, int priority) : CppQuickFixOperation(interface, priority) - , m_targetFileName(targetFileName) + , m_targetFileName(FilePath::fromString(targetFileName)) , m_targetSymbol(targetSymbol) , m_xsSpec(xsSpec) , m_decl(decl) @@ -2549,8 +2549,7 @@ public: m_targetFileName, m_targetSymbol, m_xsSpec); QTC_ASSERT(loc.isValid(), return); - CppRefactoringFilePtr targetFile = refactoring.file( - Utils::FilePath::fromString(m_targetFileName)); + CppRefactoringFilePtr targetFile = refactoring.file(m_targetFileName); int targetPosition1 = targetFile->position(loc.line(), loc.column()); int targetPosition2 = qMax(0, targetFile->position(loc.line(), 1) - 1); @@ -2565,7 +2564,7 @@ public: static QString generateDeclaration(const Function *function); private: - QString m_targetFileName; + FilePath m_targetFileName; const Class *m_targetSymbol; InsertionPointLocator::AccessSpec m_xsSpec; QString m_decl; @@ -2985,12 +2984,12 @@ private: const CppRefactoringChanges refactoring(snapshot()); const InsertionPointLocator locator(refactoring); - const QString filePath = QString::fromUtf8(m_class->fileName()); + const FilePath filePath = FilePath::fromUtf8(m_class->fileName()); const InsertionLocation loc = locator.methodDeclarationInClass( filePath, m_class, InsertionPointLocator::Private); QTC_ASSERT(loc.isValid(), return); - CppRefactoringFilePtr targetFile = refactoring.file(Utils::FilePath::fromString(filePath)); + CppRefactoringFilePtr targetFile = refactoring.file(filePath); const int targetPosition1 = targetFile->position(loc.line(), loc.column()); const int targetPosition2 = qMax(0, targetFile->position(loc.line(), 1) - 1); ChangeSet target; @@ -3633,7 +3632,7 @@ protected: if (insertionPoint != m_headerInsertionPoints.end()) return *insertionPoint; const InsertionLocation loc = m_locator.methodDeclarationInClass( - m_headerFile->filePath().toString(), m_class, spec, + m_headerFile->filePath(), m_class, spec, InsertionPointLocator::ForceAccessSpec::Yes); m_headerInsertionPoints.insert(spec, loc); return loc; @@ -4943,10 +4942,10 @@ public: // Write declaration, if necessary. if (matchingClass) { InsertionPointLocator locator(refactoring); - const QString fileName = QLatin1String(matchingClass->fileName()); + const FilePath filePath = FilePath::fromUtf8(matchingClass->fileName()); const InsertionLocation &location = - locator.methodDeclarationInClass(fileName, matchingClass, options.access); - CppRefactoringFilePtr declFile = refactoring.file(Utils::FilePath::fromString(fileName)); + locator.methodDeclarationInClass(filePath, matchingClass, options.access); + CppRefactoringFilePtr declFile = refactoring.file(filePath); change.clear(); position = declFile->position(location.line(), location.column()); change.insert(position, location.prefix() + funcDecl + location.suffix()); @@ -8081,8 +8080,7 @@ private: while (!nodesWithProcessedParents.empty()) { Node &node = nodesWithProcessedParents.back(); nodesWithProcessedParents.pop_back(); - CppRefactoringFilePtr file = refactoring.file( - Utils::FilePath::fromString(node.document->fileName())); + CppRefactoringFilePtr file = refactoring.file(node.document->filePath()); const bool parentHasUsing = Utils::anyOf(node.includes, &Node::hasGlobalUsingDirective); const int startPos = parentHasUsing ? 0 @@ -8154,14 +8152,13 @@ private: if (m_processed.contains(loc.first)) continue; - CppRefactoringFilePtr file = refactoring.file( - Utils::FilePath::fromString(loc.first->fileName())); + CppRefactoringFilePtr file = refactoring.file(loc.first->filePath()); const bool noGlobalUsing = refactorFile(file, refactoring.snapshot(), file->position(loc.second, 1)); m_processed.insert(loc.first); if (noGlobalUsing) - processIncludes(refactoring, loc.first->fileName()); + processIncludes(refactoring, loc.first->filePath().toString()); } } diff --git a/src/plugins/cppeditor/cppsemanticinfoupdater.cpp b/src/plugins/cppeditor/cppsemanticinfoupdater.cpp index 12ee180b5c0..7d4aca6f9bf 100644 --- a/src/plugins/cppeditor/cppsemanticinfoupdater.cpp +++ b/src/plugins/cppeditor/cppsemanticinfoupdater.cpp @@ -121,7 +121,7 @@ bool SemanticInfoUpdaterPrivate::reuseCurrentSemanticInfo(const SemanticInfo::So && currentSemanticInfo.revision == source.revision && currentSemanticInfo.doc && currentSemanticInfo.doc->translationUnit()->ast() - && currentSemanticInfo.doc->fileName() == source.fileName + && currentSemanticInfo.doc->filePath().toString() == source.fileName && !currentSemanticInfo.snapshot.isEmpty() && currentSemanticInfo.snapshot == source.snapshot) { SemanticInfo newSemanticInfo; diff --git a/src/plugins/cppeditor/cppsourceprocessor.cpp b/src/plugins/cppeditor/cppsourceprocessor.cpp index 35cea8f1427..3f1d18c0896 100644 --- a/src/plugins/cppeditor/cppsourceprocessor.cpp +++ b/src/plugins/cppeditor/cppsourceprocessor.cpp @@ -66,7 +66,7 @@ inline Message messageNoSuchFile(Document::Ptr &document, const QString &fileNam { const QString text = QCoreApplication::translate( "CppSourceProcessor", "%1: No such file or directory").arg(fileName); - return Message(Message::Warning, document->fileName(), line, /*column =*/ 0, text); + return Message(Message::Warning, document->filePath(), line, /*column =*/ 0, text); } inline Message messageNoFileContents(Document::Ptr &document, const QString &fileName, @@ -74,7 +74,7 @@ inline Message messageNoFileContents(Document::Ptr &document, const QString &fil { const QString text = QCoreApplication::translate( "CppSourceProcessor", "%1: Could not get file contents").arg(fileName); - return Message(Message::Warning, document->fileName(), line, /*column =*/ 0, text); + return Message(Message::Warning, document->filePath(), line, /*column =*/ 0, text); } inline const CPlusPlus::Macro revision(const WorkingCopy &workingCopy, @@ -244,7 +244,7 @@ QString CppSourceProcessor::resolveFile(const QString &fileName, IncludeType typ if (m_currentDoc) { if (type == IncludeLocal) { - const QFileInfo currentFileInfo(m_currentDoc->fileName()); + const QFileInfo currentFileInfo = m_currentDoc->filePath().toFileInfo(); const QString path = cleanPath(currentFileInfo.absolutePath()) + fileName; if (checkFile(path)) return path; @@ -252,7 +252,7 @@ QString CppSourceProcessor::resolveFile(const QString &fileName, IncludeType typ // searching as if this would be a global include. } else if (type == IncludeNext) { - const QFileInfo currentFileInfo(m_currentDoc->fileName()); + const QFileInfo currentFileInfo = m_currentDoc->filePath().toFileInfo(); const QString currentDirPath = cleanPath(currentFileInfo.dir().path()); auto headerPathsEnd = m_headerPaths.end(); auto headerPathsIt = m_headerPaths.begin(); @@ -372,7 +372,7 @@ void CppSourceProcessor::mergeEnvironment(Document::Ptr doc) if (!doc) return; - const QString fn = doc->fileName(); + const QString fn = doc->filePath().path(); if (m_processed.contains(fn)) return; @@ -457,7 +457,8 @@ void CppSourceProcessor::sourceNeeded(int line, const QString &fileName, Include document->setLastModified(info.lastModified()); const Document::Ptr previousDocument = switchCurrentDocument(document); - const QByteArray preprocessedCode = m_preprocess.run(absoluteFileName, contents); + const QByteArray preprocessedCode = + m_preprocess.run(Utils::FilePath::fromString(absoluteFileName), contents); // { // QByteArray b(preprocessedCode); b.replace("\n", "<<<\n"); // qDebug("Preprocessed code for \"%s\": [[%s]]", fileName.toUtf8().constData(), b.constData()); @@ -478,7 +479,7 @@ void CppSourceProcessor::sourceNeeded(int line, const QString &fileName, Include document->setUtf8Source(preprocessedCode); document->keepSourceAndAST(); document->tokenize(); - document->check(m_workingCopy.contains(document->fileName()) ? Document::FullCheck + document->check(m_workingCopy.contains(document->filePath()) ? Document::FullCheck : Document::FastCheck); m_documentFinished(document); diff --git a/src/plugins/cppeditor/cppsourceprocessor_test.cpp b/src/plugins/cppeditor/cppsourceprocessor_test.cpp index e4c30f97c11..58e0fdf630c 100644 --- a/src/plugins/cppeditor/cppsourceprocessor_test.cpp +++ b/src/plugins/cppeditor/cppsourceprocessor_test.cpp @@ -21,7 +21,8 @@ #include <QtTest> using namespace CPlusPlus; -using ProjectExplorer::HeaderPathType; +using namespace ProjectExplorer; +using namespace Utils; using Include = Document::Include; using CppEditor::Tests::TestCase; @@ -46,7 +47,7 @@ public: TestIncludePaths::directoryOfTestFile())}); sourceProcessor->run(filePath); - Document::Ptr document = m_cmm->document(filePath); + Document::Ptr document = m_cmm->document(Utils::FilePath::fromString(filePath)); return document; } @@ -96,7 +97,8 @@ void SourceProcessorTest::testIncludesCyclic() { const QString fileName1 = TestIncludePaths::testFilePath(QLatin1String("cyclic1.h")); const QString fileName2 = TestIncludePaths::testFilePath(QLatin1String("cyclic2.h")); - const QSet<QString> sourceFiles = {fileName1, fileName2}; + const QSet<FilePath> sourceFiles = {FilePath::fromString(fileName1), + FilePath::fromString(fileName2)}; // Create global snapshot (needed in BuiltinEditorDocumentParser) TestCase testCase; @@ -104,7 +106,7 @@ void SourceProcessorTest::testIncludesCyclic() // Open editor TextEditor::BaseTextEditor *editor; - QVERIFY(testCase.openCppEditor(fileName1, &editor)); + QVERIFY(testCase.openCppEditor(FilePath::fromString(fileName1), &editor)); testCase.closeEditorAtEndOfTestCase(editor); // Check editor snapshot @@ -165,7 +167,7 @@ void SourceProcessorTest::testMacroUses() static bool isMacroDefinedInDocument(const QByteArray ¯oName, const Document::Ptr &document) { - for (const Macro ¯o : document->definedMacros()) { + for (const CPlusPlus::Macro ¯o : document->definedMacros()) { if (macro.name() == macroName) return true; } diff --git a/src/plugins/cppeditor/cpptoolstestcase.cpp b/src/plugins/cppeditor/cpptoolstestcase.cpp index 2d83897e96d..2633e41ffbe 100644 --- a/src/plugins/cppeditor/cpptoolstestcase.cpp +++ b/src/plugins/cppeditor/cpptoolstestcase.cpp @@ -84,15 +84,15 @@ TestDocumentPtr CppTestDocument::create(const QByteArray &fileName, const QByteA return doc; } -QString CppTestDocument::filePath() const +FilePath CppTestDocument::filePath() const { if (!m_baseDirectory.isEmpty()) - return QDir::cleanPath(m_baseDirectory + QLatin1Char('/') + m_fileName); + return FilePath::fromString(QDir::cleanPath(m_baseDirectory + '/' + m_fileName)); if (!QFileInfo(m_fileName).isAbsolute()) - return Utils::TemporaryDirectory::masterDirectoryPath() + '/' + m_fileName; + return FilePath::fromString(TemporaryDirectory::masterDirectoryPath() + '/' + m_fileName); - return m_fileName; + return FilePath::fromString(m_fileName); } bool CppTestDocument::writeToDisk() const @@ -212,11 +212,11 @@ bool TestCase::succeededSoFar() const return m_succeededSoFar; } -bool TestCase::openCppEditor(const QString &fileName, TextEditor::BaseTextEditor **editor, +bool TestCase::openCppEditor(const FilePath &filePath, TextEditor::BaseTextEditor **editor, CppEditorWidget **editorWidget) { if (const auto e = dynamic_cast<TextEditor::BaseTextEditor *>( - Core::EditorManager::openEditor(FilePath::fromString(fileName)))) { + Core::EditorManager::openEditor(filePath))) { if (editor) { *editor = e; TextEditor::StorageSettings s = e->textDocument()->storageSettings(); @@ -281,16 +281,17 @@ CPlusPlus::Document::Ptr TestCase::waitForRehighlightedSemanticDocument(CppEdito return editorWidget->semanticInfo().doc; } -bool TestCase::parseFiles(const QSet<QString> &filePaths) +bool TestCase::parseFiles(const QSet<FilePath> &filePaths) { - CppModelManager::instance()->updateSourceFiles(filePaths).waitForFinished(); + QSet<QString> filePaths_ = transform(filePaths, &FilePath::toString); + CppModelManager::instance()->updateSourceFiles(filePaths_).waitForFinished(); QCoreApplication::processEvents(); const CPlusPlus::Snapshot snapshot = globalSnapshot(); if (snapshot.isEmpty()) { qWarning("After parsing: snapshot is empty."); return false; } - if (!snapshotContains(snapshot, filePaths)) { + if (!snapshotContains(snapshot, filePaths_)) { qWarning("After parsing: snapshot does not contain all expected files."); return false; } @@ -299,7 +300,7 @@ bool TestCase::parseFiles(const QSet<QString> &filePaths) bool TestCase::parseFiles(const QString &filePath) { - return parseFiles(QSet<QString>{filePath}); + return parseFiles({FilePath::fromString(filePath)}); } void TestCase::closeEditorAtEndOfTestCase(Core::IEditor *editor) @@ -355,11 +356,11 @@ bool TestCase::waitUntilProjectIsFullyOpened(Project *project, int timeOutInMs) timeOutInMs); } -bool TestCase::writeFile(const QString &filePath, const QByteArray &contents) +bool TestCase::writeFile(const FilePath &filePath, const QByteArray &contents) { - Utils::FileSaver saver(Utils::FilePath::fromString(filePath)); + Utils::FileSaver saver(filePath); if (!saver.write(contents) || !saver.finalize()) { - qWarning() << "Failed to write file to disk:" << qPrintable(filePath); + qWarning() << "Failed to write file to disk:" << qPrintable(filePath.toUserOutput()); return false; } return true; @@ -419,15 +420,15 @@ TemporaryDir::TemporaryDir() { } -QString TemporaryDir::createFile(const QByteArray &relativePath, const QByteArray &contents) +FilePath TemporaryDir::createFile(const QByteArray &relativePath, const QByteArray &contents) { const QString relativePathString = QString::fromUtf8(relativePath); if (relativePathString.isEmpty() || QFileInfo(relativePathString).isAbsolute()) - return QString(); + return {}; - const QString filePath = m_temporaryDir.filePath(relativePathString).path(); + const FilePath filePath = m_temporaryDir.filePath(relativePathString); if (!TestCase::writeFile(filePath, contents)) - return QString(); + return {}; return filePath; } diff --git a/src/plugins/cppeditor/cpptoolstestcase.h b/src/plugins/cppeditor/cpptoolstestcase.h index 600075463d1..53284f38be2 100644 --- a/src/plugins/cppeditor/cpptoolstestcase.h +++ b/src/plugins/cppeditor/cpptoolstestcase.h @@ -60,7 +60,7 @@ public: QString baseDirectory() const { return m_baseDirectory; } void setBaseDirectory(const QString &baseDirectory) { m_baseDirectory = baseDirectory; } - QString filePath() const; + Utils::FilePath filePath() const; bool writeToDisk() const; bool hasCursorMarker() const { return m_cursorPosition != -1; } @@ -123,14 +123,14 @@ public: ~TestCase(); bool succeededSoFar() const; - static bool openCppEditor(const QString &fileName, TextEditor::BaseTextEditor **editor, + static bool openCppEditor(const Utils::FilePath &filePath, TextEditor::BaseTextEditor **editor, CppEditorWidget **editorWidget = nullptr); void closeEditorAtEndOfTestCase(Core::IEditor *editor); static bool closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *editor); static bool parseFiles(const QString &filePath); - static bool parseFiles(const QSet<QString> &filePaths); + static bool parseFiles(const QSet<Utils::FilePath> &filePaths); static CPlusPlus::Snapshot globalSnapshot(); static bool garbageCollectGlobalSnapshot(); @@ -149,7 +149,7 @@ public: const QStringList &filePaths, int timeOutInMs = defaultTimeOutInMs); - static bool writeFile(const QString &filePath, const QByteArray &contents); + static bool writeFile(const Utils::FilePath &filePath, const QByteArray &contents); protected: CppModelManager *m_modelManager; @@ -184,8 +184,9 @@ public: bool isValid() const { return m_isValid; } QString path() const { return m_temporaryDir.path().path(); } + Utils::FilePath filePath() const { return m_temporaryDir.path(); } - QString createFile(const QByteArray &relativePath, const QByteArray &contents); + Utils::FilePath createFile(const QByteArray &relativePath, const QByteArray &contents); protected: Utils::TemporaryDirectory m_temporaryDir; diff --git a/src/plugins/cppeditor/fileandtokenactions_test.cpp b/src/plugins/cppeditor/fileandtokenactions_test.cpp index 0b781168bdc..c5602c5f678 100644 --- a/src/plugins/cppeditor/fileandtokenactions_test.cpp +++ b/src/plugins/cppeditor/fileandtokenactions_test.cpp @@ -51,6 +51,7 @@ using namespace Core; using namespace CPlusPlus; using namespace TextEditor; +using namespace Utils; namespace CppEditor::Internal::Tests { @@ -158,7 +159,7 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti QCOMPARE(DocumentModel::openedDocuments().size(), 0); BaseTextEditor *editor; CppEditorWidget *editorWidget; - QVERIFY(openCppEditor(filePath, &editor, &editorWidget)); + QVERIFY(openCppEditor(FilePath::fromString(filePath), &editor, &editorWidget)); QCOMPARE(DocumentModel::openedDocuments().size(), 1); QVERIFY(m_modelManager->isCppEditor(editor)); diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 38cd0cdebcf..c15995504eb 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -62,6 +62,7 @@ using namespace CPlusPlus; using namespace TextEditor; using namespace Core; using namespace ProjectExplorer; +using namespace Utils; class OverrideItem { @@ -256,7 +257,8 @@ F2TestCase::F2TestCase(CppEditorAction action, QVERIFY(testFile->baseDirectory().isEmpty()); testFile->setBaseDirectory(temporaryDir.path()); QVERIFY(testFile->writeToDisk()); - projectFileContent += QString::fromLatin1("\"%1\",").arg(testFile->filePath()); + projectFileContent += QString::fromLatin1("\"%1\",") + .arg(testFile->filePath().toString()); } projectFileContent += "]}\n"; @@ -272,9 +274,7 @@ F2TestCase::F2TestCase(CppEditorAction action, CppTestDocument projectFile("project.qbs", projectFileContent.toUtf8()); projectFile.setBaseDirectory(temporaryDir.path()); QVERIFY(projectFile.writeToDisk()); - const auto openProjectResult = - ProjectExplorerPlugin::openProject( - Utils::FilePath::fromString(projectFile.filePath())); + const auto openProjectResult = ProjectExplorerPlugin::openProject(projectFile.filePath()); QVERIFY2(openProjectResult && openProjectResult.project(), qPrintable(openProjectResult.errorMessage())); projectCloser.setProject(openProjectResult.project()); @@ -286,7 +286,7 @@ F2TestCase::F2TestCase(CppEditorAction action, } // Update Code Model - QSet<QString> filePaths; + QSet<FilePath> filePaths; for (const TestDocumentPtr &testFile : testFiles) filePaths << testFile->filePath(); QVERIFY(parseFiles(filePaths)); @@ -302,7 +302,8 @@ F2TestCase::F2TestCase(CppEditorAction action, // The file is "Full Checked" since it is in the working copy now, // that is the function bodies are processed. forever { - const Document::Ptr document = waitForFileInGlobalSnapshot(testFile->filePath()); + const Document::Ptr document = + waitForFileInGlobalSnapshot(testFile->filePath().toString()); QVERIFY(document); if (document->checkMode() == Document::FullCheck) { if (!document->diagnosticMessages().isEmpty()) @@ -405,7 +406,7 @@ F2TestCase::F2TestCase(CppEditorAction action, BaseTextEditor *currentTextEditor = dynamic_cast<BaseTextEditor*>(currentEditor); QVERIFY(currentTextEditor); - QCOMPARE(currentTextEditor->document()->filePath().toString(), targetTestFile->filePath()); + QCOMPARE(currentTextEditor->document()->filePath(), targetTestFile->filePath()); int expectedLine, expectedColumn; if (useClangd && expectedVirtualFunctionProposal.size() == 1) { expectedLine = expectedVirtualFunctionProposal.first().line; diff --git a/src/plugins/cppeditor/includeutils.cpp b/src/plugins/cppeditor/includeutils.cpp index cf855f154f8..f79bb8db127 100644 --- a/src/plugins/cppeditor/includeutils.cpp +++ b/src/plugins/cppeditor/includeutils.cpp @@ -518,7 +518,7 @@ static QList<Include> includesForSource(const QString &filePath) TestIncludePaths::globalIncludePath())}); sourceProcessor->run(filePath); - Document::Ptr document = cmm->document(filePath); + Document::Ptr document = cmm->document(FilePath::fromString(filePath)); return document->resolvedIncludes(); } diff --git a/src/plugins/cppeditor/insertionpointlocator.cpp b/src/plugins/cppeditor/insertionpointlocator.cpp index 4479246f611..a0aa777cc64 100644 --- a/src/plugins/cppeditor/insertionpointlocator.cpp +++ b/src/plugins/cppeditor/insertionpointlocator.cpp @@ -251,13 +251,12 @@ InsertionPointLocator::InsertionPointLocator(const CppRefactoringChanges &refact } InsertionLocation InsertionPointLocator::methodDeclarationInClass( - const QString &fileName, + const Utils::FilePath &filePath, const Class *clazz, AccessSpec xsSpec, ForceAccessSpec forceAccessSpec) const { - const Document::Ptr doc = m_refactoringChanges.file(Utils::FilePath::fromString(fileName)) - ->cppDocument(); + const Document::Ptr doc = m_refactoringChanges.file(filePath)->cppDocument(); if (doc) { FindInClass find(doc->translationUnit(), clazz); ClassSpecifierAST *classAST = find(); diff --git a/src/plugins/cppeditor/insertionpointlocator.h b/src/plugins/cppeditor/insertionpointlocator.h index b9133e67e20..8dc5f561a70 100644 --- a/src/plugins/cppeditor/insertionpointlocator.h +++ b/src/plugins/cppeditor/insertionpointlocator.h @@ -80,8 +80,7 @@ public: public: explicit InsertionPointLocator(const CppRefactoringChanges &refactoringChanges); - InsertionLocation methodDeclarationInClass( - const QString &fileName, + InsertionLocation methodDeclarationInClass(const Utils::FilePath &fileName, const CPlusPlus::Class *clazz, AccessSpec xsSpec, ForceAccessSpec forceAccessSpec = ForceAccessSpec::No diff --git a/src/plugins/cppeditor/searchsymbols.cpp b/src/plugins/cppeditor/searchsymbols.cpp index 0fa87c4b11b..6eb143a276c 100644 --- a/src/plugins/cppeditor/searchsymbols.cpp +++ b/src/plugins/cppeditor/searchsymbols.cpp @@ -37,7 +37,7 @@ void SearchSymbols::setSymbolsToSearchFor(const SymbolTypes &types) IndexItem::Ptr SearchSymbols::operator()(Document::Ptr doc, const QString &scope) { - IndexItem::Ptr root = IndexItem::create(Internal::StringTable::insert(doc->fileName()), 100); + IndexItem::Ptr root = IndexItem::create(Internal::StringTable::insert(doc->filePath()), 100); { // RAII scope ScopedIndexItemPtr parentRaii(_parent, root); @@ -46,7 +46,7 @@ IndexItem::Ptr SearchSymbols::operator()(Document::Ptr doc, const QString &scope QTC_ASSERT(_parent, return IndexItem::Ptr()); QTC_ASSERT(root, return IndexItem::Ptr()); - QTC_ASSERT(_parent->fileName() == Internal::StringTable::insert(doc->fileName()), + QTC_ASSERT(_parent->fileName() == Internal::StringTable::insert(doc->filePath()), return IndexItem::Ptr()); for (int i = 0, ei = doc->globalSymbolCount(); i != ei; ++i) diff --git a/src/plugins/cppeditor/stringtable.cpp b/src/plugins/cppeditor/stringtable.cpp index 6f0ef89b18a..64f324ad36f 100644 --- a/src/plugins/cppeditor/stringtable.cpp +++ b/src/plugins/cppeditor/stringtable.cpp @@ -56,6 +56,11 @@ StringTablePrivate::StringTablePrivate() connect(&m_gcCountDown, &QTimer::timeout, this, &StringTablePrivate::startGC); } +QString StringTable::insert(const Utils::FilePath &path) +{ + return m_instance->insert(path.path()); +} + QString StringTable::insert(const QString &string) { return m_instance->insert(string); diff --git a/src/plugins/cppeditor/stringtable.h b/src/plugins/cppeditor/stringtable.h index d24d77c02e0..675d3f6539b 100644 --- a/src/plugins/cppeditor/stringtable.h +++ b/src/plugins/cppeditor/stringtable.h @@ -3,13 +3,14 @@ #pragma once -#include <QString> +#include <utils/filepath.h> namespace CppEditor::Internal { class StringTable { public: + static QString insert(const Utils::FilePath &string); static QString insert(const QString &string); static void scheduleGC(); diff --git a/src/plugins/cppeditor/symbolfinder.cpp b/src/plugins/cppeditor/symbolfinder.cpp index df93d36246d..484dfd6e1b2 100644 --- a/src/plugins/cppeditor/symbolfinder.cpp +++ b/src/plugins/cppeditor/symbolfinder.cpp @@ -444,7 +444,7 @@ QStringList SymbolFinder::fileIterationOrder(const QString &referenceFile, const checkCacheConsistency(referenceFile, snapshot); } else { for (Document::Ptr doc : snapshot) - insertCache(referenceFile, doc->fileName()); + insertCache(referenceFile, doc->filePath().path()); } QStringList files = m_filePriorityCache.value(referenceFile).toStringList(); @@ -468,8 +468,8 @@ void SymbolFinder::checkCacheConsistency(const QString &referenceFile, const Sna // corresponding document and notices it's now null. const QSet<QString> &meta = m_fileMetaCache.value(referenceFile); for (const Document::Ptr &doc : snapshot) { - if (!meta.contains(doc->fileName())) - insertCache(referenceFile, doc->fileName()); + if (!meta.contains(doc->filePath().path())) + insertCache(referenceFile, doc->filePath().path()); } } diff --git a/src/plugins/cppeditor/typehierarchybuilder_test.cpp b/src/plugins/cppeditor/typehierarchybuilder_test.cpp index c1509df12f6..095aba97eaf 100644 --- a/src/plugins/cppeditor/typehierarchybuilder_test.cpp +++ b/src/plugins/cppeditor/typehierarchybuilder_test.cpp @@ -16,6 +16,8 @@ #include <QtTest> using namespace CPlusPlus; +using namespace Utils; + using CppEditor::Internal::Tests::CppTestDocument; Q_DECLARE_METATYPE(QList<CppTestDocument>) @@ -82,7 +84,7 @@ public: QList<CppTestDocument> documents_ = documents; // Write files - QSet<QString> filePaths; + QSet<FilePath> filePaths; for (auto &document : documents_) { document.setBaseDirectory(temporaryDir.path()); QVERIFY(document.writeToDisk()); diff --git a/src/plugins/designer/qtcreatorintegration.cpp b/src/plugins/designer/qtcreatorintegration.cpp index e889e212222..e3c0cc4e067 100644 --- a/src/plugins/designer/qtcreatorintegration.cpp +++ b/src/plugins/designer/qtcreatorintegration.cpp @@ -52,7 +52,7 @@ static QString msgClassNotFound(const QString &uiClassName, const QList<Document QString files; for (const Document::Ptr &doc : docList) { files += '\n'; - files += QDir::toNativeSeparators(doc->fileName()); + files += doc->filePath().toUserOutput(); } return Designer::Tr::tr( "The class containing \"%1\" could not be found in %2.\n" @@ -241,7 +241,7 @@ static void addDeclaration(const Snapshot &snapshot, CppEditor::CppRefactoringChanges refactoring(snapshot); CppEditor::InsertionPointLocator find(refactoring); const CppEditor::InsertionLocation loc = find.methodDeclarationInClass( - fileName, cl, CppEditor::InsertionPointLocator::PrivateSlot); + FilePath::fromString(fileName), cl, CppEditor::InsertionPointLocator::PrivateSlot); // //! \todo change this to use the Refactoring changes. @@ -339,7 +339,7 @@ static ClassDocumentPtrPair const Document::Ptr doc = context.thisDocument(); const Snapshot docTable = context.snapshot(); if (Designer::Constants::Internal::debug) - qDebug() << Q_FUNC_INFO << doc->fileName() << className << maxIncludeDepth; + qDebug() << Q_FUNC_INFO << doc->filePath() << className << maxIncludeDepth; // Check document if (const Class *cl = findClass(doc->globalNamespace(), context, className)) return ClassDocumentPtrPair(cl, doc); @@ -455,8 +455,8 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName, const QList<Document::Ptr> docList = findDocumentsIncluding(docTable, uicedName, true); // change to false when we know the absolute path to generated ui_<>.h file DocumentMap docMap; for (const Document::Ptr &d : docList) { - const QFileInfo docFi(d->fileName()); - docMap.insert(qAbs(docFi.absolutePath().compare(uiFolder, Qt::CaseInsensitive)), d); + docMap.insert(qAbs(d->filePath().absolutePath().toString() + .compare(uiFolder, Qt::CaseInsensitive)), d); } if (Designer::Constants::Internal::debug) @@ -501,14 +501,14 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName, const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames); if (Designer::Constants::Internal::debug) - qDebug() << Q_FUNC_INFO << "Found " << uiClass << declDoc->fileName() << " checking " << functionName << functionNameWithParameterNames; + qDebug() << Q_FUNC_INFO << "Found " << uiClass << declDoc->filePath() << " checking " << functionName << functionNameWithParameterNames; Function *fun = findDeclaration(cl, functionName); QString declFilePath; if (!fun) { // add function declaration to cl CppEditor::WorkingCopy workingCopy = CppEditor::CppModelManager::instance()->workingCopy(); - declFilePath = declDoc->fileName(); + declFilePath = declDoc->filePath().toString(); getParsedDocument(declFilePath, workingCopy, docTable); addDeclaration(docTable, declFilePath, cl, functionNameWithParameterNames); diff --git a/src/plugins/todo/cpptodoitemsscanner.cpp b/src/plugins/todo/cpptodoitemsscanner.cpp index 47a020ff4fc..3a8db09456f 100644 --- a/src/plugins/todo/cpptodoitemsscanner.cpp +++ b/src/plugins/todo/cpptodoitemsscanner.cpp @@ -46,7 +46,7 @@ void CppTodoItemsScanner::scannerParamsChanged() void CppTodoItemsScanner::documentUpdated(CPlusPlus::Document::Ptr doc) { CppEditor::CppModelManager *modelManager = CppEditor::CppModelManager::instance(); - if (!modelManager->projectPart(doc->fileName()).isEmpty()) + if (!modelManager->projectPart(doc->filePath()).isEmpty()) processDocument(doc); } @@ -84,13 +84,13 @@ void CppTodoItemsScanner::processDocument(CPlusPlus::Document::Ptr doc) const int length = end - start + 1; if (length > 0) { QString commentLine = QString::fromUtf8(start, length); - processCommentLine(doc->fileName(), commentLine, lineNumber, itemList); + processCommentLine(doc->filePath().toString(), commentLine, lineNumber, itemList); } from = to + 1; } } - emit itemsFetched(doc->fileName(), itemList); + emit itemsFetched(doc->filePath().toString(), itemList); } } |