forked from qt-creator/qt-creator
ProjectPart: Allow for line/column information in project file
Keep this information separate so that plugins using the information do not need to start parsing the project file. Change-Id: Ibecf431de1b12bbe820c6f8f9c986cffeb4972d2 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -405,7 +405,12 @@ static QHash<QString, ProjectPart::Ptr> generateProjectFileToProjectPartMapping(
|
|||||||
|
|
||||||
foreach (const ProjectPart::Ptr &projectPart, projectParts) {
|
foreach (const ProjectPart::Ptr &projectPart, projectParts) {
|
||||||
QTC_ASSERT(projectPart, continue);
|
QTC_ASSERT(projectPart, continue);
|
||||||
mapping[projectPart->projectFile] = projectPart;
|
QString projectFile = projectPart->projectFile;
|
||||||
|
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;
|
||||||
|
|||||||
@@ -1777,10 +1777,15 @@ void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Ptr &
|
|||||||
projectName = project->displayName();
|
projectName = project->displayName();
|
||||||
projectFilePath = project->projectFilePath().toUserOutput();
|
projectFilePath = project->projectFilePath().toUserOutput();
|
||||||
}
|
}
|
||||||
|
QString projectFileLocation = QDir::toNativeSeparators(part->projectFile);
|
||||||
|
if (part->projectFileLine > 0)
|
||||||
|
projectFileLocation += ":" + QString::number(part->projectFileLine);
|
||||||
|
if (part->projectFileColumn > 0)
|
||||||
|
projectFileLocation += ":" + QString::number(part->projectFileColumn);
|
||||||
|
|
||||||
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"),
|
<< qMakePair(QString::fromLatin1("Project Part File"), projectFileLocation)
|
||||||
QDir::toNativeSeparators(part->projectFile))
|
|
||||||
<< 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("Selected For Building"),
|
<< qMakePair(QString::fromLatin1("Selected For Building"),
|
||||||
|
|||||||
@@ -182,6 +182,8 @@ static ProjectPart::Ptr projectPartFromRawProjectPart(const RawProjectPart &rawP
|
|||||||
part->project = project;
|
part->project = project;
|
||||||
part->projectFile = rawProjectPart.projectFile;
|
part->projectFile = rawProjectPart.projectFile;
|
||||||
part->projectConfigFile = rawProjectPart.projectConfigFile;
|
part->projectConfigFile = rawProjectPart.projectConfigFile;
|
||||||
|
part->projectFileLine = rawProjectPart.projectFileLine;
|
||||||
|
part->projectFileColumn = rawProjectPart.projectFileColumn;
|
||||||
part->qtVersion = rawProjectPart.qtVersion;
|
part->qtVersion = rawProjectPart.qtVersion;
|
||||||
part->projectDefines = rawProjectPart.projectDefines;
|
part->projectDefines = rawProjectPart.projectDefines;
|
||||||
part->headerPaths = rawProjectPart.headerPaths;
|
part->headerPaths = rawProjectPart.headerPaths;
|
||||||
|
|||||||
@@ -54,9 +54,11 @@ void RawProjectPart::setFiles(const QStringList &files, FileClassifier fileClass
|
|||||||
this->fileClassifier = fileClassifier;
|
this->fileClassifier = fileClassifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawProjectPart::setProjectFile(const QString &projectFile)
|
void RawProjectPart::setProjectFile(const QString &projectFile, int line, int column)
|
||||||
{
|
{
|
||||||
this->projectFile = projectFile;
|
this->projectFile = projectFile;
|
||||||
|
projectFileLine = line;
|
||||||
|
projectFileColumn = column;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawProjectPart::setConfigFileName(const QString &configFileName)
|
void RawProjectPart::setConfigFileName(const QString &configFileName)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
using FileClassifier = std::function<ProjectFile::Kind (const QString &filePath)>;
|
using FileClassifier = std::function<ProjectFile::Kind (const QString &filePath)>;
|
||||||
void setFiles(const QStringList &files, FileClassifier fileClassifier = FileClassifier());
|
void setFiles(const QStringList &files, FileClassifier fileClassifier = FileClassifier());
|
||||||
|
|
||||||
void setProjectFile(const QString &projectFile);
|
void setProjectFile(const QString &projectFile, int line = -1, int column = -1);
|
||||||
void setConfigFileName(const QString &configFileName);
|
void setConfigFileName(const QString &configFileName);
|
||||||
|
|
||||||
void setQtVersion(ProjectPart::QtVersion qtVersion);
|
void setQtVersion(ProjectPart::QtVersion qtVersion);
|
||||||
@@ -79,6 +79,8 @@ public:
|
|||||||
public:
|
public:
|
||||||
QString displayName;
|
QString displayName;
|
||||||
QString projectFile;
|
QString projectFile;
|
||||||
|
int projectFileLine = -1;
|
||||||
|
int projectFileColumn = -1;
|
||||||
QString projectConfigFile; // currently only used by the Generic Project Manager
|
QString projectConfigFile; // currently only used by the Generic Project Manager
|
||||||
QStringList precompiledHeaders;
|
QStringList precompiledHeaders;
|
||||||
ProjectPartHeaderPaths headerPaths;
|
ProjectPartHeaderPaths headerPaths;
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ ProjectPart::Ptr ProjectPart::copy() const
|
|||||||
QString ProjectPart::id() const
|
QString ProjectPart::id() const
|
||||||
{
|
{
|
||||||
QString projectPartId = QDir::fromNativeSeparators(projectFile);
|
QString projectPartId = QDir::fromNativeSeparators(projectFile);
|
||||||
|
if (projectFileLine > 0)
|
||||||
|
projectPartId += ":" + QString::number(projectFileLine);
|
||||||
|
if (projectFileColumn > 0)
|
||||||
|
projectPartId += ":" + QString::number(projectFileColumn);
|
||||||
if (!displayName.isEmpty())
|
if (!displayName.isEmpty())
|
||||||
projectPartId.append(QLatin1Char(' ') + displayName);
|
projectPartId.append(QLatin1Char(' ') + displayName);
|
||||||
return projectPartId;
|
return projectPartId;
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ public:
|
|||||||
QString displayName;
|
QString displayName;
|
||||||
|
|
||||||
QString projectFile;
|
QString projectFile;
|
||||||
|
int projectFileLine = -1;
|
||||||
|
int projectFileColumn = -1;
|
||||||
QString projectConfigFile; // currently only used by the Generic Project Manager
|
QString projectConfigFile; // currently only used by the Generic Project Manager
|
||||||
|
|
||||||
ProjectFiles files;
|
ProjectFiles files;
|
||||||
|
|||||||
@@ -996,7 +996,8 @@ void QbsProject::updateCppCodeModel()
|
|||||||
rpp.setHeaderPaths(grpHeaderPaths);
|
rpp.setHeaderPaths(grpHeaderPaths);
|
||||||
|
|
||||||
rpp.setDisplayName(grp.name());
|
rpp.setDisplayName(grp.name());
|
||||||
rpp.setProjectFile(groupLocationToProjectFile(grp.location()));
|
rpp.setProjectFile(grp.location().filePath(),
|
||||||
|
grp.location().line(), grp.location().column());
|
||||||
|
|
||||||
QHash<QString, qbs::ArtifactData> filePathToSourceArtifact;
|
QHash<QString, qbs::ArtifactData> filePathToSourceArtifact;
|
||||||
bool hasCFiles = false;
|
bool hasCFiles = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user