forked from qt-creator/qt-creator
Change RawProjectPart::projectFile to FilePath
Changed the type of PawProjectPart::projectFile from QString to FilePath. Rest of the changes are a direct byproduct. Change-Id: I00ed5e948af3fd1660ebf2c4bbcfae21f8facf28 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -109,7 +109,7 @@ bool BoostTestParser::processDocument(QPromise<TestParseResultPtr> &promise,
|
|||||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||||
return false;
|
return false;
|
||||||
const CppEditor::ProjectPart::ConstPtr projectPart = projectParts.first();
|
const CppEditor::ProjectPart::ConstPtr projectPart = projectParts.first();
|
||||||
const auto projectFile = FilePath::fromString(projectPart->projectFile);
|
const FilePath &projectFile = projectPart->projectFile;
|
||||||
const QByteArray &fileContent = getFileContent(fileName);
|
const QByteArray &fileContent = getFileContent(fileName);
|
||||||
|
|
||||||
BoostCodeParser codeParser(fileContent, projectPart->languageFeatures, doc, m_cppSnapshot);
|
BoostCodeParser codeParser(fileContent, projectPart->languageFeatures, doc, m_cppSnapshot);
|
||||||
|
@@ -123,7 +123,7 @@ bool CatchTestParser::processDocument(QPromise<TestParseResultPtr> &promise,
|
|||||||
return false;
|
return false;
|
||||||
FilePath proFile;
|
FilePath proFile;
|
||||||
const CppEditor::ProjectPart::ConstPtr projectPart = projectParts.first();
|
const CppEditor::ProjectPart::ConstPtr projectPart = projectParts.first();
|
||||||
proFile = FilePath::fromString(projectPart->projectFile);
|
proFile = projectPart->projectFile;
|
||||||
|
|
||||||
CatchCodeParser codeParser(fileContent, projectPart->languageFeatures);
|
CatchCodeParser codeParser(fileContent, projectPart->languageFeatures);
|
||||||
const CatchTestCodeLocationList foundTests = codeParser.findTests();
|
const CatchTestCodeLocationList foundTests = codeParser.findTests();
|
||||||
|
@@ -97,7 +97,7 @@ bool GTestParser::processDocument(QPromise<TestParseResultPtr> &promise,
|
|||||||
const QList<CppEditor::ProjectPart::ConstPtr> &ppList =
|
const QList<CppEditor::ProjectPart::ConstPtr> &ppList =
|
||||||
CppEditor::CppModelManager::projectPart(filePath);
|
CppEditor::CppModelManager::projectPart(filePath);
|
||||||
if (!ppList.isEmpty())
|
if (!ppList.isEmpty())
|
||||||
proFile = FilePath::fromString(ppList.first()->projectFile);
|
proFile = ppList.first()->projectFile;
|
||||||
else
|
else
|
||||||
return false; // happens if shutting down while parsing
|
return false; // happens if shutting down while parsing
|
||||||
|
|
||||||
|
@@ -500,10 +500,10 @@ QSet<QString> internalTargets(const TestTreeItem &item)
|
|||||||
if (projectParts.isEmpty())
|
if (projectParts.isEmpty())
|
||||||
return CppEditor::CppModelManager::dependingInternalTargets(item.filePath());
|
return CppEditor::CppModelManager::dependingInternalTargets(item.filePath());
|
||||||
for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectParts) {
|
for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectParts) {
|
||||||
if (FilePath::fromString(projectPart->projectFile) == item.proFile()
|
if (projectPart->projectFile == item.proFile()
|
||||||
&& Utils::anyOf(projectPart->files, [&filePath](const CppEditor::ProjectFile &pf) {
|
&& Utils::anyOf(projectPart->files, [&filePath](const CppEditor::ProjectFile &pf) {
|
||||||
return pf.path == filePath;
|
return pf.path == filePath;
|
||||||
})) {
|
})) {
|
||||||
result.insert(projectPart->buildSystemTarget);
|
result.insert(projectPart->buildSystemTarget);
|
||||||
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||||
result.unite(CppEditor::CppModelManager::dependingInternalTargets(filePath));
|
result.unite(CppEditor::CppModelManager::dependingInternalTargets(filePath));
|
||||||
|
@@ -370,7 +370,7 @@ std::optional<bool> QtTestParser::fillTestCaseData(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QtTestParseResult *QtTestParser::createParseResult(
|
QtTestParseResult *QtTestParser::createParseResult(
|
||||||
const QString &testCaseName, const TestCaseData &data, const QString &projectFile) const
|
const QString &testCaseName, const TestCaseData &data, const FilePath &projectFile) const
|
||||||
{
|
{
|
||||||
QtTestParseResult *parseResult = new QtTestParseResult(framework());
|
QtTestParseResult *parseResult = new QtTestParseResult(framework());
|
||||||
parseResult->itemType = TestTreeItem::TestCase;
|
parseResult->itemType = TestTreeItem::TestCase;
|
||||||
@@ -379,7 +379,7 @@ QtTestParseResult *QtTestParser::createParseResult(
|
|||||||
parseResult->displayName = testCaseName;
|
parseResult->displayName = testCaseName;
|
||||||
parseResult->line = data.line;
|
parseResult->line = data.line;
|
||||||
parseResult->column = data.column;
|
parseResult->column = data.column;
|
||||||
parseResult->proFile = FilePath::fromString(projectFile);
|
parseResult->proFile = projectFile;
|
||||||
parseResult->setRunsMultipleTestcases(data.multipleTestCases);
|
parseResult->setRunsMultipleTestcases(data.multipleTestCases);
|
||||||
QMap<QString, QtTestCodeLocationAndType>::ConstIterator it = data.testFunctions.begin();
|
QMap<QString, QtTestCodeLocationAndType>::ConstIterator it = data.testFunctions.begin();
|
||||||
const QMap<QString, QtTestCodeLocationAndType>::ConstIterator end = data.testFunctions.end();
|
const QMap<QString, QtTestCodeLocationAndType>::ConstIterator end = data.testFunctions.end();
|
||||||
|
@@ -53,8 +53,10 @@ private:
|
|||||||
std::optional<bool> fillTestCaseData(const QString &testCaseName,
|
std::optional<bool> fillTestCaseData(const QString &testCaseName,
|
||||||
const CPlusPlus::Document::Ptr &doc,
|
const CPlusPlus::Document::Ptr &doc,
|
||||||
TestCaseData &data) const;
|
TestCaseData &data) const;
|
||||||
QtTestParseResult *createParseResult(const QString &testCaseName, const TestCaseData &data,
|
QtTestParseResult *createParseResult(
|
||||||
const QString &projectFile) const;
|
const QString &testCaseName,
|
||||||
|
const TestCaseData &data,
|
||||||
|
const Utils::FilePath &projectFile) const;
|
||||||
QHash<Utils::FilePath, TestCases> m_testCases;
|
QHash<Utils::FilePath, TestCases> m_testCases;
|
||||||
QMultiHash<Utils::FilePath, Utils::FilePath> m_alternativeFiles;
|
QMultiHash<Utils::FilePath, Utils::FilePath> m_alternativeFiles;
|
||||||
QSet<Utils::FilePath> m_prefilteredFiles;
|
QSet<Utils::FilePath> m_prefilteredFiles;
|
||||||
|
@@ -260,7 +260,7 @@ bool QuickTestParser::handleQtQuickTest(QPromise<TestParseResultPtr> &promise,
|
|||||||
if (ppList.isEmpty()) // happens if shutting down while parsing
|
if (ppList.isEmpty()) // happens if shutting down while parsing
|
||||||
return false;
|
return false;
|
||||||
const FilePath cppFileName = document->filePath();
|
const FilePath cppFileName = document->filePath();
|
||||||
const FilePath proFile = FilePath::fromString(ppList.at(0)->projectFile);
|
const FilePath proFile = ppList.at(0)->projectFile;
|
||||||
{
|
{
|
||||||
QWriteLocker lock(&m_parseLock);
|
QWriteLocker lock(&m_parseLock);
|
||||||
m_mainCppFiles.insert(cppFileName, proFile);
|
m_mainCppFiles.insert(cppFileName, proFile);
|
||||||
|
@@ -377,7 +377,7 @@ QSet<QString> internalTargets(const FilePath &proFile)
|
|||||||
for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectInfo->projectParts()) {
|
for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectInfo->projectParts()) {
|
||||||
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||||
continue;
|
continue;
|
||||||
if (projectPart->projectFile != proFile.path())
|
if (projectPart->projectFile != proFile)
|
||||||
continue;
|
continue;
|
||||||
if (Utils::anyOf(projectPart->projectMacros, [](const ProjectExplorer::Macro ¯o){
|
if (Utils::anyOf(projectPart->projectMacros, [](const ProjectExplorer::Macro ¯o){
|
||||||
return macro.type == ProjectExplorer::MacroType::Define &&
|
return macro.type == ProjectExplorer::MacroType::Define &&
|
||||||
|
@@ -154,7 +154,7 @@ void AutotoolsBuildSystem::makefileParsingFinished(const MakefileParserOutputDat
|
|||||||
|
|
||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
rpp.setDisplayName(project()->displayName());
|
rpp.setDisplayName(project()->displayName());
|
||||||
rpp.setProjectFileLocation(projectFilePath().toString());
|
rpp.setProjectFileLocation(projectFilePath());
|
||||||
rpp.setQtVersion(kitInfo.projectPartQtVersion);
|
rpp.setQtVersion(kitInfo.projectPartQtVersion);
|
||||||
const QStringList cflags = outputData.m_cflags;
|
const QStringList cflags = outputData.m_cflags;
|
||||||
QStringList cxxflags = outputData.m_cxxflags;
|
QStringList cxxflags = outputData.m_cxxflags;
|
||||||
|
@@ -446,8 +446,7 @@ static RawProjectParts generateRawProjectParts(const QFuture<void> &cancelFuture
|
|||||||
}
|
}
|
||||||
|
|
||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
rpp.setProjectFileLocation(
|
rpp.setProjectFileLocation(t.sourceDir.pathAppended(Constants::CMAKE_LISTS_TXT));
|
||||||
t.sourceDir.pathAppended(Constants::CMAKE_LISTS_TXT).toString());
|
|
||||||
rpp.setBuildSystemTarget(t.name);
|
rpp.setBuildSystemTarget(t.name);
|
||||||
const QString postfix = needPostfix ? QString("_%1_%2").arg(ci.language).arg(count)
|
const QString postfix = needPostfix ? QString("_%1_%2").arg(ci.language).arg(count)
|
||||||
: QString();
|
: QString();
|
||||||
|
@@ -172,7 +172,7 @@ static RawProjectPart makeRawProjectPart(const FilePath &projectFile,
|
|||||||
|
|
||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
|
|
||||||
rpp.setProjectFileLocation(projectFile.toString());
|
rpp.setProjectFileLocation(projectFile);
|
||||||
rpp.setBuildSystemTarget(workingDir.path());
|
rpp.setBuildSystemTarget(workingDir.path());
|
||||||
rpp.setDisplayName(filePath.fileName());
|
rpp.setDisplayName(filePath.fileName());
|
||||||
rpp.setFiles({filePath.toFSPathString()});
|
rpp.setFiles({filePath.toFSPathString()});
|
||||||
|
@@ -1142,7 +1142,7 @@ QVariant ProjectPartsModel::data(const QModelIndex &index, int role) const
|
|||||||
if (column == PartNameColumn)
|
if (column == PartNameColumn)
|
||||||
return m_projectPartsList.at(row)->displayName;
|
return m_projectPartsList.at(row)->displayName;
|
||||||
else if (column == PartFilePathColumn)
|
else if (column == PartFilePathColumn)
|
||||||
return QDir::toNativeSeparators(m_projectPartsList.at(row)->projectFile);
|
return m_projectPartsList.at(row)->projectFile.nativePath();
|
||||||
} else if (role == Qt::ForegroundRole) {
|
} else if (role == Qt::ForegroundRole) {
|
||||||
if (!m_projectPartsList.at(row)->selectedForBuilding) {
|
if (!m_projectPartsList.at(row)->selectedForBuilding) {
|
||||||
return QApplication::palette().color(QPalette::ColorGroup::Disabled,
|
return QApplication::palette().color(QPalette::ColorGroup::Disabled,
|
||||||
|
@@ -105,7 +105,7 @@ QVariant ParseContextModel::data(const QModelIndex &index, int role) const
|
|||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole)
|
||||||
return m_projectParts[row]->displayName;
|
return m_projectParts[row]->displayName;
|
||||||
else if (role == Qt::ToolTipRole)
|
else if (role == Qt::ToolTipRole)
|
||||||
return QDir::toNativeSeparators(m_projectParts[row]->projectFile);
|
return m_projectParts[row]->projectFile.nativePath();
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@@ -115,7 +115,7 @@ void ProjectPartChooserTest::testChooseManuallySet()
|
|||||||
rpp2.setProjectFileLocation("someId");
|
rpp2.setProjectFileLocation("someId");
|
||||||
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.preferredProjectPartId = p2->projectFile;
|
t.preferredProjectPartId = p2->projectFile.toString();
|
||||||
t.projectPartsForFile += {p1, p2};
|
t.projectPartsForFile += {p1, p2};
|
||||||
|
|
||||||
QCOMPARE(t.choose().projectPart, p2);
|
QCOMPARE(t.choose().projectPart, p2);
|
||||||
@@ -128,7 +128,7 @@ void ProjectPartChooserTest::testIndicateManuallySet()
|
|||||||
rpp2.setProjectFileLocation("someId");
|
rpp2.setProjectFileLocation("someId");
|
||||||
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.preferredProjectPartId = p2->projectFile;
|
t.preferredProjectPartId = p2->projectFile.toString();
|
||||||
t.projectPartsForFile += {p1, p2};
|
t.projectPartsForFile += {p1, p2};
|
||||||
|
|
||||||
QVERIFY(t.choose().hints & ProjectPartInfo::IsPreferredMatch);
|
QVERIFY(t.choose().hints & ProjectPartInfo::IsPreferredMatch);
|
||||||
@@ -141,7 +141,7 @@ void ProjectPartChooserTest::testIndicateManuallySetForFallbackToProjectPartFrom
|
|||||||
rpp2.setProjectFileLocation("someId");
|
rpp2.setProjectFileLocation("someId");
|
||||||
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.preferredProjectPartId = p2->projectFile;
|
t.preferredProjectPartId = p2->projectFile.toString();
|
||||||
t.projectPartsFromDependenciesForFile += {p1, p2};
|
t.projectPartsFromDependenciesForFile += {p1, p2};
|
||||||
|
|
||||||
QVERIFY(t.choose().hints & ProjectPartInfo::IsPreferredMatch);
|
QVERIFY(t.choose().hints & ProjectPartInfo::IsPreferredMatch);
|
||||||
|
@@ -27,7 +27,7 @@ QString ProjectPart::id() const
|
|||||||
|
|
||||||
QString ProjectPart::projectFileLocation() const
|
QString ProjectPart::projectFileLocation() const
|
||||||
{
|
{
|
||||||
QString location = QDir::fromNativeSeparators(projectFile);
|
QString location = projectFile.toString();
|
||||||
if (projectFileLine > 0)
|
if (projectFileLine > 0)
|
||||||
location += ":" + QString::number(projectFileLine);
|
location += ":" + QString::number(projectFileLine);
|
||||||
if (projectFileColumn > 0)
|
if (projectFileColumn > 0)
|
||||||
|
@@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
const Utils::FilePath topLevelProject;
|
const Utils::FilePath topLevelProject;
|
||||||
const QString displayName;
|
const QString displayName;
|
||||||
const QString projectFile;
|
const Utils::FilePath projectFile;
|
||||||
const QString projectConfigFile; // Generic Project Manager only
|
const QString projectConfigFile; // Generic Project Manager only
|
||||||
|
|
||||||
const int projectFileLine = -1;
|
const int projectFileLine = -1;
|
||||||
|
@@ -398,7 +398,7 @@ private:
|
|||||||
FileType fileType = node && node->asFileNode() ? node->asFileNode()->fileType()
|
FileType fileType = node && node->asFileNode() ? node->asFileNode()->fileType()
|
||||||
: FileType::Unknown;
|
: FileType::Unknown;
|
||||||
if (fileType == FileType::Unknown
|
if (fileType == FileType::Unknown
|
||||||
&& ProjectFile::isHeader(ProjectFile::classify(interface.filePath().toString()))) {
|
&& ProjectFile::isHeader(ProjectFile::classify(interface.filePath()))) {
|
||||||
fileType = FileType::Header;
|
fileType = FileType::Header;
|
||||||
}
|
}
|
||||||
if (fileType == FileType::Header) {
|
if (fileType == FileType::Header) {
|
||||||
|
@@ -565,7 +565,7 @@ void GenericBuildSystem::refreshCppCodeModel()
|
|||||||
|
|
||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
rpp.setDisplayName(project()->displayName());
|
rpp.setDisplayName(project()->displayName());
|
||||||
rpp.setProjectFileLocation(projectFilePath().toString());
|
rpp.setProjectFileLocation(projectFilePath());
|
||||||
rpp.setQtVersion(kitInfo.projectPartQtVersion);
|
rpp.setQtVersion(kitInfo.projectPartQtVersion);
|
||||||
rpp.setHeaderPaths(m_projectIncludePaths);
|
rpp.setHeaderPaths(m_projectIncludePaths);
|
||||||
rpp.setConfigFileName(m_configFileName);
|
rpp.setConfigFileName(m_configFileName);
|
||||||
|
@@ -310,7 +310,7 @@ RawProjectPart MesonProjectParser::buildRawPart(
|
|||||||
CompilerArgs flags = splitArgs(sources.parameters);
|
CompilerArgs flags = splitArgs(sources.parameters);
|
||||||
part.setMacros(flags.macros);
|
part.setMacros(flags.macros);
|
||||||
part.setIncludePaths(toAbsolutePath(m_buildDir, flags.includePaths));
|
part.setIncludePaths(toAbsolutePath(m_buildDir, flags.includePaths));
|
||||||
part.setProjectFileLocation(target.definedIn);
|
part.setProjectFileLocation(FilePath::fromUserInput(target.definedIn));
|
||||||
if (sources.language == "cpp")
|
if (sources.language == "cpp")
|
||||||
part.setFlagsForCxx({cxxToolchain, flags.args, {}});
|
part.setFlagsForCxx({cxxToolchain, flags.args, {}});
|
||||||
else if (sources.language == "c")
|
else if (sources.language == "c")
|
||||||
|
@@ -63,7 +63,7 @@ HeaderPath RawProjectPart::frameworkDetectionHeuristic(const HeaderPath &header)
|
|||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawProjectPart::setProjectFileLocation(const QString &projectFile, int line, int column)
|
void RawProjectPart::setProjectFileLocation(const Utils::FilePath &projectFile, int line, int column)
|
||||||
{
|
{
|
||||||
this->projectFile = projectFile;
|
this->projectFile = projectFile;
|
||||||
projectFileLine = line;
|
projectFileLine = line;
|
||||||
|
@@ -50,7 +50,7 @@ class PROJECTEXPLORER_EXPORT RawProjectPart
|
|||||||
public:
|
public:
|
||||||
void setDisplayName(const QString &displayName);
|
void setDisplayName(const QString &displayName);
|
||||||
|
|
||||||
void setProjectFileLocation(const QString &projectFile, int line = -1, int column = -1);
|
void setProjectFileLocation(const Utils::FilePath &projectFile, int line = -1, int column = -1);
|
||||||
void setConfigFileName(const QString &configFileName);
|
void setConfigFileName(const QString &configFileName);
|
||||||
void setCallGroupId(const QString &id);
|
void setCallGroupId(const QString &id);
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
QString displayName;
|
QString displayName;
|
||||||
|
|
||||||
QString projectFile;
|
Utils::FilePath projectFile;
|
||||||
int projectFileLine = -1;
|
int projectFileLine = -1;
|
||||||
int projectFileColumn = -1;
|
int projectFileColumn = -1;
|
||||||
QString callGroupId;
|
QString callGroupId;
|
||||||
|
@@ -858,9 +858,10 @@ static RawProjectPart generateProjectPart(
|
|||||||
rpp.setHeaderPaths(headerPaths);
|
rpp.setHeaderPaths(headerPaths);
|
||||||
rpp.setDisplayName(groupName);
|
rpp.setDisplayName(groupName);
|
||||||
const QJsonObject location = groupOrProduct.value("location").toObject();
|
const QJsonObject location = groupOrProduct.value("location").toObject();
|
||||||
rpp.setProjectFileLocation(location.value("file-path").toString(),
|
rpp.setProjectFileLocation(
|
||||||
location.value("line").toInt(),
|
FilePath::fromUserInput(location.value("file-path").toString()),
|
||||||
location.value("column").toInt());
|
location.value("line").toInt(),
|
||||||
|
location.value("column").toInt());
|
||||||
rpp.setBuildSystemTarget(QbsProductNode::getBuildKey(product));
|
rpp.setBuildSystemTarget(QbsProductNode::getBuildKey(product));
|
||||||
if (product.value("is-runnable").toBool()) {
|
if (product.value("is-runnable").toBool()) {
|
||||||
rpp.setBuildTargetType(BuildTargetType::Executable);
|
rpp.setBuildTargetType(BuildTargetType::Executable);
|
||||||
|
@@ -324,7 +324,7 @@ void QmakeBuildSystem::updateCppCodeModel()
|
|||||||
warnOnToolChainMismatch(pro);
|
warnOnToolChainMismatch(pro);
|
||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
rpp.setDisplayName(pro->displayName());
|
rpp.setDisplayName(pro->displayName());
|
||||||
rpp.setProjectFileLocation(pro->filePath().toString());
|
rpp.setProjectFileLocation(pro->filePath());
|
||||||
rpp.setBuildSystemTarget(pro->filePath().toString());
|
rpp.setBuildSystemTarget(pro->filePath().toString());
|
||||||
switch (pro->projectType()) {
|
switch (pro->projectType()) {
|
||||||
case ProjectType::ApplicationTemplate:
|
case ProjectType::ApplicationTemplate:
|
||||||
|
Reference in New Issue
Block a user