diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index 7cd1259f25c..47c53628caa 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -375,7 +375,7 @@ void AutotestPluginPrivate::onRunUnderCursorTriggered(TestRunMode mode) // check whether we have been triggered on a test function definition const int line = currentEditor->currentLine(); - const QString &filePath = currentEditor->textDocument()->filePath().toString(); + const Utils::FilePath &filePath = currentEditor->textDocument()->filePath(); const QList filteredItems = Utils::filtered(testsItems, [&](ITestTreeItem *it){ return it->line() == line && it->filePath() == filePath; }); diff --git a/src/plugins/autotest/boost/boosttestframework.cpp b/src/plugins/autotest/boost/boosttestframework.cpp index 6f8ac0192fb..74a7880c988 100644 --- a/src/plugins/autotest/boost/boosttestframework.cpp +++ b/src/plugins/autotest/boost/boosttestframework.cpp @@ -43,7 +43,7 @@ ITestTreeItem *BoostTestFramework::createRootNode() this, QCoreApplication::translate("BoostTestFramework", BoostTest::Constants::FRAMEWORK_SETTINGS_CATEGORY), - QString(), ITestTreeItem::Root); + Utils::FilePath(), ITestTreeItem::Root); } const char *BoostTestFramework::name() const diff --git a/src/plugins/autotest/boost/boosttestoutputreader.cpp b/src/plugins/autotest/boost/boosttestoutputreader.cpp index 7338c6a6609..5036a683ff3 100644 --- a/src/plugins/autotest/boost/boosttestoutputreader.cpp +++ b/src/plugins/autotest/boost/boosttestoutputreader.cpp @@ -40,15 +40,10 @@ namespace Internal { static Q_LOGGING_CATEGORY(orLog, "qtc.autotest.boost.outputreader", QtWarningMsg) -static QString constructSourceFilePath(const QString &path, const QString &filePath) -{ - return QFileInfo(path, filePath).canonicalFilePath(); -} - BoostTestOutputReader::BoostTestOutputReader(const QFutureInterface &futureInterface, QProcess *testApplication, - const QString &buildDirectory, - const QString &projectFile, + const Utils::FilePath &buildDirectory, + const Utils::FilePath &projectFile, LogLevel log, ReportLevel report) : TestOutputReader(futureInterface, testApplication, buildDirectory) , m_projectFile(projectFile) diff --git a/src/plugins/autotest/boost/boosttestoutputreader.h b/src/plugins/autotest/boost/boosttestoutputreader.h index 4d109ecd45a..56527fa6271 100644 --- a/src/plugins/autotest/boost/boosttestoutputreader.h +++ b/src/plugins/autotest/boost/boosttestoutputreader.h @@ -39,8 +39,8 @@ class BoostTestOutputReader : public TestOutputReader Q_OBJECT public: BoostTestOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory, - const QString &projectFile, LogLevel log, ReportLevel report); + QProcess *testApplication, const Utils::FilePath &buildDirectory, + const Utils::FilePath &projectFile, LogLevel log, ReportLevel report); protected: void processOutputLine(const QByteArray &outputLine) override; void processStdError(const QByteArray &outputLine) override; @@ -51,12 +51,12 @@ private: void sendCompleteInformation(); void handleMessageMatch(const QRegularExpressionMatch &match); void reportNoOutputFinish(const QString &description, ResultType type); - QString m_projectFile; + Utils::FilePath m_projectFile; QString m_currentModule; QString m_currentSuite; QString m_currentTest; QString m_description; - QString m_fileName; + Utils::FilePath m_fileName; ResultType m_result = ResultType::Invalid; int m_lineNumber = 0; int m_testCaseCount = -1; diff --git a/src/plugins/autotest/boost/boosttestparser.cpp b/src/plugins/autotest/boost/boosttestparser.cpp index 6b01a5477e9..53a14434304 100644 --- a/src/plugins/autotest/boost/boosttestparser.cpp +++ b/src/plugins/autotest/boost/boosttestparser.cpp @@ -98,8 +98,9 @@ static bool hasBoostTestMacros(const CPlusPlus::Document::Ptr &doc) return false; } -static BoostTestParseResult *createParseResult(const QString &name, const QString &filePath, - const QString &projectFile, ITestFramework *framework, +static BoostTestParseResult *createParseResult(const QString &name, const Utils::FilePath &filePath, + const Utils::FilePath &projectFile, + ITestFramework *framework, TestTreeItem::Type type, const BoostTestInfo &info) { BoostTestParseResult *partialSuite = new BoostTestParseResult(framework); @@ -116,21 +117,19 @@ static BoostTestParseResult *createParseResult(const QString &name, const QStrin } bool BoostTestParser::processDocument(QFutureInterface futureInterface, - const QString &fileName) + const Utils::FilePath &fileName) { CPlusPlus::Document::Ptr doc = document(fileName); if (doc.isNull() || !includesBoostTest(doc, m_cppSnapshot) || !hasBoostTestMacros(doc)) return false; const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance(); - const QString &filePath = doc->fileName(); - - const QList projectParts = modelManager->projectPart(filePath); + const QList projectParts = modelManager->projectPart(fileName); if (projectParts.isEmpty()) // happens if shutting down while parsing return false; const CppTools::ProjectPart::Ptr projectPart = projectParts.first(); - const auto projectFile = projectPart->projectFile; - const QByteArray &fileContent = getFileContent(filePath); + const auto projectFile = Utils::FilePath::fromString(projectPart->projectFile); + const QByteArray &fileContent = getFileContent(fileName); BoostCodeParser codeParser(fileContent, projectPart->languageFeatures, doc, m_cppSnapshot); const BoostTestCodeLocationList foundTests = codeParser.findTests(); @@ -141,7 +140,7 @@ bool BoostTestParser::processDocument(QFutureInterface futur BoostTestInfoList suitesStates = locationAndType.m_suitesState; BoostTestInfo firstSuite = suitesStates.first(); QStringList suites = firstSuite.fullName.split('/'); - BoostTestParseResult *topLevelSuite = createParseResult(suites.first(), filePath, + BoostTestParseResult *topLevelSuite = createParseResult(suites.first(), fileName, projectFile, framework(), TestTreeItem::TestSuite, firstSuite); @@ -150,7 +149,7 @@ bool BoostTestParser::processDocument(QFutureInterface futur while (!suitesStates.isEmpty()) { firstSuite = suitesStates.first(); suites = firstSuite.fullName.split('/'); - BoostTestParseResult *suiteResult = createParseResult(suites.last(), filePath, + BoostTestParseResult *suiteResult = createParseResult(suites.last(), fileName, projectFile, framework(), TestTreeItem::TestSuite, firstSuite); @@ -163,7 +162,7 @@ bool BoostTestParser::processDocument(QFutureInterface futur BoostTestInfo tmpInfo{ locationAndType.m_suitesState.last().fullName + "::" + locationAndType.m_name, locationAndType.m_state, locationAndType.m_line}; - BoostTestParseResult *funcResult = createParseResult(locationAndType.m_name, filePath, + BoostTestParseResult *funcResult = createParseResult(locationAndType.m_name, fileName, projectFile, framework(), locationAndType.m_type, tmpInfo); diff --git a/src/plugins/autotest/boost/boosttestparser.h b/src/plugins/autotest/boost/boosttestparser.h index bba9640ef2f..795a7e4c78a 100644 --- a/src/plugins/autotest/boost/boosttestparser.h +++ b/src/plugins/autotest/boost/boosttestparser.h @@ -45,7 +45,7 @@ class BoostTestParser : public CppParser public: explicit BoostTestParser(ITestFramework *framework) : CppParser(framework) {} bool processDocument(QFutureInterface futureInterface, - const QString &fileName) override; + const Utils::FilePath &fileName) override; }; } // namespace Internal diff --git a/src/plugins/autotest/boost/boosttestresult.cpp b/src/plugins/autotest/boost/boosttestresult.cpp index 7d88787446a..9cfab7d289e 100644 --- a/src/plugins/autotest/boost/boosttestresult.cpp +++ b/src/plugins/autotest/boost/boosttestresult.cpp @@ -36,7 +36,7 @@ namespace Autotest { namespace Internal { -BoostTestResult::BoostTestResult(const QString &id, const QString &projectFile, const QString &name) +BoostTestResult::BoostTestResult(const QString &id, const Utils::FilePath &projectFile, const QString &name) : TestResult(id, name), m_projectFile(projectFile) { } diff --git a/src/plugins/autotest/boost/boosttestresult.h b/src/plugins/autotest/boost/boosttestresult.h index 842afc241cb..99c25c5dfa1 100644 --- a/src/plugins/autotest/boost/boosttestresult.h +++ b/src/plugins/autotest/boost/boosttestresult.h @@ -35,7 +35,7 @@ class BoostTestTreeItem; class BoostTestResult : public TestResult { public: - BoostTestResult(const QString &id, const QString &projectFile, const QString &name); + BoostTestResult(const QString &id, const Utils::FilePath &projectFile, const QString &name); const QString outputString(bool selected) const override; bool isDirectParentOf(const TestResult *other, bool *needsIntermediate) const override; @@ -45,7 +45,7 @@ public: private: bool matches(const BoostTestTreeItem *item) const; - QString m_projectFile; + Utils::FilePath m_projectFile; QString m_testSuite; QString m_testCase; }; diff --git a/src/plugins/autotest/boost/boosttesttreeitem.cpp b/src/plugins/autotest/boost/boosttesttreeitem.cpp index 0a18d06f19e..74e97409738 100644 --- a/src/plugins/autotest/boost/boosttesttreeitem.cpp +++ b/src/plugins/autotest/boost/boosttesttreeitem.cpp @@ -77,11 +77,9 @@ TestTreeItem *BoostTestTreeItem::find(const TestParseResult *result) switch (type()) { case Root: if (result->framework->grouping()) { - const QFileInfo fileInfo(bResult->fileName); - const QFileInfo base(fileInfo.absolutePath()); for (int row = 0; row < childCount(); ++row) { BoostTestTreeItem *group = static_cast(childAt(row)); - if (group->filePath() != base.absoluteFilePath()) + if (group->filePath() != bResult->fileName.absoluteFilePath()) continue; if (auto groupChild = group->findChildByNameStateAndFile( bResult->name, bResult->state, bResult->proFile)) { @@ -146,9 +144,8 @@ bool BoostTestTreeItem::modify(const TestParseResult *result) TestTreeItem *BoostTestTreeItem::createParentGroupNode() const { - const QFileInfo fileInfo(filePath()); - const QFileInfo base(fileInfo.absolutePath()); - return new BoostTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); + const QFileInfo base = filePath().absolutePath().toFileInfo(); + return new BoostTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), TestTreeItem::GroupNode); } QString BoostTestTreeItem::prependWithParentsSuitePaths(const QString &testName) const @@ -188,7 +185,7 @@ QList BoostTestTreeItem::getAllTestConfigurations() const }; // we only need the unique project files (and number of test cases for the progress indicator) - QHash testsPerProjectfile; + QHash testsPerProjectfile; forAllChildItems([&testsPerProjectfile](TestTreeItem *item){ if (item->type() != TestSuite) return; @@ -231,7 +228,7 @@ QList BoostTestTreeItem::getTestConfigurations( QSet internalTargets; }; - QHash testCasesForProjectFile; + QHash testCasesForProjectFile; forAllChildren([&testCasesForProjectFile, &predicate](TreeItem *it){ auto item = static_cast(it); if (item->type() != TestCase) @@ -371,7 +368,7 @@ bool BoostTestTreeItem::enabled() const TestTreeItem *BoostTestTreeItem::findChildByNameStateAndFile(const QString &name, BoostTestTreeItem::TestStates state, - const QString &proFile) const + const Utils::FilePath &proFile) const { return static_cast( findAnyChild([name, state, proFile](const Utils::TreeItem *other){ diff --git a/src/plugins/autotest/boost/boosttesttreeitem.h b/src/plugins/autotest/boost/boosttesttreeitem.h index 5bcdf5cf19c..96b6315151d 100644 --- a/src/plugins/autotest/boost/boosttesttreeitem.h +++ b/src/plugins/autotest/boost/boosttesttreeitem.h @@ -50,7 +50,7 @@ public: explicit BoostTestTreeItem(ITestFramework *framework, const QString &name = QString(), - const QString &filePath = QString(), + const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root) : TestTreeItem(framework, name, filePath, type) {} @@ -82,7 +82,7 @@ private: bool enabled() const; TestTreeItem *findChildByNameStateAndFile(const QString &name, BoostTestTreeItem::TestStates state, - const QString &proFile) const; + const Utils::FilePath &proFile) const; QString prependWithParentsSuitePaths(const QString &testName) const; QList getTestConfigurations( std::function predicate) const; diff --git a/src/plugins/autotest/catch/catchframework.cpp b/src/plugins/autotest/catch/catchframework.cpp index 3a8b71c4c24..754703bf711 100644 --- a/src/plugins/autotest/catch/catchframework.cpp +++ b/src/plugins/autotest/catch/catchframework.cpp @@ -49,7 +49,7 @@ ITestTreeItem *CatchFramework::createRootNode() { return new CatchTreeItem(this, QCoreApplication::translate("CatchFramework", "Catch Test"), - QString(), ITestTreeItem::Root); + Utils::FilePath(), ITestTreeItem::Root); } } // namespace Internal diff --git a/src/plugins/autotest/catch/catchoutputreader.cpp b/src/plugins/autotest/catch/catchoutputreader.cpp index 4a46c7722ce..f7ae4d3bc8f 100644 --- a/src/plugins/autotest/catch/catchoutputreader.cpp +++ b/src/plugins/autotest/catch/catchoutputreader.cpp @@ -49,8 +49,8 @@ namespace CatchXml { } CatchOutputReader::CatchOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory, - const QString &projectFile) + QProcess *testApplication, const Utils::FilePath &buildDirectory, + const Utils::FilePath &projectFile) : TestOutputReader (futureInterface, testApplication, buildDirectory) , m_projectFile(projectFile) { @@ -174,11 +174,8 @@ TestResultPtr CatchOutputReader::createDefaultResult() const result->setDescription(m_testCaseInfo.last().name); result->setLine(m_testCaseInfo.last().line); const QString givenPath = m_testCaseInfo.last().filename; - const Utils::FilePath filePath = Utils::FilePath::fromFileInfo(QFileInfo(givenPath)); if (!givenPath.isEmpty()) { - result->setFileName(QDir::isAbsolutePath(givenPath) - ? filePath.toString() - : QFileInfo(m_buildDir + '/' + givenPath).canonicalFilePath()); + result->setFileName(constructSourceFilePath(m_buildDir, givenPath)); } } else { result = new CatchResult(id(), QString()); diff --git a/src/plugins/autotest/catch/catchoutputreader.h b/src/plugins/autotest/catch/catchoutputreader.h index 86f016478b6..70158309617 100644 --- a/src/plugins/autotest/catch/catchoutputreader.h +++ b/src/plugins/autotest/catch/catchoutputreader.h @@ -39,8 +39,8 @@ class CatchOutputReader : public TestOutputReader public: CatchOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory, - const QString &projectFile); + QProcess *testApplication, const Utils::FilePath &buildDirectory, + const Utils::FilePath &projectFile); protected: void processOutputLine(const QByteArray &outputLineWithNewLine) override; @@ -74,7 +74,7 @@ private: QStack m_testCaseInfo; int m_sectionDepth = 0; - QString m_projectFile; + Utils::FilePath m_projectFile; QString m_currentTagName; QString m_currentExpression; QXmlStreamReader m_xmlReader; diff --git a/src/plugins/autotest/catch/catchresult.cpp b/src/plugins/autotest/catch/catchresult.cpp index 36641f9d01a..8e7f2cdb7e1 100644 --- a/src/plugins/autotest/catch/catchresult.cpp +++ b/src/plugins/autotest/catch/catchresult.cpp @@ -73,7 +73,7 @@ const ITestTreeItem *CatchResult::findTestTreeItem() const return nullptr; const QString tcName = name(); - const QString tcFilePath = fileName(); + const Utils::FilePath tcFilePath = fileName(); return rootNode->findAnyChild([&tcName, &tcFilePath](const Utils::TreeItem *item) { const auto treeItem = static_cast(item); if (!treeItem || treeItem->filePath() != tcFilePath) diff --git a/src/plugins/autotest/catch/catchtestparser.cpp b/src/plugins/autotest/catch/catchtestparser.cpp index a01de57a750..a95e1f2905c 100644 --- a/src/plugins/autotest/catch/catchtestparser.cpp +++ b/src/plugins/autotest/catch/catchtestparser.cpp @@ -105,7 +105,8 @@ static bool hasCatchNames(const CPlusPlus::Document::Ptr &document) return false; } -bool CatchTestParser::processDocument(QFutureInterface futureInterface, const QString &fileName) +bool CatchTestParser::processDocument(QFutureInterface futureInterface, + const Utils::FilePath &fileName) { CPlusPlus::Document::Ptr doc = document(fileName); if (doc.isNull() || !includesCatchHeader(doc, m_cppSnapshot) || !hasCatchNames(doc)) @@ -113,28 +114,28 @@ bool CatchTestParser::processDocument(QFutureInterface futur const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance(); const QString &filePath = doc->fileName(); - const QByteArray &fileContent = getFileContent(filePath); + const QByteArray &fileContent = getFileContent(fileName); - const QList projectParts = modelManager->projectPart(filePath); + const QList projectParts = modelManager->projectPart(fileName); if (projectParts.isEmpty()) // happens if shutting down while parsing return false; - QString proFile; + Utils::FilePath proFile; const CppTools::ProjectPart::Ptr projectPart = projectParts.first(); - proFile = projectPart->projectFile; + proFile = Utils::FilePath::fromString(projectPart->projectFile); CatchCodeParser codeParser(fileContent, projectPart->languageFeatures); const CatchTestCodeLocationList foundTests = codeParser.findTests(); CatchParseResult *parseResult = new CatchParseResult(framework()); parseResult->itemType = TestTreeItem::TestSuite; - parseResult->fileName = filePath; + parseResult->fileName = fileName; parseResult->name = filePath; parseResult->displayName = filePath; - parseResult->proFile = projectParts.first()->projectFile; + parseResult->proFile = proFile; for (const CatchTestCodeLocationAndType & testLocation : foundTests) { CatchParseResult *testCase = new CatchParseResult(framework()); - testCase->fileName = filePath; + testCase->fileName = fileName; testCase->name = testLocation.m_name; testCase->proFile = proFile; testCase->itemType = testLocation.m_type; diff --git a/src/plugins/autotest/catch/catchtestparser.h b/src/plugins/autotest/catch/catchtestparser.h index 4c558aa637e..3191072f057 100644 --- a/src/plugins/autotest/catch/catchtestparser.h +++ b/src/plugins/autotest/catch/catchtestparser.h @@ -45,7 +45,7 @@ public: CatchTestParser(ITestFramework *framework) : CppParser(framework) {} bool processDocument(QFutureInterface futureInterface, - const QString &fileName) override; + const Utils::FilePath &fileName) override; }; } // namespace Internal diff --git a/src/plugins/autotest/catch/catchtreeitem.cpp b/src/plugins/autotest/catch/catchtreeitem.cpp index cd5c6c5d1a9..96ee8816537 100644 --- a/src/plugins/autotest/catch/catchtreeitem.cpp +++ b/src/plugins/autotest/catch/catchtreeitem.cpp @@ -49,7 +49,7 @@ static QString nonRootDisplayName(const CatchTreeItem *it) return it->name(); TestTreeItem *parent = it->parentItem(); int baseDirSize = (parent->type() == TestTreeItem::GroupNode) - ? parent->filePath().size() : project->projectDirectory().toString().size(); + ? parent->filePath().toString().size() : project->projectDirectory().toString().size(); return it->name().mid(baseDirSize + 1); } @@ -88,7 +88,7 @@ TestTreeItem *CatchTreeItem::find(const TestParseResult *result) switch (type()) { case Root: if (result->framework->grouping()) { - const QString path = QFileInfo(result->fileName).absolutePath(); + const Utils::FilePath path = result->fileName.absolutePath(); for (int row = 0; row < childCount(); ++row) { TestTreeItem *group = childItem(row); if (group->filePath() != path) @@ -139,9 +139,8 @@ bool CatchTreeItem::modify(const TestParseResult *result) TestTreeItem *CatchTreeItem::createParentGroupNode() const { - const QFileInfo fileInfo(filePath()); - const QFileInfo base(fileInfo.absolutePath()); - return new CatchTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); + const QFileInfo base(filePath().toFileInfo().absolutePath()); + return new CatchTreeItem(framework(), base.baseName(), filePath(), TestTreeItem::GroupNode); } bool CatchTreeItem::canProvideTestConfiguration() const @@ -189,7 +188,7 @@ struct CatchTestCases }; static void collectTestInfo(const TestTreeItem *item, - QHash &testCasesForProfile, + QHash &testCasesForProfile, bool ignoreCheckState) { QTC_ASSERT(item, return); @@ -206,7 +205,7 @@ static void collectTestInfo(const TestTreeItem *item, QTC_ASSERT(childCount != 0, return); QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return); if (ignoreCheckState || item->checked() == Qt::Checked) { - const QString &projectFile = item->childItem(0)->proFile(); + const Utils::FilePath &projectFile = item->childItem(0)->proFile(); item->forAllChildItems([&testCasesForProfile, &projectFile](TestTreeItem *it) { CatchTreeItem *current = static_cast(it); testCasesForProfile[projectFile].names.append(current->testCasesString()); @@ -227,7 +226,7 @@ static void collectTestInfo(const TestTreeItem *item, } static void collectFailedTestInfo(const CatchTreeItem *item, - QHash &testCasesForProfile) + QHash &testCasesForProfile) { QTC_ASSERT(item, return); QTC_ASSERT(item->type() == TestTreeItem::Root, return); @@ -263,7 +262,7 @@ QList CatchTreeItem::getFailedTestConfigurations() const if (!project || type() != Root) return result; - QHash testCasesForProFile; + QHash testCasesForProFile; collectFailedTestInfo(this, testCasesForProFile); for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) { @@ -334,7 +333,7 @@ QList CatchTreeItem::getTestConfigurations(bool ignoreChec if (!project || type() != Root) return result; - QHash testCasesForProfile; + QHash testCasesForProfile; for (int row = 0, end = childCount(); row < end; ++row) collectTestInfo(childItem(row), testCasesForProfile, ignoreCheckState); diff --git a/src/plugins/autotest/catch/catchtreeitem.h b/src/plugins/autotest/catch/catchtreeitem.h index 72256cdb133..c79e9aa640d 100644 --- a/src/plugins/autotest/catch/catchtreeitem.h +++ b/src/plugins/autotest/catch/catchtreeitem.h @@ -42,7 +42,7 @@ public: Q_DECLARE_FLAGS(TestStates, TestState) explicit CatchTreeItem(ITestFramework *testFramework, const QString &name = QString(), - const QString &filePath = QString(), Type type = Root) + const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root) : TestTreeItem(testFramework, name, filePath, type) {} void setStates(CatchTreeItem::TestStates state) { m_state = state; } diff --git a/src/plugins/autotest/ctest/ctestoutputreader.cpp b/src/plugins/autotest/ctest/ctestoutputreader.cpp index 8722e2d9a6d..be20942da5e 100644 --- a/src/plugins/autotest/ctest/ctestoutputreader.cpp +++ b/src/plugins/autotest/ctest/ctestoutputreader.cpp @@ -71,7 +71,8 @@ private: }; CTestOutputReader::CTestOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory) + QProcess *testApplication, + const Utils::FilePath &buildDirectory) : TestOutputReader(futureInterface, testApplication, buildDirectory) { } diff --git a/src/plugins/autotest/ctest/ctestoutputreader.h b/src/plugins/autotest/ctest/ctestoutputreader.h index da93a711830..b5baaaf96c5 100644 --- a/src/plugins/autotest/ctest/ctestoutputreader.h +++ b/src/plugins/autotest/ctest/ctestoutputreader.h @@ -36,7 +36,7 @@ class CTestOutputReader final : public Autotest::TestOutputReader Q_DECLARE_TR_FUNCTIONS(Autotest::Internal::CTestOutputReader) public: CTestOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory); + QProcess *testApplication, const Utils::FilePath &buildDirectory); protected: void processOutputLine(const QByteArray &outputLineWithNewLine) final; diff --git a/src/plugins/autotest/ctest/ctesttool.cpp b/src/plugins/autotest/ctest/ctesttool.cpp index c4388f1dac6..4db818581eb 100644 --- a/src/plugins/autotest/ctest/ctesttool.cpp +++ b/src/plugins/autotest/ctest/ctesttool.cpp @@ -40,8 +40,7 @@ Utils::Id CTestTool::buildSystemId() const ITestTreeItem *CTestTool::createItemFromTestCaseInfo(const ProjectExplorer::TestCaseInfo &tci) { - CTestTreeItem *item = new CTestTreeItem(this, tci.name, tci.path.toString(), - TestTreeItem::TestCase); + CTestTreeItem *item = new CTestTreeItem(this, tci.name, tci.path, TestTreeItem::TestCase); item->setLine(tci.line); return item; } @@ -55,7 +54,7 @@ ITestTreeItem *CTestTool::createRootNode() { return new CTestTreeItem(this, QCoreApplication::translate("CTestTool", "CTest"), - QString(), ITestTreeItem::Root); + Utils::FilePath(), ITestTreeItem::Root); } } // namespace Internal diff --git a/src/plugins/autotest/ctest/ctesttreeitem.cpp b/src/plugins/autotest/ctest/ctesttreeitem.cpp index 3f9cbb9e343..085ecb65002 100644 --- a/src/plugins/autotest/ctest/ctesttreeitem.cpp +++ b/src/plugins/autotest/ctest/ctesttreeitem.cpp @@ -43,7 +43,7 @@ namespace Autotest { namespace Internal { CTestTreeItem::CTestTreeItem(ITestBase *testBase, const QString &name, - const QString &filepath, Type type) + const Utils::FilePath &filepath, Type type) : ITestTreeItem(testBase, name, filepath, type) { } @@ -88,7 +88,7 @@ QVariant CTestTreeItem::data(int column, int role) const return checked(); if (role == LinkRole) { QVariant itemLink; - itemLink.setValue(Utils::Link(Utils::FilePath::fromString(filePath()), line())); + itemLink.setValue(Utils::Link(filePath(), line())); return itemLink; } return ITestTreeItem::data(column, role); diff --git a/src/plugins/autotest/ctest/ctesttreeitem.h b/src/plugins/autotest/ctest/ctesttreeitem.h index f63dabaa8e6..424872e7cda 100644 --- a/src/plugins/autotest/ctest/ctesttreeitem.h +++ b/src/plugins/autotest/ctest/ctesttreeitem.h @@ -33,7 +33,7 @@ namespace Internal { class CTestTreeItem final : public Autotest::ITestTreeItem { public: - CTestTreeItem(ITestBase *testBase, const QString &name, const QString &filepath, Type type); + CTestTreeItem(ITestBase *testBase, const QString &name, const Utils::FilePath &filepath, Type type); QList getAllTestConfigurations() const final; QList getSelectedTestConfigurations() const final; diff --git a/src/plugins/autotest/gtest/gtestframework.cpp b/src/plugins/autotest/gtest/gtestframework.cpp index 10bad2a2634..b093417324b 100644 --- a/src/plugins/autotest/gtest/gtestframework.cpp +++ b/src/plugins/autotest/gtest/gtestframework.cpp @@ -50,7 +50,7 @@ ITestTreeItem *GTestFramework::createRootNode() this, QCoreApplication::translate("GTestFramework", GTest::Constants::FRAMEWORK_SETTINGS_CATEGORY), - QString(), ITestTreeItem::Root); + Utils::FilePath(), ITestTreeItem::Root); } const char *GTestFramework::name() const diff --git a/src/plugins/autotest/gtest/gtestoutputreader.cpp b/src/plugins/autotest/gtest/gtestoutputreader.cpp index 77c0e825e81..4bc93690bc9 100644 --- a/src/plugins/autotest/gtest/gtestoutputreader.cpp +++ b/src/plugins/autotest/gtest/gtestoutputreader.cpp @@ -36,14 +36,10 @@ namespace Autotest { namespace Internal { -static QString constructSourceFilePath(const QString &path, const QString &filePath) -{ - return QFileInfo(path, filePath).canonicalFilePath(); -} - GTestOutputReader::GTestOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory, - const QString &projectFile) + QProcess *testApplication, + const Utils::FilePath &buildDirectory, + const Utils::FilePath &projectFile) : TestOutputReader(futureInterface, testApplication, buildDirectory) , m_projectFile(projectFile) { @@ -181,7 +177,7 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine) TestResultPtr testResult = createDefaultResult(); testResult->setResult(type); testResult->setLine(match.captured(3).toInt()); - const QString file = constructSourceFilePath(m_buildDir, match.captured(2)); + const Utils::FilePath file = constructSourceFilePath(m_buildDir, match.captured(2)); if (!file.isEmpty()) testResult->setFileName(file); testResult->setDescription(match.captured(4)); @@ -246,7 +242,7 @@ void GTestOutputReader::handleDescriptionAndReportResult(TestResultPtr testResul testResult = createDefaultResult(); testResult->setResult(ResultType::MessageLocation); testResult->setLine(innerMatch.captured(2).toInt()); - QString file = constructSourceFilePath(m_buildDir, innerMatch.captured(1)); + const Utils::FilePath file = constructSourceFilePath(m_buildDir, innerMatch.captured(1)); if (!file.isEmpty()) testResult->setFileName(file); resultDescription << output; diff --git a/src/plugins/autotest/gtest/gtestoutputreader.h b/src/plugins/autotest/gtest/gtestoutputreader.h index 9bed450971a..05688a4fa2b 100644 --- a/src/plugins/autotest/gtest/gtestoutputreader.h +++ b/src/plugins/autotest/gtest/gtestoutputreader.h @@ -38,8 +38,8 @@ class GTestOutputReader : public TestOutputReader public: GTestOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory, - const QString &projectFile); + QProcess *testApplication, const Utils::FilePath &buildDirectory, + const Utils::FilePath &projectFile); protected: void processOutputLine(const QByteArray &outputLine) override; void processStdError(const QByteArray &outputLine) override; @@ -50,7 +50,7 @@ private: void setCurrentTestSuite(const QString &testSuite); void handleDescriptionAndReportResult(TestResultPtr testResult); - QString m_projectFile; + Utils::FilePath m_projectFile; QString m_currentTestSuite; QString m_currentTestCase; QString m_description; diff --git a/src/plugins/autotest/gtest/gtestparser.cpp b/src/plugins/autotest/gtest/gtestparser.cpp index e59251a8774..4975bc66da9 100644 --- a/src/plugins/autotest/gtest/gtestparser.cpp +++ b/src/plugins/autotest/gtest/gtestparser.cpp @@ -88,7 +88,7 @@ static bool hasGTestNames(const CPlusPlus::Document::Ptr &document) } bool GTestParser::processDocument(QFutureInterface futureInterface, - const QString &fileName) + const Utils::FilePath &fileName) { CPlusPlus::Document::Ptr doc = document(fileName); if (doc.isNull() || !includesGTest(doc, m_cppSnapshot) || !hasGTestNames(doc)) @@ -96,18 +96,18 @@ bool GTestParser::processDocument(QFutureInterface futureInt const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance(); const QString &filePath = doc->fileName(); - const QByteArray &fileContent = getFileContent(filePath); - CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, filePath); + const QByteArray &fileContent = getFileContent(fileName); + CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName); document->check(); CPlusPlus::AST *ast = document->translationUnit()->ast(); GTestVisitor visitor(document); visitor.accept(ast); const QMap result = visitor.gtestFunctions(); - QString proFile; + Utils::FilePath proFile; const QList &ppList = modelManager->projectPart(filePath); if (!ppList.isEmpty()) - proFile = ppList.first()->projectFile; + proFile = Utils::FilePath::fromString(ppList.first()->projectFile); else return false; // happens if shutting down while parsing @@ -115,7 +115,7 @@ bool GTestParser::processDocument(QFutureInterface futureInt const GTestCaseSpec &testSpec = it.key(); GTestParseResult *parseResult = new GTestParseResult(framework()); parseResult->itemType = TestTreeItem::TestSuite; - parseResult->fileName = filePath; + parseResult->fileName = fileName; parseResult->name = testSpec.testCaseName; parseResult->parameterized = testSpec.parameterized; parseResult->typed = testSpec.typed; @@ -125,7 +125,7 @@ bool GTestParser::processDocument(QFutureInterface futureInt for (const GTestCodeLocationAndType &location : it.value()) { GTestParseResult *testSet = new GTestParseResult(framework()); testSet->name = location.m_name; - testSet->fileName = filePath; + testSet->fileName = fileName; testSet->line = location.m_line; testSet->column = location.m_column; testSet->disabled = location.m_state & GTestTreeItem::Disabled; diff --git a/src/plugins/autotest/gtest/gtestparser.h b/src/plugins/autotest/gtest/gtestparser.h index 781c9fe9023..6f8f87603f5 100644 --- a/src/plugins/autotest/gtest/gtestparser.h +++ b/src/plugins/autotest/gtest/gtestparser.h @@ -45,7 +45,7 @@ class GTestParser : public CppParser public: explicit GTestParser(ITestFramework *framework) : CppParser(framework) {} bool processDocument(QFutureInterface futureInterface, - const QString &fileName) override; + const Utils::FilePath &fileName) override; }; } // namespace Internal diff --git a/src/plugins/autotest/gtest/gtestresult.cpp b/src/plugins/autotest/gtest/gtestresult.cpp index 10a81f48dbb..fb3527425c6 100644 --- a/src/plugins/autotest/gtest/gtestresult.cpp +++ b/src/plugins/autotest/gtest/gtestresult.cpp @@ -36,7 +36,7 @@ namespace Autotest { namespace Internal { -GTestResult::GTestResult(const QString &id, const QString &projectFile, +GTestResult::GTestResult(const QString &id, const Utils::FilePath &projectFile, const QString &name) : TestResult(id, name), m_projectFile(projectFile) { diff --git a/src/plugins/autotest/gtest/gtestresult.h b/src/plugins/autotest/gtest/gtestresult.h index 6fc1728629c..a662134b7b6 100644 --- a/src/plugins/autotest/gtest/gtestresult.h +++ b/src/plugins/autotest/gtest/gtestresult.h @@ -36,7 +36,7 @@ namespace Internal { class GTestResult : public TestResult { public: - GTestResult(const QString &id, const QString &projectFile, const QString &name); + GTestResult(const QString &id, const Utils::FilePath &projectFile, const QString &name); const QString outputString(bool selected) const override; void setTestCaseName(const QString &testSetName) { m_testCaseName = testSetName; } @@ -53,7 +53,7 @@ private: bool matchesTestSuite(const TestTreeItem *treeItem) const; QString m_testCaseName; - QString m_projectFile; + Utils::FilePath m_projectFile; int m_iteration = 1; }; diff --git a/src/plugins/autotest/gtest/gtesttreeitem.cpp b/src/plugins/autotest/gtest/gtesttreeitem.cpp index 70aca519225..2d2012e35d3 100644 --- a/src/plugins/autotest/gtest/gtesttreeitem.cpp +++ b/src/plugins/autotest/gtest/gtesttreeitem.cpp @@ -139,7 +139,7 @@ QVariant GTestTreeItem::data(int column, int role) const case Qt::ToolTipRole: if (type() == GroupNode && GTestFramework::groupMode() == GTest::Constants::GTestFilter) { - const auto tpl = QString("

%1

%2

").arg(filePath()); + const auto tpl = QString("

%1

%2

").arg(filePath().toString()); return tpl.arg(QCoreApplication::translate( "GTestTreeItem", "Change GTest filter in use inside the settings.")); } @@ -217,7 +217,7 @@ struct GTestCases }; static void collectTestInfo(const GTestTreeItem *item, - QHash &testCasesForProFile, + QHash &testCasesForProFile, bool ignoreCheckState) { QTC_ASSERT(item, return); @@ -232,7 +232,7 @@ static void collectTestInfo(const GTestTreeItem *item, QTC_ASSERT(childCount != 0, return); QTC_ASSERT(item->type() == TestTreeItem::TestSuite, return); if (ignoreCheckState || item->checked() == Qt::Checked) { - const QString &projectFile = item->childItem(0)->proFile(); + const Utils::FilePath &projectFile = item->childItem(0)->proFile(); testCasesForProFile[projectFile].filters.append( gtestFilter(item->state()).arg(item->name()).arg('*')); testCasesForProFile[projectFile].testSetCount += childCount - 1; @@ -251,7 +251,7 @@ static void collectTestInfo(const GTestTreeItem *item, } static void collectFailedTestInfo(const GTestTreeItem *item, - QHash &testCasesForProfile) + QHash &testCasesForProfile) { QTC_ASSERT(item, return); QTC_ASSERT(item->type() == TestTreeItem::Root, return); @@ -276,7 +276,7 @@ QList GTestTreeItem::getTestConfigurations(bool ignoreChec if (!project || type() != Root) return result; - QHash testCasesForProFile; + QHash testCasesForProFile; for (int row = 0, count = childCount(); row < count; ++row) { auto child = static_cast(childAt(row)); collectTestInfo(child, testCasesForProFile, ignoreCheckState); @@ -315,7 +315,7 @@ QList GTestTreeItem::getFailedTestConfigurations() const if (!project || type() != Root) return result; - QHash testCasesForProFile; + QHash testCasesForProFile; collectFailedTestInfo(this, testCasesForProFile); for (auto it = testCasesForProFile.begin(), end = testCasesForProFile.end(); it != end; ++it) { @@ -340,10 +340,9 @@ QList GTestTreeItem::getTestConfigurationsForFile(const Ut if (!project || type() != Root) return result; - QHash testCases; - const QString &file = fileName.toString(); - forAllChildItems([&testCases, &file](TestTreeItem *node) { - if (node->type() == Type::TestCase && node->filePath() == file) { + QHash testCases; + forAllChildItems([&testCases, &fileName](TestTreeItem *node) { + if (node->type() == Type::TestCase && node->filePath() == fileName) { QTC_ASSERT(node->parentItem(), return); const GTestTreeItem *testCase = static_cast(node->parentItem()); QTC_ASSERT(testCase->type() == Type::TestSuite, return); @@ -381,8 +380,7 @@ TestTreeItem *GTestTreeItem::find(const TestParseResult *result) case Root: if (result->framework->grouping()) { if (GTestFramework::groupMode() == GTest::Constants::Directory) { - const QFileInfo fileInfo(parseResult->fileName); - const QFileInfo base(fileInfo.absolutePath()); + const Utils::FilePath base = parseResult->fileName.absolutePath(); for (int row = 0; row < childCount(); ++row) { GTestTreeItem *group = static_cast(childAt(row)); if (group->filePath() != base.absoluteFilePath()) @@ -466,9 +464,9 @@ bool GTestTreeItem::modify(const TestParseResult *result) TestTreeItem *GTestTreeItem::createParentGroupNode() const { if (GTestFramework::groupMode() == GTest::Constants::Directory) { - const QFileInfo fileInfo(filePath()); - const QFileInfo base(fileInfo.absolutePath()); - return new GTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); + const QFileInfo base = filePath().absolutePath().toFileInfo(); + return new GTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), + TestTreeItem::GroupNode); } else { // GTestFilter QTC_ASSERT(childCount(), return nullptr); // paranoia const TestTreeItem *firstChild = childItem(0); @@ -476,7 +474,10 @@ TestTreeItem *GTestTreeItem::createParentGroupNode() const const QString fullTestName = name() + '.' + firstChild->name(); const QString groupNodeName = matchesFilter(activeFilter, fullTestName) ? matchingString() : notMatchingString(); - auto groupNode = new GTestTreeItem(framework(), groupNodeName, activeFilter, TestTreeItem::GroupNode); + // FIXME activeFilter is not a FilePath + auto groupNode = new GTestTreeItem(framework(), groupNodeName, + Utils::FilePath::fromString(activeFilter), + TestTreeItem::GroupNode); if (groupNodeName == notMatchingString()) groupNode->setData(0, Qt::Unchecked, Qt::CheckStateRole); return groupNode; @@ -497,7 +498,7 @@ bool GTestTreeItem::modifyTestSetContent(const GTestParseResult *result) TestTreeItem *GTestTreeItem::findChildByNameStateAndFile(const QString &name, GTestTreeItem::TestStates state, - const QString &proFile) const + const Utils::FilePath &proFile) const { return findFirstLevelChildItem([name, state, proFile](const TestTreeItem *other) { const GTestTreeItem *gtestItem = static_cast(other); @@ -524,18 +525,19 @@ QSet internalTargets(const TestTreeItem &item) QSet result; const auto cppMM = CppTools::CppModelManager::instance(); const auto projectInfo = cppMM->projectInfo(ProjectExplorer::SessionManager::startupProject()); - const QString file = item.filePath(); + const Utils::FilePath filePath = item.filePath(); + const QString file = filePath.toString(); const QVector projectParts = projectInfo.projectParts(); if (projectParts.isEmpty()) - return cppMM->dependingInternalTargets(file); + return cppMM->dependingInternalTargets(item.filePath()); for (const CppTools::ProjectPart::Ptr &projectPart : projectParts) { - if (projectPart->projectFile == item.proFile() + if (Utils::FilePath::fromString(projectPart->projectFile) == item.proFile() && Utils::anyOf(projectPart->files, [&file] (const CppTools::ProjectFile &pf) { return pf.path == file; })) { result.insert(projectPart->buildSystemTarget); if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable) - result.unite(cppMM->dependingInternalTargets(file)); + result.unite(cppMM->dependingInternalTargets(filePath)); } } return result; @@ -548,7 +550,7 @@ bool GTestTreeItem::isGroupNodeFor(const TestTreeItem *other) const return false; if (GTestFramework::groupMode() == GTest::Constants::Directory) { - return QFileInfo(other->filePath()).absolutePath() == filePath(); + return other->filePath().absolutePath() == filePath(); } else { // GTestFilter QString fullName; if (other->type() == TestSuite) { @@ -563,9 +565,10 @@ bool GTestTreeItem::isGroupNodeFor(const TestTreeItem *other) const } else { QTC_ASSERT(false, return false); } - if (GTestFramework::currentGTestFilter() != filePath()) // filter has changed in settings + // FIXME gtest filter is no FilePath + if (GTestFramework::currentGTestFilter() != filePath().toString()) // filter has changed in settings return false; - bool matches = matchesFilter(filePath(), fullName); + bool matches = matchesFilter(filePath().toString(), fullName); return (matches && name() == matchingString()) || (!matches && name() == notMatchingString()); } diff --git a/src/plugins/autotest/gtest/gtesttreeitem.h b/src/plugins/autotest/gtest/gtesttreeitem.h index 0ad87085d9b..62133063ed1 100644 --- a/src/plugins/autotest/gtest/gtesttreeitem.h +++ b/src/plugins/autotest/gtest/gtesttreeitem.h @@ -48,7 +48,7 @@ public: explicit GTestTreeItem(ITestFramework *testFramework, const QString &name = QString(), - const QString &filePath = QString(), + const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root) : TestTreeItem(testFramework, name, filePath, type), m_state(Enabled) {} @@ -73,7 +73,7 @@ public: TestStates state() const { return m_state; } TestTreeItem *findChildByNameStateAndFile(const QString &name, GTestTreeItem::TestStates state, - const QString &proFile) const; + const Utils::FilePath &proFile) const; QString nameSuffix() const; bool isGroupNodeFor(const TestTreeItem *other) const override; bool isGroupable() const override; diff --git a/src/plugins/autotest/itestparser.cpp b/src/plugins/autotest/itestparser.cpp index 873f4f2a781..740f029e4c6 100644 --- a/src/plugins/autotest/itestparser.cpp +++ b/src/plugins/autotest/itestparser.cpp @@ -36,7 +36,7 @@ CppParser::CppParser(ITestFramework *framework) { } -void CppParser::init(const QStringList &filesToParse, bool fullParse) +void CppParser::init(const Utils::FilePaths &filesToParse, bool fullParse) { Q_UNUSED(filesToParse) Q_UNUSED(fullParse) @@ -44,7 +44,7 @@ void CppParser::init(const QStringList &filesToParse, bool fullParse) m_workingCopy = CppTools::CppModelManager::instance()->workingCopy(); } -bool CppParser::selectedForBuilding(const QString &fileName) +bool CppParser::selectedForBuilding(const Utils::FilePath &fileName) { QList projParts = CppTools::CppModelManager::instance()->projectPart(fileName); @@ -52,7 +52,7 @@ bool CppParser::selectedForBuilding(const QString &fileName) return !projParts.isEmpty() && projParts.at(0)->selectedForBuilding; } -QByteArray CppParser::getFileContent(const QString &filePath) const +QByteArray CppParser::getFileContent(const Utils::FilePath &filePath) const { QByteArray fileContent; if (m_workingCopy.contains(filePath)) { @@ -60,11 +60,8 @@ QByteArray CppParser::getFileContent(const QString &filePath) const } else { QString error; const QTextCodec *codec = Core::EditorManager::defaultTextCodec(); - if (Utils::TextFileFormat::readFileUTF8(Utils::FilePath::fromString(filePath), - codec, - &fileContent, - &error) - != Utils::TextFileFormat::ReadSuccess) { + if (Utils::TextFileFormat::readFileUTF8(filePath, codec, &fileContent, &error) + != Utils::TextFileFormat::ReadSuccess) { qDebug() << "Failed to read file" << filePath << ":" << error; } } @@ -78,7 +75,7 @@ void CppParser::release() m_workingCopy = CppTools::WorkingCopy(); } -CPlusPlus::Document::Ptr CppParser::document(const QString &fileName) +CPlusPlus::Document::Ptr CppParser::document(const Utils::FilePath &fileName) { return selectedForBuilding(fileName) ? m_cppSnapshot.document(fileName) : nullptr; } diff --git a/src/plugins/autotest/itestparser.h b/src/plugins/autotest/itestparser.h index 0639797fa1e..e089c030d48 100644 --- a/src/plugins/autotest/itestparser.h +++ b/src/plugins/autotest/itestparser.h @@ -49,8 +49,8 @@ public: ITestFramework *framework; TestTreeItem::Type itemType = TestTreeItem::Root; QString displayName; - QString fileName; - QString proFile; + Utils::FilePath fileName; + Utils::FilePath proFile; QString name; int line = 0; int column = 0; @@ -63,9 +63,9 @@ class ITestParser public: explicit ITestParser(ITestFramework *framework) : m_framework(framework) {} virtual ~ITestParser() { } - virtual void init(const QStringList &filesToParse, bool fullParse) = 0; + virtual void init(const Utils::FilePaths &filesToParse, bool fullParse) = 0; virtual bool processDocument(QFutureInterface futureInterface, - const QString &fileName) = 0; + const Utils::FilePath &fileName) = 0; virtual void release() = 0; ITestFramework *framework() const { return m_framework; } @@ -78,12 +78,12 @@ class CppParser : public ITestParser { public: explicit CppParser(ITestFramework *framework); - void init(const QStringList &filesToParse, bool fullParse) override; - static bool selectedForBuilding(const QString &fileName); - QByteArray getFileContent(const QString &filePath) const; + void init(const Utils::FilePaths &filesToParse, bool fullParse) override; + static bool selectedForBuilding(const Utils::FilePath &fileName); + QByteArray getFileContent(const Utils::FilePath &filePath) const; void release() override; - CPlusPlus::Document::Ptr document(const QString &fileName); + CPlusPlus::Document::Ptr document(const Utils::FilePath &fileName); protected: CPlusPlus::Snapshot m_cppSnapshot; diff --git a/src/plugins/autotest/qtest/qttest_utils.cpp b/src/plugins/autotest/qtest/qttest_utils.cpp index ce98f959d2d..7d5e0d96aa6 100644 --- a/src/plugins/autotest/qtest/qttest_utils.cpp +++ b/src/plugins/autotest/qtest/qttest_utils.cpp @@ -47,9 +47,10 @@ bool isQTestMacro(const QByteArray ¯o) return valid.contains(macro); } -QHash testCaseNamesForFiles(ITestFramework *framework, const QStringList &files) +QHash testCaseNamesForFiles(ITestFramework *framework, + const Utils::FilePaths &files) { - QHash result; + QHash result; TestTreeItem *rootNode = framework->rootNode(); QTC_ASSERT(rootNode, return result); @@ -64,17 +65,18 @@ QHash testCaseNamesForFiles(ITestFramework *framework, const Q return result; } -QMultiHash alternativeFiles(ITestFramework *framework, const QStringList &files) +QMultiHash alternativeFiles(ITestFramework *framework, + const Utils::FilePaths &files) { - QMultiHash result; + QMultiHash result; TestTreeItem *rootNode = framework->rootNode(); QTC_ASSERT(rootNode, return result); rootNode->forFirstLevelChildren([&result, &files](ITestTreeItem *child) { - const QString &baseFilePath = child->filePath(); + const Utils::FilePath &baseFilePath = child->filePath(); for (int childRow = 0, count = child->childCount(); childRow < count; ++childRow) { auto grandChild = static_cast(child->childAt(childRow)); - const QString &filePath = grandChild->filePath(); + const Utils::FilePath &filePath = grandChild->filePath(); if (grandChild->inherited() && baseFilePath != filePath && files.contains(filePath)) { if (!result.contains(filePath, baseFilePath)) result.insert(filePath, baseFilePath); diff --git a/src/plugins/autotest/qtest/qttest_utils.h b/src/plugins/autotest/qtest/qttest_utils.h index b1156ff7eec..22a127899d2 100644 --- a/src/plugins/autotest/qtest/qttest_utils.h +++ b/src/plugins/autotest/qtest/qttest_utils.h @@ -25,6 +25,8 @@ #pragma once +#include + #include namespace Utils { class Environment; } @@ -37,8 +39,10 @@ namespace Internal { namespace QTestUtils { bool isQTestMacro(const QByteArray ¯o); -QHash testCaseNamesForFiles(ITestFramework *framework, const QStringList &files); -QMultiHash alternativeFiles(ITestFramework *framework, const QStringList &files); +QHash testCaseNamesForFiles(ITestFramework *framework, + const Utils::FilePaths &files); +QMultiHash alternativeFiles(ITestFramework *framework, + const Utils::FilePaths &files); QStringList filterInterfering(const QStringList &provided, QStringList *omitted, bool isQuickTest); Utils::Environment prepareBasicEnvironment(const Utils::Environment &env); diff --git a/src/plugins/autotest/qtest/qttestframework.cpp b/src/plugins/autotest/qtest/qttestframework.cpp index fcf2445ebd8..23646e43d93 100644 --- a/src/plugins/autotest/qtest/qttestframework.cpp +++ b/src/plugins/autotest/qtest/qttestframework.cpp @@ -42,7 +42,7 @@ ITestTreeItem *QtTestFramework::createRootNode() this, QCoreApplication::translate("QtTestFramework", QtTest::Constants::FRAMEWORK_SETTINGS_CATEGORY), - QString(), ITestTreeItem::Root); + Utils::FilePath(), ITestTreeItem::Root); } const char *QtTestFramework::name() const diff --git a/src/plugins/autotest/qtest/qttestoutputreader.cpp b/src/plugins/autotest/qtest/qttestoutputreader.cpp index 843a1dd2adb..a15a0fc1d4d 100644 --- a/src/plugins/autotest/qtest/qttestoutputreader.cpp +++ b/src/plugins/autotest/qtest/qttestoutputreader.cpp @@ -125,14 +125,11 @@ static QString constructBenchmarkInformation(const QString &metric, double value .arg(iterations); } -static QString constructSourceFilePath(const QString &path, const QString &filePath) -{ - return QFileInfo(path, filePath).canonicalFilePath(); -} - QtTestOutputReader::QtTestOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory, - const QString &projectFile, OutputMode mode, TestType type) + QProcess *testApplication, + const Utils::FilePath &buildDirectory, + const Utils::FilePath &projectFile, + OutputMode mode, TestType type) : TestOutputReader(futureInterface, testApplication, buildDirectory) , m_projectFile(projectFile) , m_mode(mode) @@ -237,9 +234,8 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine) const QXmlStreamAttributes &attributes = m_xmlReader.attributes(); m_result = TestResult::resultFromString( attributes.value(QStringLiteral("type")).toString()); - m_file = decode(attributes.value(QStringLiteral("file")).toString()); - if (!m_file.isEmpty()) - m_file = constructSourceFilePath(m_buildDir, m_file); + const QString file = decode(attributes.value(QStringLiteral("file")).toString()); + m_file = constructSourceFilePath(m_buildDir, file); m_lineNumber = attributes.value(QStringLiteral("line")).toInt(); } else if (currentTag == QStringLiteral("BenchmarkResult")) { const QXmlStreamAttributes &attributes = m_xmlReader.attributes(); diff --git a/src/plugins/autotest/qtest/qttestoutputreader.h b/src/plugins/autotest/qtest/qttestoutputreader.h index 8d03726b12b..eff84dd4642 100644 --- a/src/plugins/autotest/qtest/qttestoutputreader.h +++ b/src/plugins/autotest/qtest/qttestoutputreader.h @@ -48,8 +48,8 @@ public: }; QtTestOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory, - const QString &projectFile, OutputMode mode, TestType type); + QProcess *testApplication, const Utils::FilePath &buildDirectory, + const Utils::FilePath &projectFile, OutputMode mode, TestType type); protected: void processOutputLine(const QByteArray &outputLine) override; TestResultPtr createDefaultResult() const override; @@ -78,14 +78,14 @@ private: }; CDATAMode m_cdataMode = None; - QString m_projectFile; + Utils::FilePath m_projectFile; QString m_className; QString m_testCase; QString m_formerTestCase; QString m_dataTag; ResultType m_result = ResultType::Invalid; QString m_description; - QString m_file; + Utils::FilePath m_file; int m_lineNumber = 0; QString m_duration; QXmlStreamReader m_xmlReader; diff --git a/src/plugins/autotest/qtest/qttestparser.cpp b/src/plugins/autotest/qtest/qttestparser.cpp index f40bab1d89d..d1c27723fce 100644 --- a/src/plugins/autotest/qtest/qttestparser.cpp +++ b/src/plugins/autotest/qtest/qttestparser.cpp @@ -81,7 +81,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus: return false; } -static bool qtTestLibDefined(const QString &fileName) +static bool qtTestLibDefined(const Utils::FilePath &fileName) { const QList parts = CppTools::CppModelManager::instance()->projectPart(fileName); @@ -93,10 +93,11 @@ static bool qtTestLibDefined(const QString &fileName) return false; } -QString QtTestParser::testClass(const CppTools::CppModelManager *modelManager, const QString &fileName) const +QString QtTestParser::testClass(const CppTools::CppModelManager *modelManager, + const Utils::FilePath &fileName) const { const QByteArray &fileContent = getFileContent(fileName); - CPlusPlus::Document::Ptr document = modelManager->document(fileName); + CPlusPlus::Document::Ptr document = modelManager->document(fileName.toString()); if (document.isNull()) return QString(); @@ -124,7 +125,7 @@ QString QtTestParser::testClass(const CppTools::CppModelManager *modelManager, c static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc, const CPlusPlus::Snapshot &snapshot, const QString &testCaseName, - const QStringList &alternativeFiles = {}, + const Utils::FilePaths &alternativeFiles = {}, int *line = nullptr, int *column = nullptr) { @@ -136,7 +137,7 @@ static CPlusPlus::Document::Ptr declaringDocument(CPlusPlus::Document::Ptr doc, doc->globalNamespace()); // fallback for inherited functions if (lookupItems.size() == 0 && !alternativeFiles.isEmpty()) { - for (const QString &alternativeFile : alternativeFiles) { + for (const Utils::FilePath &alternativeFile : alternativeFiles) { if (snapshot.contains(alternativeFile)) { CPlusPlus::Document::Ptr document = snapshot.document(alternativeFile); CPlusPlus::TypeOfExpression typeOfExpr; // we need a new one with no bindings @@ -181,7 +182,7 @@ static QSet filesWithDataFunctionDefinitions( QHash QtTestParser::checkForDataTags(const QString &fileName) const { - const QByteArray fileContent = getFileContent(fileName); + const QByteArray fileContent = getFileContent(Utils::FilePath::fromString(fileName)); CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName); document->check(); CPlusPlus::AST *ast = document->translationUnit()->ast(); @@ -278,7 +279,7 @@ static bool isQObject(const CPlusPlus::Document::Ptr &declaringDoc) } bool QtTestParser::processDocument(QFutureInterface futureInterface, - const QString &fileName) + const Utils::FilePath &fileName) { CPlusPlus::Document::Ptr doc = document(fileName); if (doc.isNull()) @@ -314,7 +315,8 @@ Utils::optional QtTestParser::fillTestCaseData( const QString &testCaseName, const CPlusPlus::Document::Ptr &doc, TestCaseData &data) const { - const QStringList &alternativeFiles = m_alternativeFiles.values(doc->fileName()); + const Utils::FilePath filePath = Utils::FilePath::fromString(doc->fileName()); + const Utils::FilePaths &alternativeFiles = m_alternativeFiles.values(filePath); CPlusPlus::Document::Ptr declaringDoc = declaringDocument(doc, m_cppSnapshot, testCaseName, alternativeFiles, &(data.line), &(data.column)); @@ -341,7 +343,7 @@ Utils::optional QtTestParser::fillTestCaseData( for (const QString &file : files) Utils::addToHash(&(data.dataTags), checkForDataTags(file)); - data.fileName = declaringDoc->fileName(); + data.fileName = Utils::FilePath::fromString(declaringDoc->fileName()); data.valid = true; return Utils::optional(); } @@ -356,7 +358,7 @@ QtTestParseResult *QtTestParser::createParseResult( parseResult->displayName = testCaseName; parseResult->line = data.line; parseResult->column = data.column; - parseResult->proFile = projectFile; + parseResult->proFile = Utils::FilePath::fromString(projectFile); QMap::ConstIterator it = data.testFunctions.begin(); const QMap::ConstIterator end = data.testFunctions.end(); for ( ; it != end; ++it) { @@ -367,7 +369,7 @@ QtTestParseResult *QtTestParser::createParseResult( func->itemType = location.m_type; func->name = testCaseName + "::" + functionName; func->displayName = functionName; - func->fileName = location.m_name; + func->fileName = Utils::FilePath::fromString(location.m_name); func->line = location.m_line; func->column = location.m_column; func->setInherited(location.m_inherited); @@ -378,7 +380,8 @@ QtTestParseResult *QtTestParser::createParseResult( dataTag->itemType = tag.m_type; dataTag->name = tag.m_name; dataTag->displayName = tag.m_name; - dataTag->fileName = data.testFunctions.value(it.key() + "_data").m_name; + dataTag->fileName = Utils::FilePath::fromString( + data.testFunctions.value(it.key() + "_data").m_name); dataTag->line = tag.m_line; dataTag->column = tag.m_column; dataTag->setInherited(tag.m_inherited); @@ -390,7 +393,7 @@ QtTestParseResult *QtTestParser::createParseResult( return parseResult; } -void QtTestParser::init(const QStringList &filesToParse, bool fullParse) +void QtTestParser::init(const Utils::FilePaths &filesToParse, bool fullParse) { if (!fullParse) { // in a full parse cached information might lead to wrong results m_testCaseNames = QTestUtils::testCaseNamesForFiles(framework(), filesToParse); diff --git a/src/plugins/autotest/qtest/qttestparser.h b/src/plugins/autotest/qtest/qttestparser.h index be46435a6f8..861bf2dfa96 100644 --- a/src/plugins/autotest/qtest/qttestparser.h +++ b/src/plugins/autotest/qtest/qttestparser.h @@ -52,16 +52,17 @@ class QtTestParser : public CppParser public: explicit QtTestParser(ITestFramework *framework) : CppParser(framework) {} - void init(const QStringList &filesToParse, bool fullParse) override; + void init(const Utils::FilePaths &filesToParse, bool fullParse) override; void release() override; bool processDocument(QFutureInterface futureInterface, - const QString &fileName) override; + const Utils::FilePath &fileName) override; private: - QString testClass(const CppTools::CppModelManager *modelManager, const QString &fileName) const; + QString testClass(const CppTools::CppModelManager *modelManager, + const Utils::FilePath &fileName) const; QHash checkForDataTags(const QString &fileName) const; struct TestCaseData { - QString fileName; + Utils::FilePath fileName; int line = 0; int column = 0; QMap testFunctions; @@ -74,8 +75,8 @@ private: TestCaseData &data) const; QtTestParseResult *createParseResult(const QString &testCaseName, const TestCaseData &data, const QString &projectFile) const; - QHash m_testCaseNames; - QMultiHash m_alternativeFiles; + QHash m_testCaseNames; + QMultiHash m_alternativeFiles; }; } // namespace Internal diff --git a/src/plugins/autotest/qtest/qttestresult.cpp b/src/plugins/autotest/qtest/qttestresult.cpp index e1b9edc22f3..aa16f601963 100644 --- a/src/plugins/autotest/qtest/qttestresult.cpp +++ b/src/plugins/autotest/qtest/qttestresult.cpp @@ -34,7 +34,7 @@ namespace Autotest { namespace Internal { -QtTestResult::QtTestResult(const QString &id, const QString &projectFile, TestType type, +QtTestResult::QtTestResult(const QString &id, const Utils::FilePath &projectFile, TestType type, const QString &className) : TestResult(id, className), m_projectFile(projectFile), m_type(type) { diff --git a/src/plugins/autotest/qtest/qttestresult.h b/src/plugins/autotest/qtest/qttestresult.h index e2c1ae2e672..949ec638173 100644 --- a/src/plugins/autotest/qtest/qttestresult.h +++ b/src/plugins/autotest/qtest/qttestresult.h @@ -37,7 +37,7 @@ namespace Internal { class QtTestResult : public TestResult { public: - QtTestResult(const QString &id, const QString &projectFile, TestType type, + QtTestResult(const QString &id, const Utils::FilePath &projectFile, TestType type, const QString &className); const QString outputString(bool selected) const override; @@ -59,7 +59,7 @@ private: QString m_function; QString m_dataTag; - QString m_projectFile; + Utils::FilePath m_projectFile; TestType m_type; }; diff --git a/src/plugins/autotest/qtest/qttesttreeitem.cpp b/src/plugins/autotest/qtest/qttesttreeitem.cpp index 3bdcf14a5ba..98cde79ee12 100644 --- a/src/plugins/autotest/qtest/qttesttreeitem.cpp +++ b/src/plugins/autotest/qtest/qttesttreeitem.cpp @@ -36,7 +36,7 @@ namespace Autotest { namespace Internal { QtTestTreeItem::QtTestTreeItem(ITestFramework *testFramework, const QString &name, - const QString &filePath, TestTreeItem::Type type) + const Utils::FilePath &filePath, TestTreeItem::Type type) : TestTreeItem(testFramework, name, filePath, type) { if (type == TestDataTag) @@ -291,9 +291,8 @@ QList QtTestTreeItem::getTestConfigurationsForFile(const U return result; QHash testFunctions; - const QString &file = fileName.toString(); - forAllChildItems([&testFunctions, &file](TestTreeItem *node) { - if (node->type() == Type::TestFunction && node->filePath() == file) { + forAllChildItems([&testFunctions, &fileName](TestTreeItem *node) { + if (node->type() == Type::TestFunction && node->filePath() == fileName) { QTC_ASSERT(node->parentItem(), return); TestTreeItem *testCase = node->parentItem(); QTC_ASSERT(testCase->type() == Type::TestCase, return); @@ -318,7 +317,7 @@ TestTreeItem *QtTestTreeItem::find(const TestParseResult *result) switch (type()) { case Root: if (result->framework->grouping()) { - const QString path = QFileInfo(result->fileName).absolutePath(); + const Utils::FilePath path = result->fileName.absolutePath(); for (int row = 0; row < childCount(); ++row) { TestTreeItem *group = childItem(row); if (group->filePath() != path) @@ -357,7 +356,7 @@ TestTreeItem *QtTestTreeItem::findChild(const TestTreeItem *other) if (otherType != TestFunction && otherType != TestDataFunction && otherType != TestSpecialFunction) return nullptr; auto qtOther = static_cast(other); - return findChildByNameAndInheritance(other->filePath(), qtOther->inherited()); + return findChildByNameAndInheritance(other->name(), qtOther->inherited()); } case TestFunction: case TestDataFunction: @@ -388,9 +387,8 @@ bool QtTestTreeItem::modify(const TestParseResult *result) TestTreeItem *QtTestTreeItem::createParentGroupNode() const { - const QFileInfo fileInfo(filePath()); - const QFileInfo base(fileInfo.absolutePath()); - return new QtTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); + const QFileInfo base = filePath().absolutePath().toFileInfo(); + return new QtTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), TestTreeItem::GroupNode); } bool QtTestTreeItem::isGroupable() const diff --git a/src/plugins/autotest/qtest/qttesttreeitem.h b/src/plugins/autotest/qtest/qttesttreeitem.h index d3583c4a92d..087e1d79b8f 100644 --- a/src/plugins/autotest/qtest/qttesttreeitem.h +++ b/src/plugins/autotest/qtest/qttesttreeitem.h @@ -34,7 +34,7 @@ class QtTestTreeItem : public TestTreeItem { public: explicit QtTestTreeItem(ITestFramework *framework, const QString &name = QString(), - const QString &filePath = QString(), Type type = Root); + const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root); TestTreeItem *copyWithoutChildren() override; QVariant data(int column, int role) const override; diff --git a/src/plugins/autotest/quick/quicktest_utils.cpp b/src/plugins/autotest/quick/quicktest_utils.cpp index ef7dc81f37b..c25009a1ff7 100644 --- a/src/plugins/autotest/quick/quicktest_utils.cpp +++ b/src/plugins/autotest/quick/quicktest_utils.cpp @@ -43,9 +43,10 @@ bool isQuickTestMacro(const QByteArray ¯o) return valid.contains(macro); } -QHash proFilesForQmlFiles(ITestFramework *framework, const QStringList &files) +QHash proFilesForQmlFiles(ITestFramework *framework, + const Utils::FilePaths &files) { - QHash result; + QHash result; TestTreeItem *rootNode = framework->rootNode(); QTC_ASSERT(rootNode, return result); @@ -53,16 +54,16 @@ QHash proFilesForQmlFiles(ITestFramework *framework, const QSt return result; rootNode->forFirstLevelChildItems([&result, &files](TestTreeItem *child) { - const QString &file = child->filePath(); + const Utils::FilePath &file = child->filePath(); if (!file.isEmpty() && files.contains(file)) { - const QString &proFile = child->proFile(); + const Utils::FilePath &proFile = child->proFile(); if (!proFile.isEmpty()) result.insert(file, proFile); } child->forFirstLevelChildItems([&result, &files](TestTreeItem *grandChild) { - const QString &file = grandChild->filePath(); + const Utils::FilePath &file = grandChild->filePath(); if (!file.isEmpty() && files.contains(file)) { - const QString &proFile = grandChild->proFile(); + const Utils::FilePath &proFile = grandChild->proFile(); if (!proFile.isEmpty()) result.insert(file, proFile); } diff --git a/src/plugins/autotest/quick/quicktest_utils.h b/src/plugins/autotest/quick/quicktest_utils.h index 3fc919ce67a..51f52f38bac 100644 --- a/src/plugins/autotest/quick/quicktest_utils.h +++ b/src/plugins/autotest/quick/quicktest_utils.h @@ -25,6 +25,8 @@ #pragma once +#include + #include namespace Autotest { @@ -35,7 +37,8 @@ namespace Internal { namespace QuickTestUtils { bool isQuickTestMacro(const QByteArray ¯o); -QHash proFilesForQmlFiles(ITestFramework *framework, const QStringList &files); +QHash proFilesForQmlFiles(ITestFramework *framework, + const Utils::FilePaths &files); } // namespace QuickTestUtils } // namespace Internal diff --git a/src/plugins/autotest/quick/quicktestframework.cpp b/src/plugins/autotest/quick/quicktestframework.cpp index 39763bc07a1..e4fecb1daf0 100644 --- a/src/plugins/autotest/quick/quicktestframework.cpp +++ b/src/plugins/autotest/quick/quicktestframework.cpp @@ -42,7 +42,7 @@ ITestParser *QuickTestFramework::createTestParser() ITestTreeItem *QuickTestFramework::createRootNode() { return new QuickTestTreeItem(this, QCoreApplication::translate("QuickTestFramework", "Quick Test"), - QString(), ITestTreeItem::Root); + Utils::FilePath(), ITestTreeItem::Root); } const char *QuickTestFramework::name() const diff --git a/src/plugins/autotest/quick/quicktestparser.cpp b/src/plugins/autotest/quick/quicktestparser.cpp index c08d0da3cf3..fdd045bb31c 100644 --- a/src/plugins/autotest/quick/quicktestparser.cpp +++ b/src/plugins/autotest/quick/quicktestparser.cpp @@ -91,7 +91,7 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc, } static QString quickTestSrcDir(const CppTools::CppModelManager *cppMM, - const QString &fileName) + const Utils::FilePath &fileName) { const QList parts = cppMM->projectPart(fileName); if (parts.size() > 0) { @@ -122,14 +122,14 @@ QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) cons const QByteArray name = macro.macro().name(); if (QuickTestUtils::isQuickTestMacro(name)) { CPlusPlus::Document::Block arg = macro.arguments().at(0); - return QLatin1String(getFileContent(doc->fileName()) + return QLatin1String(getFileContent(Utils::FilePath::fromString(doc->fileName())) .mid(int(arg.bytesBegin()), int(arg.bytesEnd() - arg.bytesBegin()))); } } // check for using quick_test_main() directly const QString fileName = doc->fileName(); - const QByteArray &fileContent = getFileContent(fileName); + const QByteArray &fileContent = getFileContent(Utils::FilePath::fromString(fileName)); CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, fileName); if (document.isNull()) return QString(); @@ -182,7 +182,7 @@ QList QuickTestParser::scanDirectoryForQuickTestQmlFiles(const QS static bool checkQmlDocumentForQuickTestCode(QFutureInterface futureInterface, const Document::Ptr &qmlJSDoc, ITestFramework *framework, - const QString &proFile = QString()) + const Utils::FilePath &proFile = Utils::FilePath()) { if (qmlJSDoc.isNull()) return false; @@ -203,7 +203,7 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterfaceproFile = proFile; parseResult->itemType = TestTreeItem::TestCase; if (!testCaseName.isEmpty()) { - parseResult->fileName = testCase.m_locationAndType.m_name; + parseResult->fileName = Utils::FilePath::fromString(testCase.m_locationAndType.m_name); parseResult->name = testCaseName; parseResult->line = testCase.m_locationAndType.m_line; parseResult->column = testCase.m_locationAndType.m_column; @@ -214,7 +214,7 @@ static bool checkQmlDocumentForQuickTestCode(QFutureInterfacename = function.m_functionName; funcResult->displayName = function.m_functionName; funcResult->itemType = function.m_locationAndType.m_type; - funcResult->fileName = function.m_locationAndType.m_name; + funcResult->fileName = Utils::FilePath::fromString(function.m_locationAndType.m_name); funcResult->line = function.m_locationAndType.m_line; funcResult->column = function.m_locationAndType.m_column; funcResult->proFile = proFile; @@ -235,11 +235,11 @@ bool QuickTestParser::handleQtQuickTest(QFutureInterface fut if (quickTestName(document).isEmpty()) return false; - const QString cppFileName = document->fileName(); - QList ppList = modelManager->projectPart(cppFileName); + QList ppList = modelManager->projectPart(document->fileName()); if (ppList.isEmpty()) // happens if shutting down while parsing return false; - const QString &proFile = ppList.at(0)->projectFile; + const Utils::FilePath cppFileName = Utils::FilePath::fromString(document->fileName()); + const Utils::FilePath proFile = Utils::FilePath::fromString(ppList.at(0)->projectFile); m_mainCppFiles.insert(cppFileName, proFile); const QString srcDir = quickTestSrcDir(modelManager, cppFileName); if (srcDir.isEmpty()) @@ -315,14 +315,14 @@ QuickTestParser::QuickTestParser(ITestFramework *framework) this, &QuickTestParser::handleDirectoryChanged); } -void QuickTestParser::init(const QStringList &filesToParse, bool fullParse) +void QuickTestParser::init(const Utils::FilePaths &filesToParse, bool fullParse) { m_qmlSnapshot = QmlJSTools::Internal::ModelManager::instance()->snapshot(); if (!fullParse) { // in a full parse we get the correct entry points by the respective main m_proFilesForQmlFiles = QuickTestUtils::proFilesForQmlFiles(framework(), filesToParse); // get rid of cached main cpp files that are going to get processed anyhow - for (const QString &file : filesToParse) { + for (const Utils::FilePath &file : filesToParse) { if (m_mainCppFiles.contains(file)) { m_mainCppFiles.remove(file); if (m_mainCppFiles.isEmpty()) @@ -344,13 +344,13 @@ void QuickTestParser::release() } bool QuickTestParser::processDocument(QFutureInterface futureInterface, - const QString &fileName) + const Utils::FilePath &fileName) { if (fileName.endsWith(".qml")) { - const QString &proFile = m_proFilesForQmlFiles.value(fileName); + const Utils::FilePath &proFile = m_proFilesForQmlFiles.value(fileName); if (proFile.isEmpty()) return false; - Document::Ptr qmlJSDoc = m_qmlSnapshot.document(fileName); + Document::Ptr qmlJSDoc = m_qmlSnapshot.document(fileName.toString()); return checkQmlDocumentForQuickTestCode(futureInterface, qmlJSDoc, framework(), proFile); } if (!m_cppSnapshot.contains(fileName) || !selectedForBuilding(fileName)) @@ -361,9 +361,9 @@ bool QuickTestParser::processDocument(QFutureInterface futur return handleQtQuickTest(futureInterface, document, framework()); } -QString QuickTestParser::projectFileForMainCppFile(const QString &fileName) const +Utils::FilePath QuickTestParser::projectFileForMainCppFile(const Utils::FilePath &fileName) const { - return m_mainCppFiles.contains(fileName) ? m_mainCppFiles.value(fileName) : QString(); + return m_mainCppFiles.contains(fileName) ? m_mainCppFiles.value(fileName) : Utils::FilePath(); } } // namespace Internal diff --git a/src/plugins/autotest/quick/quicktestparser.h b/src/plugins/autotest/quick/quicktestparser.h index 51dde56fe61..440e54a73e2 100644 --- a/src/plugins/autotest/quick/quicktestparser.h +++ b/src/plugins/autotest/quick/quicktestparser.h @@ -46,11 +46,11 @@ class QuickTestParser : public QObject, public CppParser Q_OBJECT public: explicit QuickTestParser(ITestFramework *framework); - void init(const QStringList &filesToParse, bool fullParse) override; + void init(const Utils::FilePaths &filesToParse, bool fullParse) override; void release() override; bool processDocument(QFutureInterface futureInterface, - const QString &fileName) override; - QString projectFileForMainCppFile(const QString &fileName) const; + const Utils::FilePath &fileName) override; + Utils::FilePath projectFileForMainCppFile(const Utils::FilePath &fileName) const; private: bool handleQtQuickTest(QFutureInterface futureInterface, CPlusPlus::Document::Ptr document, ITestFramework *framework); @@ -59,10 +59,10 @@ private: QString quickTestName(const CPlusPlus::Document::Ptr &doc) const; QList scanDirectoryForQuickTestQmlFiles(const QString &srcDir); QmlJS::Snapshot m_qmlSnapshot; - QHash m_proFilesForQmlFiles; + QHash m_proFilesForQmlFiles; QFileSystemWatcher m_directoryWatcher; QMap > m_watchedFiles; - QMap m_mainCppFiles; + QMap m_mainCppFiles; }; } // namespace Internal diff --git a/src/plugins/autotest/quick/quicktesttreeitem.cpp b/src/plugins/autotest/quick/quicktesttreeitem.cpp index 2e449cf93b2..f4015a1f3ff 100644 --- a/src/plugins/autotest/quick/quicktesttreeitem.cpp +++ b/src/plugins/autotest/quick/quicktesttreeitem.cpp @@ -36,7 +36,7 @@ namespace Autotest { namespace Internal { -QSet internalTargets(const QString &proFile); +QSet internalTargets(const Utils::FilePath &proFile); TestTreeItem *QuickTestTreeItem::copyWithoutChildren() { @@ -170,7 +170,7 @@ static QList testConfigurationsFor( if (!project || rootNode->type() != TestTreeItem::Root) return {}; - QHash configurationForProFiles; + QHash configurationForProFiles; rootNode->forSelectedChildren([&predicate, &configurationForProFiles](Utils::TreeItem *it) { auto treeItem = static_cast(it); if (treeItem->type() == TestTreeItem::Root || treeItem->type() == TestTreeItem::GroupNode) @@ -229,12 +229,12 @@ QList QuickTestTreeItem::getAllTestConfigurations() const if (!project || type() != Root) return result; - QHash testsForProfile; + QHash testsForProfile; forFirstLevelChildItems([&testsForProfile](TestTreeItem *child) { // unnamed Quick Tests must be handled separately if (child->name().isEmpty()) { child->forFirstLevelChildItems([&testsForProfile](TestTreeItem *grandChild) { - const QString &proFile = grandChild->proFile(); + const Utils::FilePath &proFile = grandChild->proFile(); ++(testsForProfile[proFile].testCount); testsForProfile[proFile].internalTargets = internalTargets(grandChild->proFile()); }); @@ -278,9 +278,8 @@ QList QuickTestTreeItem::getFailedTestConfigurations() con QList QuickTestTreeItem::getTestConfigurationsForFile( const Utils::FilePath &fileName) const { - const QString &file = fileName.toString(); - return testConfigurationsFor(this, [&file](TestTreeItem *it) { - return it->filePath() == file; + return testConfigurationsFor(this, [&fileName](TestTreeItem *it) { + return it->filePath() == fileName; }); } @@ -293,7 +292,7 @@ TestTreeItem *QuickTestTreeItem::find(const TestParseResult *result) if (result->name.isEmpty()) return unnamedQuickTests(); if (result->framework->grouping()) { - const QString path = QFileInfo(result->fileName).absolutePath(); + const Utils::FilePath path = result->fileName.absolutePath(); TestTreeItem *group = findFirstLevelChildItem([path](TestTreeItem *group) { return group->filePath() == path; }); @@ -376,9 +375,8 @@ bool QuickTestTreeItem::removeOnSweepIfEmpty() const TestTreeItem *QuickTestTreeItem::createParentGroupNode() const { - const QFileInfo fileInfo(filePath()); - const QFileInfo base(fileInfo.absolutePath()); - return new QuickTestTreeItem(framework(), base.baseName(), fileInfo.absolutePath(), TestTreeItem::GroupNode); + const QFileInfo base = filePath().absolutePath().toFileInfo(); + return new QuickTestTreeItem(framework(), base.baseName(), filePath().absolutePath(), TestTreeItem::GroupNode); } bool QuickTestTreeItem::isGroupable() const @@ -386,7 +384,7 @@ bool QuickTestTreeItem::isGroupable() const return type() == TestCase && !name().isEmpty() && !filePath().isEmpty(); } -QSet internalTargets(const QString &proFile) +QSet internalTargets(const Utils::FilePath &proFile) { QSet result; const auto cppMM = CppTools::CppModelManager::instance(); @@ -394,17 +392,17 @@ QSet internalTargets(const QString &proFile) for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo.projectParts()) { if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable) continue; - if (projectPart->projectFile == proFile) + if (projectPart->projectFile == proFile.toString()) result.insert(projectPart->buildSystemTarget); } return result; } -void QuickTestTreeItem::markForRemovalRecursively(const QString &filePath) +void QuickTestTreeItem::markForRemovalRecursively(const Utils::FilePath &filePath) { TestTreeItem::markForRemovalRecursively(filePath); auto parser = dynamic_cast(framework()->testParser()); - const QString proFile = parser->projectFileForMainCppFile(filePath); + const Utils::FilePath proFile = parser->projectFileForMainCppFile(filePath); if (!proFile.isEmpty()) { TestTreeItem *root = framework()->rootNode(); root->forAllChildItems([proFile](TestTreeItem *it) { @@ -414,7 +412,7 @@ void QuickTestTreeItem::markForRemovalRecursively(const QString &filePath) } } -TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const QString &filePath, +TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const Utils::FilePath &filePath, const QString &name, TestTreeItem::Type tType) @@ -425,7 +423,8 @@ TestTreeItem *QuickTestTreeItem::findChildByFileNameAndType(const QString &fileP } TestTreeItem *QuickTestTreeItem::findChildByNameFileAndLine(const QString &name, - const QString &filePath, int line) + const Utils::FilePath &filePath, + int line) { return findFirstLevelChildItem([name, filePath, line](const TestTreeItem *other) { return other->filePath() == filePath && other->line() == line && other->name() == name; diff --git a/src/plugins/autotest/quick/quicktesttreeitem.h b/src/plugins/autotest/quick/quicktesttreeitem.h index 5397d01f779..f9977b1bec7 100644 --- a/src/plugins/autotest/quick/quicktesttreeitem.h +++ b/src/plugins/autotest/quick/quicktesttreeitem.h @@ -35,7 +35,7 @@ class QuickTestTreeItem : public TestTreeItem public: explicit QuickTestTreeItem(ITestFramework *testFramework, const QString &name = QString(), - const QString &filePath = QString(), + const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root) : TestTreeItem(testFramework, name, filePath, type) {} @@ -59,11 +59,11 @@ public: bool removeOnSweepIfEmpty() const override; TestTreeItem *createParentGroupNode() const override; bool isGroupable() const override; - void markForRemovalRecursively(const QString &filePath) override; + void markForRemovalRecursively(const Utils::FilePath &filePath) override; private: - TestTreeItem *findChildByFileNameAndType(const QString &filePath, const QString &name, + TestTreeItem *findChildByFileNameAndType(const Utils::FilePath &filePath, const QString &name, Type tType); - TestTreeItem *findChildByNameFileAndLine(const QString &name, const QString &filePath, + TestTreeItem *findChildByNameFileAndLine(const QString &name, const Utils::FilePath &filePath, int line); TestTreeItem *unnamedQuickTests() const; }; diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index c2afe3846de..f2fc52778de 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -163,12 +163,12 @@ void TestCodeParser::updateTestTree(const QSet &parsers) Utils::sort(sortedParsers, [](const ITestParser *lhs, const ITestParser *rhs) { return lhs->framework()->priority() < rhs->framework()->priority(); }); - scanForTests(QStringList(), sortedParsers); + scanForTests(Utils::FilePaths(), sortedParsers); } /****** threaded parsing stuff *******/ -void TestCodeParser::onDocumentUpdated(const QString &fileName, bool isQmlFile) +void TestCodeParser::onDocumentUpdated(const Utils::FilePath &fileName, bool isQmlFile) { if (m_codeModelParsing || m_fullUpdatePostponed) return; @@ -177,22 +177,22 @@ void TestCodeParser::onDocumentUpdated(const QString &fileName, bool isQmlFile) if (!project) return; // Quick tests: qml files aren't necessarily listed inside project files - if (!isQmlFile && !project->isKnownFile(Utils::FilePath::fromString(fileName))) + if (!isQmlFile && !project->isKnownFile(fileName)) return; - scanForTests(QStringList(fileName)); + scanForTests(Utils::FilePaths{fileName}); } void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document) { - onDocumentUpdated(document->fileName()); + onDocumentUpdated(Utils::FilePath::fromString(document->fileName())); } void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document) { const QString fileName = document->fileName(); if (!fileName.endsWith(".qbs")) - onDocumentUpdated(fileName, true); + onDocumentUpdated(Utils::FilePath::fromString(fileName), true); } void TestCodeParser::onStartupProjectChanged(Project *project) @@ -227,7 +227,7 @@ void TestCodeParser::aboutToShutdown() } } -bool TestCodeParser::postponed(const QStringList &fileList) +bool TestCodeParser::postponed(const Utils::FilePaths &fileList) { switch (m_parserState) { case Idle: @@ -270,7 +270,7 @@ bool TestCodeParser::postponed(const QStringList &fileList) if (m_fullUpdatePostponed) return true; // partial parse triggered, postpone or add current files to already postponed partial - for (const QString &file : fileList) + for (const Utils::FilePath &file : fileList) m_postponedFiles.insert(file); m_partialUpdatePostponed = true; } @@ -283,7 +283,7 @@ bool TestCodeParser::postponed(const QStringList &fileList) static void parseFileForTests(const QList &parsers, QFutureInterface &futureInterface, - const QString &fileName) + const Utils::FilePath &fileName) { for (ITestParser *parser : parsers) { if (futureInterface.isCanceled()) @@ -293,7 +293,8 @@ static void parseFileForTests(const QList &parsers, } } -void TestCodeParser::scanForTests(const QStringList &fileList, const QList &parsers) +void TestCodeParser::scanForTests(const Utils::FilePaths &fileList, + const QList &parsers) { if (m_parserState == Shutdown || m_testCodeParsers.isEmpty()) return; @@ -308,9 +309,9 @@ void TestCodeParser::scanForTests(const QStringList &fileList, const QListfiles(Project::SourceFiles), &Utils::FilePath::toString); + list = project->files(Project::SourceFiles); if (list.isEmpty()) { // at least project file should be there, but might happen if parsing current project // takes too long, especially when opening sessions holding multiple projects @@ -330,7 +331,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList, const QListupdateCheckStateCache(); if (isFullParse) { // remove qml files as they will be found automatically by the referencing cpp file - list = Utils::filtered(list, [] (const QString &fn) { + list = Utils::filtered(list, [] (const Utils::FilePath &fn) { return !fn.endsWith(".qml"); }); if (!parsers.isEmpty()) { @@ -342,12 +343,11 @@ void TestCodeParser::scanForTests(const QStringList &fileList, const QListframework()->rootNode()->markForRemovalRecursively(filePath); - } } } else { - for (const QString &filePath : qAsConst(list)) + for (const Utils::FilePath &filePath : qAsConst(list)) emit requestRemoval(filePath); } @@ -360,7 +360,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList, const QListinit(list, isFullParse); QFuture future = Utils::map(list, - [codeParsers](QFutureInterface &fi, const QString &file) { + [codeParsers](QFutureInterface &fi, const Utils::FilePath &file) { parseFileForTests(codeParsers, fi, file); }, Utils::MapReduceOption::Unordered, diff --git a/src/plugins/autotest/testcodeparser.h b/src/plugins/autotest/testcodeparser.h index c426c274da7..85e6f505fec 100644 --- a/src/plugins/autotest/testcodeparser.h +++ b/src/plugins/autotest/testcodeparser.h @@ -74,7 +74,7 @@ signals: void parsingStarted(); void parsingFinished(); void parsingFailed(); - void requestRemoval(const QString &filePath); + void requestRemoval(const Utils::FilePath &filePath); void requestRemoveAllFrameworkItems(); public: @@ -87,12 +87,12 @@ public: void aboutToShutdown(); private: - bool postponed(const QStringList &fileList); - void scanForTests(const QStringList &fileList = QStringList(), + bool postponed(const Utils::FilePaths &fileList); + void scanForTests(const Utils::FilePaths &fileList = Utils::FilePaths(), const QList &parsers = {}); // qml files must be handled slightly different - void onDocumentUpdated(const QString &fileName, bool isQmlFile = false); + void onDocumentUpdated(const Utils::FilePath &fileName, bool isQmlFile = false); void onTaskStarted(Utils::Id type); void onAllTasksFinished(Utils::Id type); void onFinished(); @@ -110,7 +110,7 @@ private: bool m_dirty = false; bool m_singleShotScheduled = false; bool m_reparseTimerTimedOut = false; - QSet m_postponedFiles; + QSet m_postponedFiles; State m_parserState = Idle; QFutureWatcher m_futureWatcher; QList m_testCodeParsers; // ptrs are still owned by TestFrameworkManager diff --git a/src/plugins/autotest/testconfiguration.cpp b/src/plugins/autotest/testconfiguration.cpp index 4e032e8a6eb..e15fe3ac570 100644 --- a/src/plugins/autotest/testconfiguration.cpp +++ b/src/plugins/autotest/testconfiguration.cpp @@ -62,16 +62,16 @@ void ITestConfiguration::setWorkingDirectory(const QString &workingDirectory) m_runnable.workingDirectory = workingDirectory; } -QString ITestConfiguration::workingDirectory() const +Utils::FilePath ITestConfiguration::workingDirectory() const { if (!m_runnable.workingDirectory.isEmpty()) { const QFileInfo info(m_runnable.workingDirectory); if (info.isDir()) // ensure wanted working dir does exist - return info.absoluteFilePath(); + return Utils::FilePath::fromString(info.absoluteFilePath()); } - const QString executable = executableFilePath(); - return executable.isEmpty() ? executable : QFileInfo(executable).absolutePath(); + const Utils::FilePath executable = executableFilePath(); + return executable.isEmpty() ? executable : executable.absolutePath(); } bool ITestConfiguration::hasExecutable() const @@ -79,15 +79,15 @@ bool ITestConfiguration::hasExecutable() const return !m_runnable.executable.isEmpty(); } -QString ITestConfiguration::executableFilePath() const +Utils::FilePath ITestConfiguration::executableFilePath() const { if (!hasExecutable()) - return QString(); + return {}; QFileInfo commandFileInfo = m_runnable.executable.toFileInfo(); - if (commandFileInfo.isExecutable() && commandFileInfo.path() != ".") { - return commandFileInfo.absoluteFilePath(); - } else if (commandFileInfo.path() == "."){ + if (m_runnable.executable.isExecutableFile() && m_runnable.executable.path() != ".") { + return m_runnable.executable.absoluteFilePath(); + } else if (m_runnable.executable.path() == "."){ QString fullCommandFileName = m_runnable.executable.toString(); // TODO: check if we can use searchInPath() from Utils::Environment const QStringList &pathList = m_runnable.environment.toProcessEnvironment().value("PATH") @@ -96,10 +96,10 @@ QString ITestConfiguration::executableFilePath() const for (const QString &path : pathList) { QString filePath(path + QDir::separator() + fullCommandFileName); if (QFileInfo(filePath).isExecutable()) - return commandFileInfo.absoluteFilePath(); + return m_runnable.executable.absoluteFilePath(); } } - return QString(); + return {}; } Environment ITestConfiguration::filteredEnvironment(const Environment &original) const @@ -158,12 +158,12 @@ void TestConfiguration::completeTestInformation(ProjectExplorer::RunConfiguratio if (!targetInfo.targetFilePath.isEmpty()) m_runnable.executable = ensureExeEnding(targetInfo.targetFilePath); - QString buildBase; + Utils::FilePath buildBase; if (auto buildConfig = target->activeBuildConfiguration()) { - buildBase = buildConfig->buildDirectory().toString(); + buildBase = buildConfig->buildDirectory(); const QString projBase = startupProject->projectDirectory().toString(); if (m_projectFile.startsWith(projBase)) - m_buildDir = QFileInfo(buildBase + m_projectFile.mid(projBase.length())).absolutePath(); + m_buildDir = (buildBase / m_projectFile.toString().mid(projBase.length())).absolutePath(); } if (runMode == TestRunMode::Debug || runMode == TestRunMode::DebugWithoutDeploy) m_runConfig = new Internal::TestRunConfiguration(rc->target(), this); @@ -225,12 +225,12 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode) if (localExecutable.isEmpty()) return; - QString buildBase; + Utils::FilePath buildBase; if (auto buildConfig = target->activeBuildConfiguration()) { - buildBase = buildConfig->buildDirectory().toString(); + buildBase = buildConfig->buildDirectory(); const QString projBase = startupProject->projectDirectory().toString(); if (m_projectFile.startsWith(projBase)) - m_buildDir = QFileInfo(buildBase + m_projectFile.mid(projBase.length())).absolutePath(); + m_buildDir = (buildBase / m_projectFile.toString().mid(projBase.length())).absolutePath(); } // deployment information should get taken into account, but it pretty much seems as if @@ -323,12 +323,12 @@ void TestConfiguration::setExecutableFile(const QString &executableFile) m_runnable.executable = Utils::FilePath::fromString(executableFile); } -void TestConfiguration::setProjectFile(const QString &projectFile) +void TestConfiguration::setProjectFile(const Utils::FilePath &projectFile) { m_projectFile = projectFile; } -void TestConfiguration::setBuildDirectory(const QString &buildDirectory) +void TestConfiguration::setBuildDirectory(const FilePath &buildDirectory) { m_buildDir = buildDirectory; } diff --git a/src/plugins/autotest/testconfiguration.h b/src/plugins/autotest/testconfiguration.h index a065c045f9a..2d6c36544d2 100644 --- a/src/plugins/autotest/testconfiguration.h +++ b/src/plugins/autotest/testconfiguration.h @@ -61,9 +61,9 @@ public: void setEnvironment(const Utils::Environment &env) { m_runnable.environment = env; } Utils::Environment environment() const { return m_runnable.environment; } void setWorkingDirectory(const QString &workingDirectory); - QString workingDirectory() const; + Utils::FilePath workingDirectory() const; bool hasExecutable() const; - QString executableFilePath() const; + Utils::FilePath executableFilePath() const; virtual TestOutputReader *outputReader(const QFutureInterface &fi, QProcess *app) const = 0; @@ -99,16 +99,16 @@ public: void setTestCases(const QStringList &testCases); void setExecutableFile(const QString &executableFile); - void setProjectFile(const QString &projectFile); - void setBuildDirectory(const QString &buildDirectory); + void setProjectFile(const Utils::FilePath &projectFile); + void setBuildDirectory(const Utils::FilePath &buildDirectory); void setInternalTarget(const QString &target); void setInternalTargets(const QSet &targets); void setOriginalRunConfiguration(ProjectExplorer::RunConfiguration *runConfig); ITestFramework *framework() const; QStringList testCases() const { return m_testCases; } - QString buildDirectory() const { return m_buildDir; } - QString projectFile() const { return m_projectFile; } + Utils::FilePath buildDirectory() const { return m_buildDir; } + Utils::FilePath projectFile() const { return m_projectFile; } QSet internalTargets() const { return m_buildTargets; } ProjectExplorer::RunConfiguration *originalRunConfiguration() const { return m_origRunConfig; } Internal::TestRunConfiguration *runConfiguration() const { return m_runConfig; } @@ -120,8 +120,8 @@ public: private: QStringList m_testCases; - QString m_projectFile; - QString m_buildDir; + Utils::FilePath m_projectFile; + Utils::FilePath m_buildDir; QString m_deducedFrom; bool m_deducedConfiguration = false; Internal::TestRunConfiguration *m_runConfig = nullptr; diff --git a/src/plugins/autotest/testoutputreader.cpp b/src/plugins/autotest/testoutputreader.cpp index dcbb61a0c2e..403f086de5f 100644 --- a/src/plugins/autotest/testoutputreader.cpp +++ b/src/plugins/autotest/testoutputreader.cpp @@ -38,8 +38,16 @@ namespace Autotest { +Utils::FilePath TestOutputReader::constructSourceFilePath(const Utils::FilePath &path, + const QString &filePath) +{ + if (!filePath.isEmpty() && filePath.at(0) != '.') + return Utils::FilePath::fromFileInfo(QFileInfo(filePath)); + return (path / filePath).canonicalPath(); +} + TestOutputReader::TestOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory) + QProcess *testApplication, const Utils::FilePath &buildDirectory) : m_futureInterface(futureInterface) , m_testApplication(testApplication) , m_buildDir(buildDirectory) @@ -167,9 +175,11 @@ void TestOutputReader::checkForSanitizerOutput(const QByteArray &line) m_sanitizerLines.append("Sanitizer Issue"); m_sanitizerLines.append(lineStr); if (m_sanitizerOutputMode == SanitizerOutputMode::Ubsan) { - const QString path = QFileInfo(m_buildDir, match.captured(1)).canonicalFilePath(); + const Utils::FilePath path = constructSourceFilePath(m_buildDir, match.captured(1)); // path may be empty if not existing - so, provide at least what we have - m_sanitizerResult->setFileName(path.isEmpty() ? match.captured(1) : path); + m_sanitizerResult->setFileName(path.isEmpty() + ? Utils::FilePath::fromString(match.captured(1)) + : path); m_sanitizerResult->setLine(match.captured(2).toInt()); } } diff --git a/src/plugins/autotest/testoutputreader.h b/src/plugins/autotest/testoutputreader.h index d4dd5c46983..b3d7cc3476d 100644 --- a/src/plugins/autotest/testoutputreader.h +++ b/src/plugins/autotest/testoutputreader.h @@ -39,7 +39,7 @@ class TestOutputReader : public QObject Q_OBJECT public: TestOutputReader(const QFutureInterface &futureInterface, - QProcess *testApplication, const QString &buildDirectory); + QProcess *testApplication, const Utils::FilePath &buildDirectory); virtual ~TestOutputReader(); void processStdOutput(const QByteArray &outputLine); virtual void processStdError(const QByteArray &outputLine); @@ -56,6 +56,9 @@ public: signals: void newOutputLineAvailable(const QByteArray &outputLine, OutputChannel channel); protected: + static Utils::FilePath constructSourceFilePath(const Utils::FilePath &base, + const QString &file); + QString removeCommandlineColors(const QString &original); virtual void processOutputLine(const QByteArray &outputLine) = 0; virtual TestResultPtr createDefaultResult() const = 0; @@ -65,7 +68,7 @@ protected: void reportResult(const TestResultPtr &result); QFutureInterface m_futureInterface; QProcess *m_testApplication; // not owned - QString m_buildDir; + Utils::FilePath m_buildDir; QString m_id; QHash m_summary; int m_disabled = -1; diff --git a/src/plugins/autotest/testresult.h b/src/plugins/autotest/testresult.h index af8ba7e450b..e1081fe9523 100644 --- a/src/plugins/autotest/testresult.h +++ b/src/plugins/autotest/testresult.h @@ -27,6 +27,8 @@ #include "autotestconstants.h" +#include + #include #include #include @@ -92,11 +94,11 @@ public: QString name() const { return m_name; } ResultType result() const { return m_result; } QString description() const { return m_description; } - QString fileName() const { return m_file; } + Utils::FilePath fileName() const { return m_file; } int line() const { return m_line; } void setDescription(const QString &description) { m_description = description; } - void setFileName(const QString &fileName) { m_file = fileName; } + void setFileName(const Utils::FilePath &fileName) { m_file = fileName; } void setLine(int line) { m_line = line; } void setResult(ResultType type) { m_result = type; } @@ -113,7 +115,7 @@ private: QString m_name; ResultType m_result = ResultType::Invalid; // the real result.. QString m_description; - QString m_file; + Utils::FilePath m_file; int m_line = 0; }; diff --git a/src/plugins/autotest/testresultdelegate.cpp b/src/plugins/autotest/testresultdelegate.cpp index a439c58a5c9..f0e7ec111c0 100644 --- a/src/plugins/autotest/testresultdelegate.cpp +++ b/src/plugins/autotest/testresultdelegate.cpp @@ -117,15 +117,10 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op fm.elidedText(output.left(2000), Qt::ElideRight, positions.textAreaWidth())); } - QString file = testResult->fileName(); - const int pos = file.lastIndexOf('/'); - if (pos != -1) - file = file.mid(pos + 1); - + const QString file = testResult->fileName().fileName(); painter->setClipRect(positions.fileArea()); painter->drawText(positions.fileAreaLeft(), positions.top() + fm.ascent(), file); - if (testResult->line()) { QString line = QString::number(testResult->line()); painter->setClipRect(positions.lineArea()); diff --git a/src/plugins/autotest/testresultmodel.cpp b/src/plugins/autotest/testresultmodel.cpp index bc93a3ad653..c4060f4d42d 100644 --- a/src/plugins/autotest/testresultmodel.cpp +++ b/src/plugins/autotest/testresultmodel.cpp @@ -299,7 +299,7 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx } TestResultItem *parentItem = findParentItemFor(newItem, root); - addFileName(testResult->fileName()); // ensure we calculate the results pane correctly + addFileName(testResult->fileName().fileName()); // ensure we calculate the results pane correctly if (parentItem) { parentItem->appendChild(newItem); if (autoExpand) { @@ -362,16 +362,14 @@ void TestResultModel::recalculateMaxWidthOfFileName(const QFont &font) const QFontMetrics fm(font); m_maxWidthOfFileName = 0; for (const QString &fileName : qAsConst(m_fileNames)) { - int pos = fileName.lastIndexOf('/'); - m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName.mid(pos + 1))); + m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName)); } } void TestResultModel::addFileName(const QString &fileName) { const QFontMetrics fm(m_measurementFont); - int pos = fileName.lastIndexOf('/'); - m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName.mid(pos + 1))); + m_maxWidthOfFileName = qMax(m_maxWidthOfFileName, fm.horizontalAdvance(fileName)); m_fileNames.insert(fileName); } diff --git a/src/plugins/autotest/testresultspane.cpp b/src/plugins/autotest/testresultspane.cpp index 16f39e72497..cbd0fdee9b6 100644 --- a/src/plugins/autotest/testresultspane.cpp +++ b/src/plugins/autotest/testresultspane.cpp @@ -473,7 +473,7 @@ void TestResultsPane::onItemActivated(const QModelIndex &index) const TestResult *testResult = m_filterModel->testResult(index); if (testResult && !testResult->fileName().isEmpty()) - EditorManager::openEditorAt(testResult->fileName(), testResult->line(), 0); + EditorManager::openEditorAt(Utils::Link{testResult->fileName(), testResult->line(), 0}); } void TestResultsPane::onRunAllTriggered() @@ -750,8 +750,7 @@ void TestResultsPane::createMarks(const QModelIndex &parent) bool isLocationItem = result->result() == ResultType::MessageLocation; if (interested.contains(result->result()) || (isLocationItem && interested.contains(parentType))) { - const Utils::FilePath fileName = Utils::FilePath::fromString(result->fileName()); - TestEditorMark *mark = new TestEditorMark(index, fileName, result->line()); + TestEditorMark *mark = new TestEditorMark(index, result->fileName(), result->line()); mark->setIcon(index.data(Qt::DecorationRole).value()); mark->setColor(Utils::Theme::OutputPanes_TestFailTextColor); mark->setPriority(TextEditor::TextMark::NormalPriority); diff --git a/src/plugins/autotest/testrunconfiguration.h b/src/plugins/autotest/testrunconfiguration.h index 7e88eb6ce86..2e8748edeac 100644 --- a/src/plugins/autotest/testrunconfiguration.h +++ b/src/plugins/autotest/testrunconfiguration.h @@ -65,9 +65,9 @@ public: { ProjectExplorer::Runnable r; QTC_ASSERT(m_testConfig, return r); - r.executable = Utils::FilePath::fromString(m_testConfig->executableFilePath()); + r.executable = m_testConfig->executableFilePath(); r.commandLineArguments = m_testConfig->argumentsForTestRunner().join(' '); - r.workingDirectory = m_testConfig->workingDirectory(); + r.workingDirectory = m_testConfig->workingDirectory().toString(); r.environment = m_testConfig->environment(); r.device = ProjectExplorer::DeviceManager::instance()->defaultDevice( ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE); diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index 5fc67810beb..a0b00f7d374 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -176,13 +176,13 @@ static QString constructOmittedVariablesDetailsString(const Utils::EnvironmentIt bool TestRunner::currentConfigValid() { - QString commandFilePath; + Utils::FilePath commandFilePath; if (m_currentConfig->testBase()->type() == ITestBase::Framework) { TestConfiguration *current = static_cast(m_currentConfig); commandFilePath = current->executableFilePath(); } else { TestToolConfiguration *current = static_cast(m_currentConfig); - commandFilePath = current->commandLine().executable().toString(); + commandFilePath = current->commandLine().executable(); } if (commandFilePath.isEmpty()) { reportResult(ResultType::MessageFatal, @@ -208,7 +208,7 @@ void TestRunner::setUpProcess() m_currentProcess->setReadChannel(QProcess::StandardOutput); if (m_currentConfig->testBase()->type() == ITestBase::Framework) { TestConfiguration *current = static_cast(m_currentConfig); - m_currentProcess->setProgram(current->executableFilePath()); + m_currentProcess->setProgram(current->executableFilePath().toString()); } else { TestToolConfiguration *current = static_cast(m_currentConfig); m_currentProcess->setProgram(current->commandLine().executable().toString()); @@ -231,7 +231,7 @@ void TestRunner::setUpProcessEnv() m_currentProcess->setArguments(current->commandLine().splitArguments()); } - m_currentProcess->setWorkingDirectory(m_currentConfig->workingDirectory()); + m_currentProcess->setWorkingDirectory(m_currentConfig->workingDirectory().toString()); const Utils::Environment &original = m_currentConfig->environment(); Utils::Environment environment = m_currentConfig->filteredEnvironment(original); const Utils::EnvironmentItems removedVariables = Utils::filtered( @@ -625,10 +625,10 @@ void TestRunner::debugTests() return; } - const QString &commandFilePath = config->executableFilePath(); + const Utils::FilePath &commandFilePath = config->executableFilePath(); if (commandFilePath.isEmpty()) { reportResult(ResultType::MessageFatal, tr("Could not find command \"%1\". (%2)") - .arg(config->executableFilePath(), config->displayName())); + .arg(config->executableFilePath().toString(), config->displayName())); onFinished(); return; } @@ -638,7 +638,7 @@ void TestRunner::debugTests() QStringList omitted; Runnable inferior = config->runnable(); - inferior.executable = FilePath::fromString(commandFilePath); + inferior.executable = commandFilePath; const QStringList args = config->argumentsForTestRunner(&omitted); inferior.commandLineArguments = Utils::ProcessArgs::joinArgs(args); diff --git a/src/plugins/autotest/testtreeitem.cpp b/src/plugins/autotest/testtreeitem.cpp index c84259b0cbd..1b68a192c74 100644 --- a/src/plugins/autotest/testtreeitem.cpp +++ b/src/plugins/autotest/testtreeitem.cpp @@ -54,7 +54,7 @@ static QIcon testTreeIcon(TestTreeItem::Type type) } ITestTreeItem::ITestTreeItem(ITestBase *testBase, const QString &name, - const QString &filePath, Type type) + const Utils::FilePath &filePath, Type type) : m_testBase(testBase) , m_name(name) , m_filePath(filePath) @@ -70,7 +70,7 @@ QVariant ITestTreeItem::data(int /*column*/, int role) const else return m_name; case Qt::ToolTipRole: - return m_filePath; + return m_filePath.toString(); case Qt::DecorationRole: return testTreeIcon(m_type); case Qt::CheckStateRole: @@ -162,7 +162,7 @@ ITestConfiguration *ITestTreeItem::asConfiguration(TestRunMode mode) const /****************************** TestTreeItem ********************************************/ TestTreeItem::TestTreeItem(ITestFramework *testFramework, const QString &name, - const QString &filePath, Type type) + const Utils::FilePath &filePath, Type type) : ITestTreeItem(testFramework, name, filePath, type) { switch (type) { @@ -186,7 +186,7 @@ QVariant TestTreeItem::data(int column, int role) const return QVariant(); QVariant itemLink; itemLink.setValue( - Utils::Link(Utils::FilePath::fromString(filePath()), line(), int(m_column))); + Utils::Link(filePath(), line(), int(m_column))); return itemLink; } return ITestTreeItem::data(column, role); @@ -240,7 +240,7 @@ void TestTreeItem::markForRemovalRecursively(bool mark) childItem(row)->markForRemovalRecursively(mark); } -void TestTreeItem::markForRemovalRecursively(const QString &filepath) +void TestTreeItem::markForRemovalRecursively(const Utils::FilePath &filepath) { bool mark = filePath() == filepath; forFirstLevelChildItems([&mark, &filepath](TestTreeItem *child) { @@ -267,20 +267,20 @@ TestTreeItem *TestTreeItem::findChildByName(const QString &name) }); } -TestTreeItem *TestTreeItem::findChildByFile(const QString &filePath) +TestTreeItem *TestTreeItem::findChildByFile(const Utils::FilePath &filePath) { return findFirstLevelChildItem([filePath](const TestTreeItem *other) { return other->filePath() == filePath; }); } -TestTreeItem *TestTreeItem::findChildByFileAndType(const QString &filePath, Type tType) +TestTreeItem *TestTreeItem::findChildByFileAndType(const Utils::FilePath &filePath, Type tType) { return findFirstLevelChildItem([filePath, tType](const TestTreeItem *other) { return other->type() == tType && other->filePath() == filePath; });} -TestTreeItem *TestTreeItem::findChildByNameAndFile(const QString &name, const QString &filePath) +TestTreeItem *TestTreeItem::findChildByNameAndFile(const QString &name, const Utils::FilePath &filePath) { return findFirstLevelChildItem([name, filePath](const TestTreeItem *other) { return other->filePath() == filePath && other->name() == name; @@ -310,7 +310,7 @@ bool TestTreeItem::isGroupNodeFor(const TestTreeItem *other) const return false; // for now there's only the possibility to have 'Folder' nodes - return QFileInfo(other->filePath()).absolutePath() == filePath(); + return other->filePath().absolutePath() == filePath(); } bool TestTreeItem::isGroupable() const @@ -360,7 +360,7 @@ void TestTreeItem::copyBasicDataFrom(const TestTreeItem *other) m_status = other->m_status; } -inline bool TestTreeItem::modifyFilePath(const QString &filepath) +inline bool TestTreeItem::modifyFilePath(const Utils::FilePath &filepath) { if (filePath() != filepath) { setFilePath(filepath); diff --git a/src/plugins/autotest/testtreeitem.h b/src/plugins/autotest/testtreeitem.h index f06abb74860..43b41ca1608 100644 --- a/src/plugins/autotest/testtreeitem.h +++ b/src/plugins/autotest/testtreeitem.h @@ -25,6 +25,7 @@ #pragma once +#include #include #include @@ -42,8 +43,6 @@ namespace { }; } -namespace Utils { class FilePath; } - namespace Autotest { class ITestBase; @@ -75,7 +74,7 @@ public: explicit ITestTreeItem(ITestBase *testBase, const QString &name = QString(), - const QString &filePath = QString(), + const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root); virtual QVariant data(int column, int role) const override; @@ -93,15 +92,15 @@ public: const QString name() const { return m_name; } void setName(const QString &name) { m_name = name; } - const QString filePath() const { return m_filePath; } - void setFilePath(const QString &filePath) { m_filePath = filePath; } + const Utils::FilePath filePath() const { return m_filePath; } + void setFilePath(const Utils::FilePath &filePath) { m_filePath = filePath; } Type type() const { return m_type; } int line() const { return m_line; } void setLine(int line) { m_line = line;} ITestBase *testBase() const { return m_testBase; } virtual bool lessThan(const ITestTreeItem *other, SortMode mode) const; - QString cacheName() const { return m_filePath + ':' + m_name; } + QString cacheName() const { return m_filePath.toString() + ':' + m_name; } protected: void setType(Type type) { m_type = type; } @@ -110,7 +109,7 @@ protected: private: ITestBase *m_testBase = nullptr; // not owned QString m_name; - QString m_filePath; + Utils::FilePath m_filePath; Type m_type; int m_line = 0; bool m_failed = false; @@ -121,7 +120,7 @@ class TestTreeItem : public ITestTreeItem public: explicit TestTreeItem(ITestFramework *testFramework, const QString &name = QString(), - const QString &filePath = QString(), + const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root); virtual TestTreeItem *copyWithoutChildren() = 0; @@ -134,11 +133,11 @@ public: ITestFramework *framework() const; void setColumn(int column) { m_column = column; } int column() const { return m_column; } - QString proFile() const { return m_proFile; } - void setProFile(const QString &proFile) { m_proFile = proFile; } + Utils::FilePath proFile() const { return m_proFile; } + void setProFile(const Utils::FilePath &proFile) { m_proFile = proFile; } void markForRemoval(bool mark); void markForRemovalRecursively(bool mark); - virtual void markForRemovalRecursively(const QString &filepath); + virtual void markForRemovalRecursively(const Utils::FilePath &filepath); virtual bool removeOnSweepIfEmpty() const { return type() == GroupNode; } bool markedForRemoval() const { return m_status == MarkedForRemoval; } bool newlyAdded() const { return m_status == NewlyAdded; } @@ -146,9 +145,9 @@ public: TestTreeItem *parentItem() const; TestTreeItem *findChildByName(const QString &name); - TestTreeItem *findChildByFile(const QString &filePath); - TestTreeItem *findChildByFileAndType(const QString &filePath, Type type); - TestTreeItem *findChildByNameAndFile(const QString &name, const QString &filePath); + TestTreeItem *findChildByFile(const Utils::FilePath &filePath); + TestTreeItem *findChildByFileAndType(const Utils::FilePath &filePath, Type type); + TestTreeItem *findChildByNameAndFile(const QString &name, const Utils::FilePath &filePath); virtual ITestConfiguration *debugConfiguration() const { return nullptr; } virtual bool canProvideDebugConfiguration() const { return false; } @@ -174,7 +173,7 @@ protected: typedef std::function CompareFunction; private: - bool modifyFilePath(const QString &filepath); + bool modifyFilePath(const Utils::FilePath &filepath); bool modifyName(const QString &name); enum Status @@ -185,7 +184,7 @@ private: }; int m_column = 0; - QString m_proFile; + Utils::FilePath m_proFile; Status m_status = NewlyAdded; friend class TestTreeModel; // grant access to (protected) findChildBy() @@ -194,7 +193,7 @@ private: class TestCodeLocationAndType { public: - QString m_name; // tag name for m_type == TestDataTag, file name for other values + QString m_name; // tag name for m_type == TestDataTag, file name for other values // FIXME int m_line = 0; int m_column = 0; TestTreeItem::Type m_type = TestTreeItem::Root; diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp index 4719818d5d8..da6da812d6b 100644 --- a/src/plugins/autotest/testtreemodel.cpp +++ b/src/plugins/autotest/testtreemodel.cpp @@ -115,7 +115,11 @@ void TestTreeModel::setupParsingConnections() connect(cppMM, &CppTools::CppModelManager::documentUpdated, m_parser, &TestCodeParser::onCppDocumentUpdated, Qt::QueuedConnection); connect(cppMM, &CppTools::CppModelManager::aboutToRemoveFiles, - this, &TestTreeModel::removeFiles, Qt::QueuedConnection); + this, [this](const QStringList &files) { + const Utils::FilePaths filesToRemove + = Utils::transform(files, &Utils::FilePath::fromString); + removeFiles(filesToRemove); + }, Qt::QueuedConnection); connect(cppMM, &CppTools::CppModelManager::projectPartsUpdated, m_parser, &TestCodeParser::onProjectPartsUpdated); @@ -123,7 +127,11 @@ void TestTreeModel::setupParsingConnections() connect(qmlJsMM, &QmlJS::ModelManagerInterface::documentUpdated, m_parser, &TestCodeParser::onQmlDocumentUpdated, Qt::QueuedConnection); connect(qmlJsMM, &QmlJS::ModelManagerInterface::aboutToRemoveFiles, - this, &TestTreeModel::removeFiles, Qt::QueuedConnection); + this, [this](const QStringList files) { + const Utils::FilePaths filesToRemove + = Utils::transform(files, &Utils::FilePath::fromString); + removeFiles(filesToRemove); + }, Qt::QueuedConnection); connectionsInitialized = true; } @@ -481,9 +489,9 @@ void TestTreeModel::clearFailedMarks() m_failedStateCache.clear(); } -void TestTreeModel::removeFiles(const QStringList &files) +void TestTreeModel::removeFiles(const Utils::FilePaths &files) { - for (const QString &file : files) + for (const Utils::FilePath &file : files) markForRemoval(file); sweep(); } @@ -497,7 +505,7 @@ void TestTreeModel::markAllFrameworkItemsForRemoval() } } -void TestTreeModel::markForRemoval(const QString &filePath) +void TestTreeModel::markForRemoval(const Utils::FilePath &filePath) { if (filePath.isEmpty()) return; @@ -865,7 +873,7 @@ QMap TestTreeModel::boostTestSuitesAndTests() const if (TestTreeItem *rootNode = boostTestRootNode()) { rootNode->forFirstLevelChildItems([&result](TestTreeItem *child) { - result.insert(child->name() + '|' + child->proFile(), child->childCount()); + result.insert(child->name() + '|' + child->proFile().toString(), child->childCount()); }); } return result; diff --git a/src/plugins/autotest/testtreemodel.h b/src/plugins/autotest/testtreemodel.h index 4f844874828..ab9dcd51565 100644 --- a/src/plugins/autotest/testtreemodel.h +++ b/src/plugins/autotest/testtreemodel.h @@ -88,7 +88,7 @@ public: #endif void markAllFrameworkItemsForRemoval(); - void markForRemoval(const QString &filePath); + void markForRemoval(const Utils::FilePath &filePath); void sweep(); signals: @@ -105,7 +105,7 @@ private: void handleParseResult(const TestParseResult *result, TestTreeItem *rootNode); void removeAllTestItems(); void removeAllTestToolItems(); - void removeFiles(const QStringList &files); + void removeFiles(const Utils::FilePaths &files); bool sweepChildren(TestTreeItem *item); void insertItemInParent(TestTreeItem *item, TestTreeItem *root, bool groupingEnabled); void revalidateCheckState(ITestTreeItem *item); diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 73c39e62f24..cd53aeddbcb 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -1419,16 +1419,16 @@ void CppModelManager::onAboutToLoadSession() GC(); } -QSet CppModelManager::dependingInternalTargets(const QString &file) const +QSet CppModelManager::dependingInternalTargets(const Utils::FilePath &file) const { QSet result; const Snapshot snapshot = this->snapshot(); QTC_ASSERT(snapshot.contains(file), return result); bool wasHeader; const QString correspondingFile - = correspondingHeaderOrSource(file, &wasHeader, CacheUsage::ReadOnly); + = correspondingHeaderOrSource(file.toString(), &wasHeader, CacheUsage::ReadOnly); const Utils::FilePaths dependingFiles = snapshot.filesDependingOn( - wasHeader ? file : correspondingFile); + wasHeader ? file : Utils::FilePath::fromString(correspondingFile)); for (const Utils::FilePath &fn : qAsConst(dependingFiles)) { for (const ProjectPart::Ptr &part : projectPart(fn)) result.insert(part->buildSystemTarget); @@ -1436,7 +1436,7 @@ QSet CppModelManager::dependingInternalTargets(const QString &file) con return result; } -QSet CppModelManager::internalTargets(const QString &filePath) const +QSet CppModelManager::internalTargets(const Utils::FilePath &filePath) const { const QList projectParts = projectPart(filePath); // if we have no project parts it's most likely a header with declarations only and CMake based diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h index 1f09f9d8edd..ff987caf93f 100644 --- a/src/plugins/cpptools/cppmodelmanager.h +++ b/src/plugins/cpptools/cppmodelmanager.h @@ -237,9 +237,9 @@ public: * try to find build system target that depends on the given file - if the file is no header * try to find the corresponding header and use this instead to find the respective target */ - QSet dependingInternalTargets(const QString &file) const; + QSet dependingInternalTargets(const Utils::FilePath &file) const; - QSet internalTargets(const QString &filePath) const; + QSet internalTargets(const Utils::FilePath &filePath) const; void renameIncludes(const QString &oldFileName, const QString &newFileName);