ProjectPart: Add callGroupId

Do not rely on the projectfile being unique anymore.

Change-Id: I52e63b3ac8aeca43ef70af1d59d1d8612bd3540e
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Tobias Hunger
2017-02-27 14:37:41 +01:00
parent cee92463f7
commit 546df41853
7 changed files with 22 additions and 14 deletions

View File

@@ -340,7 +340,7 @@ static QStringList tweakedArguments(const ProjectPart &projectPart,
} }
static AnalyzeUnits unitsToAnalyzeFromCompilerCallData( static AnalyzeUnits unitsToAnalyzeFromCompilerCallData(
const QHash<QString, ProjectPart::Ptr> &projectFileToProjectPart, const QHash<QString, ProjectPart::Ptr> &callGroupToProjectPart,
const ProjectInfo::CompilerCallData &compilerCallData, const ProjectInfo::CompilerCallData &compilerCallData,
const QString &targetTriple) const QString &targetTriple)
{ {
@@ -350,7 +350,7 @@ static AnalyzeUnits unitsToAnalyzeFromCompilerCallData(
foreach (const ProjectInfo::CompilerCallGroup &compilerCallGroup, compilerCallData) { foreach (const ProjectInfo::CompilerCallGroup &compilerCallGroup, compilerCallData) {
const ProjectPart::Ptr projectPart const ProjectPart::Ptr projectPart
= projectFileToProjectPart.value(compilerCallGroup.groupId); = callGroupToProjectPart.value(compilerCallGroup.groupId);
QTC_ASSERT(projectPart, continue); QTC_ASSERT(projectPart, continue);
QHashIterator<QString, QList<QStringList> > it(compilerCallGroup.callsPerSourceFile); QHashIterator<QString, QList<QStringList> > it(compilerCallGroup.callsPerSourceFile);
@@ -398,19 +398,14 @@ static AnalyzeUnits unitsToAnalyzeFromProjectParts(const QVector<ProjectPart::Pt
return unitsToAnalyze; return unitsToAnalyze;
} }
static QHash<QString, ProjectPart::Ptr> generateProjectFileToProjectPartMapping( static QHash<QString, ProjectPart::Ptr> generateCallGroupToProjectPartMapping(
const QVector<ProjectPart::Ptr> &projectParts) const QVector<ProjectPart::Ptr> &projectParts)
{ {
QHash<QString, ProjectPart::Ptr> mapping; QHash<QString, ProjectPart::Ptr> mapping;
foreach (const ProjectPart::Ptr &projectPart, projectParts) { foreach (const ProjectPart::Ptr &projectPart, projectParts) {
QTC_ASSERT(projectPart, continue); QTC_ASSERT(projectPart, continue);
QString projectFile = projectPart->projectFile; mapping[projectPart->callGroupId] = projectPart;
if (projectPart->projectFileLine >= 0)
projectFile += ':' + QString::number(projectPart->projectFileLine);
if (projectPart->projectFileColumn >= 0)
projectFile += ':' + QString::number(projectPart->projectFileColumn);
mapping[projectFile] = projectPart;
} }
return mapping; return mapping;
@@ -425,9 +420,9 @@ AnalyzeUnits ClangStaticAnalyzerRunControl::sortedUnitsToAnalyze()
if (compilerCallData.isEmpty()) { if (compilerCallData.isEmpty()) {
units = unitsToAnalyzeFromProjectParts(m_projectInfo.projectParts()); units = unitsToAnalyzeFromProjectParts(m_projectInfo.projectParts());
} else { } else {
const QHash<QString, ProjectPart::Ptr> projectFileToProjectPart const QHash<QString, ProjectPart::Ptr> callGroupToProjectPart
= generateProjectFileToProjectPartMapping(m_projectInfo.projectParts()); = generateCallGroupToProjectPartMapping(m_projectInfo.projectParts());
units = unitsToAnalyzeFromCompilerCallData(projectFileToProjectPart, units = unitsToAnalyzeFromCompilerCallData(callGroupToProjectPart,
compilerCallData, compilerCallData,
m_targetTriple); m_targetTriple);
} }

View File

@@ -1782,12 +1782,15 @@ void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Ptr &
projectFileLocation += ":" + QString::number(part->projectFileLine); projectFileLocation += ":" + QString::number(part->projectFileLine);
if (part->projectFileColumn > 0) if (part->projectFileColumn > 0)
projectFileLocation += ":" + QString::number(part->projectFileColumn); projectFileLocation += ":" + QString::number(part->projectFileColumn);
const QString callGroupId = part->callGroupId.isEmpty() ? QString::fromLatin1("<None>")
: part->callGroupId;
KeyValueModel::Table table = KeyValueModel::Table() KeyValueModel::Table table = KeyValueModel::Table()
<< qMakePair(QString::fromLatin1("Project Part Name"), part->displayName) << qMakePair(QString::fromLatin1("Project Part Name"), part->displayName)
<< qMakePair(QString::fromLatin1("Project Part File"), projectFileLocation) << qMakePair(QString::fromLatin1("Project Part File"), projectFileLocation)
<< qMakePair(QString::fromLatin1("Project Name"), projectName) << qMakePair(QString::fromLatin1("Project Name"), projectName)
<< qMakePair(QString::fromLatin1("Project File"), projectFilePath) << qMakePair(QString::fromLatin1("Project File"), projectFilePath)
<< qMakePair(QString::fromLatin1("Callgroup Id"), callGroupId)
<< qMakePair(QString::fromLatin1("Selected For Building"), << qMakePair(QString::fromLatin1("Selected For Building"),
CMI::Utils::toString(part->selectedForBuilding)) CMI::Utils::toString(part->selectedForBuilding))
<< qMakePair(QString::fromLatin1("Language Version"), << qMakePair(QString::fromLatin1("Language Version"),

View File

@@ -184,6 +184,7 @@ static ProjectPart::Ptr projectPartFromRawProjectPart(const RawProjectPart &rawP
part->projectConfigFile = rawProjectPart.projectConfigFile; part->projectConfigFile = rawProjectPart.projectConfigFile;
part->projectFileLine = rawProjectPart.projectFileLine; part->projectFileLine = rawProjectPart.projectFileLine;
part->projectFileColumn = rawProjectPart.projectFileColumn; part->projectFileColumn = rawProjectPart.projectFileColumn;
part->callGroupId = rawProjectPart.callGroupId;
part->qtVersion = rawProjectPart.qtVersion; part->qtVersion = rawProjectPart.qtVersion;
part->projectDefines = rawProjectPart.projectDefines; part->projectDefines = rawProjectPart.projectDefines;
part->headerPaths = rawProjectPart.headerPaths; part->headerPaths = rawProjectPart.headerPaths;

View File

@@ -66,6 +66,11 @@ void RawProjectPart::setConfigFileName(const QString &configFileName)
this->projectConfigFile = configFileName; this->projectConfigFile = configFileName;
} }
void RawProjectPart::setCallGroupId(const QString &id)
{
callGroupId = id;
}
void RawProjectPart::setQtVersion(ProjectPart::QtVersion qtVersion) void RawProjectPart::setQtVersion(ProjectPart::QtVersion qtVersion)
{ {
this->qtVersion = qtVersion; this->qtVersion = qtVersion;

View File

@@ -62,6 +62,7 @@ public:
void setProjectFile(const QString &projectFile, int line = -1, int column = -1); void setProjectFile(const QString &projectFile, int line = -1, int column = -1);
void setConfigFileName(const QString &configFileName); void setConfigFileName(const QString &configFileName);
void setCallGroupId(const QString &id);
void setQtVersion(ProjectPart::QtVersion qtVersion); void setQtVersion(ProjectPart::QtVersion qtVersion);
@@ -82,6 +83,7 @@ public:
int projectFileLine = -1; int projectFileLine = -1;
int projectFileColumn = -1; int projectFileColumn = -1;
QString projectConfigFile; // currently only used by the Generic Project Manager QString projectConfigFile; // currently only used by the Generic Project Manager
QString callGroupId;
QStringList precompiledHeaders; QStringList precompiledHeaders;
ProjectPartHeaderPaths headerPaths; ProjectPartHeaderPaths headerPaths;
QByteArray projectDefines; QByteArray projectDefines;

View File

@@ -108,6 +108,7 @@ public:
int projectFileLine = -1; int projectFileLine = -1;
int projectFileColumn = -1; int projectFileColumn = -1;
QString projectConfigFile; // currently only used by the Generic Project Manager QString projectConfigFile; // currently only used by the Generic Project Manager
QString callGroupId;
ProjectFiles files; ProjectFiles files;

View File

@@ -790,7 +790,7 @@ static CppTools::ProjectFile::Kind cppFileType(const qbs::ArtifactData &sourceFi
return CppTools::ProjectFile::Unsupported; return CppTools::ProjectFile::Unsupported;
} }
static QString groupLocationToProjectFile(const qbs::CodeLocation &location) static QString groupLocationToCallGroupId(const qbs::CodeLocation &location)
{ {
return QString::fromLatin1("%1:%2:%3") return QString::fromLatin1("%1:%2:%3")
.arg(location.filePath()) .arg(location.filePath())
@@ -950,6 +950,7 @@ void QbsProject::updateCppCodeModel()
CppTools::RawProjectPart rpp; CppTools::RawProjectPart rpp;
rpp.setQtVersion(qtVersionForPart); rpp.setQtVersion(qtVersionForPart);
const qbs::PropertyMap &props = grp.properties(); const qbs::PropertyMap &props = grp.properties();
rpp.setCallGroupId(groupLocationToCallGroupId(grp.location()));
QStringList cFlags; QStringList cFlags;
QStringList cxxFlags; QStringList cxxFlags;
@@ -1091,7 +1092,7 @@ void QbsProject::updateCppCompilerCallData()
continue; continue;
CppTools::ProjectInfo::CompilerCallGroup compilerCallGroup; CppTools::ProjectInfo::CompilerCallGroup compilerCallGroup;
compilerCallGroup.groupId = groupLocationToProjectFile(group.location()); compilerCallGroup.groupId = groupLocationToCallGroupId(group.location());
foreach (const qbs::ArtifactData &file, group.allSourceArtifacts()) { foreach (const qbs::ArtifactData &file, group.allSourceArtifacts()) {
const QString &filePath = file.filePath(); const QString &filePath = file.filePath();