ProjectExplorer: Pass extra project files as QSet

They are available in some cases as such, and consumed as such.

Change-Id: I9866c7d7bd817fb19a8b11a0efbe583ed55fe393
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2020-03-02 18:34:12 +01:00
parent 757628bf4a
commit b0b50257ec
14 changed files with 22 additions and 22 deletions

View File

@@ -110,7 +110,7 @@ void AutotoolsBuildSystem::makefileParsingFinished()
m_files.clear(); m_files.clear();
QVector<Utils::FilePath> filesToWatch; QSet<Utils::FilePath> filesToWatch;
// Apply sources to m_files, which are returned at AutotoolsBuildSystem::files() // Apply sources to m_files, which are returned at AutotoolsBuildSystem::files()
const QFileInfo fileInfo = projectFilePath().toFileInfo(); const QFileInfo fileInfo = projectFilePath().toFileInfo();
@@ -127,7 +127,7 @@ void AutotoolsBuildSystem::makefileParsingFinished()
m_files.append(absMakefile); m_files.append(absMakefile);
filesToWatch.append(Utils::FilePath::fromString(absMakefile)); filesToWatch.insert(Utils::FilePath::fromString(absMakefile));
} }
// Add configure.ac file to project and watch for changes. // Add configure.ac file to project and watch for changes.
@@ -137,7 +137,7 @@ void AutotoolsBuildSystem::makefileParsingFinished()
const QString absConfigureAc = dir.absoluteFilePath(configureAc); const QString absConfigureAc = dir.absoluteFilePath(configureAc);
m_files.append(absConfigureAc); m_files.append(absConfigureAc);
filesToWatch.append(Utils::FilePath::fromString(absConfigureAc)); filesToWatch.insert(Utils::FilePath::fromString(absConfigureAc));
} }
auto newRoot = std::make_unique<ProjectNode>(project()->projectDirectory()); auto newRoot = std::make_unique<ProjectNode>(project()->projectDirectory());

View File

@@ -390,7 +390,7 @@ void BuildDirManager::parse()
reparseParameters & REPARSE_FORCE_CONFIGURATION); reparseParameters & REPARSE_FORCE_CONFIGURATION);
} }
QVector<FilePath> BuildDirManager::takeProjectFilesToWatch() QSet<FilePath> BuildDirManager::projectFilesToWatch() const
{ {
QTC_ASSERT(!m_isHandlingError, return {}); QTC_ASSERT(!m_isHandlingError, return {});
QTC_ASSERT(m_reader, return {}); QTC_ASSERT(m_reader, return {});
@@ -398,7 +398,7 @@ QVector<FilePath> BuildDirManager::takeProjectFilesToWatch()
Utils::FilePath sourceDir = m_parameters.sourceDirectory; Utils::FilePath sourceDir = m_parameters.sourceDirectory;
Utils::FilePath buildDir = m_parameters.workDirectory; Utils::FilePath buildDir = m_parameters.workDirectory;
return Utils::filtered(m_reader->takeProjectFilesToWatch(), return Utils::filtered(m_reader->projectFilesToWatch(),
[&sourceDir, [&sourceDir,
&buildDir](const Utils::FilePath &p) { &buildDir](const Utils::FilePath &p) {
return p.isChildOf(sourceDir) return p.isChildOf(sourceDir)

View File

@@ -89,7 +89,7 @@ public:
bool isFilesystemScanRequested() const; bool isFilesystemScanRequested() const;
void parse(); void parse();
QVector<Utils::FilePath> takeProjectFilesToWatch(); QSet<Utils::FilePath> projectFilesToWatch() const;
std::unique_ptr<CMakeProjectNode> generateProjectTree(const QList<const ProjectExplorer::FileNode *> &allFiles, std::unique_ptr<CMakeProjectNode> generateProjectTree(const QList<const ProjectExplorer::FileNode *> &allFiles,
QString &errorMessage) const; QString &errorMessage) const;
ProjectExplorer::RawProjectParts createRawProjectParts(QString &errorMessage) const; ProjectExplorer::RawProjectParts createRawProjectParts(QString &errorMessage) const;

View File

@@ -63,7 +63,7 @@ public:
virtual bool isParsing() const = 0; virtual bool isParsing() const = 0;
virtual QVector<Utils::FilePath> takeProjectFilesToWatch() = 0; virtual QSet<Utils::FilePath> projectFilesToWatch() const = 0;
virtual QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage) = 0; virtual QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage) = 0;
virtual CMakeConfig takeParsedConfiguration(QString &errorMessage) = 0; virtual CMakeConfig takeParsedConfiguration(QString &errorMessage) = 0;
virtual std::unique_ptr<CMakeProjectNode> generateProjectTree( virtual std::unique_ptr<CMakeProjectNode> generateProjectTree(

View File

@@ -409,7 +409,7 @@ void CMakeBuildSystem::updateProjectData()
QTC_ASSERT(m_treeScanner.isFinished() && !m_buildDirManager.isParsing(), return); QTC_ASSERT(m_treeScanner.isFinished() && !m_buildDirManager.isParsing(), return);
m_buildConfiguration->project()->setExtraProjectFiles(m_buildDirManager.takeProjectFilesToWatch()); m_buildConfiguration->project()->setExtraProjectFiles(m_buildDirManager.projectFilesToWatch());
CMakeConfig patchedConfig = m_buildConfiguration->configurationFromCMake(); CMakeConfig patchedConfig = m_buildConfiguration->configurationFromCMake();
{ {

View File

@@ -164,9 +164,9 @@ bool FileApiReader::isParsing() const
return m_isParsing; return m_isParsing;
} }
QVector<FilePath> FileApiReader::takeProjectFilesToWatch() QSet<FilePath> FileApiReader::projectFilesToWatch() const
{ {
return QVector<FilePath>::fromList(Utils::toList(m_cmakeFiles)); return m_cmakeFiles;
} }
QList<CMakeBuildTarget> FileApiReader::takeBuildTargets(QString &errorMessage){ QList<CMakeBuildTarget> FileApiReader::takeBuildTargets(QString &errorMessage){

View File

@@ -62,7 +62,7 @@ public:
bool isParsing() const final; bool isParsing() const final;
QVector<Utils::FilePath> takeProjectFilesToWatch() final; QSet<Utils::FilePath> projectFilesToWatch() const final;
QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage) final; QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage) final;
CMakeConfig takeParsedConfiguration(QString &errorMessage) final; CMakeConfig takeParsedConfiguration(QString &errorMessage) final;
std::unique_ptr<CMakeProjectNode> generateProjectTree( std::unique_ptr<CMakeProjectNode> generateProjectTree(

View File

@@ -55,7 +55,7 @@ public:
bool isParsing() const final; bool isParsing() const final;
QVector<Utils::FilePath> takeProjectFilesToWatch() final { return {}; }; QSet<Utils::FilePath> projectFilesToWatch() const final { return {}; };
QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage) final; QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage) final;
CMakeConfig takeParsedConfiguration(QString &errorMessage) final; CMakeConfig takeParsedConfiguration(QString &errorMessage) final;
std::unique_ptr<CMakeProjectNode> generateProjectTree( std::unique_ptr<CMakeProjectNode> generateProjectTree(

View File

@@ -160,9 +160,9 @@ bool TeaLeafReader::isParsing() const
return m_cmakeProcess && m_cmakeProcess->state() != QProcess::NotRunning; return m_cmakeProcess && m_cmakeProcess->state() != QProcess::NotRunning;
} }
QVector<FilePath> TeaLeafReader::takeProjectFilesToWatch() QSet<FilePath> TeaLeafReader::projectFilesToWatch() const
{ {
return transform<QVector>(m_cmakeFiles, [](const FilePath &p) { return p; }); return m_cmakeFiles;
} }
QList<CMakeBuildTarget> TeaLeafReader::takeBuildTargets(QString &errorMessage) QList<CMakeBuildTarget> TeaLeafReader::takeBuildTargets(QString &errorMessage)

View File

@@ -54,7 +54,7 @@ public:
bool isParsing() const final; bool isParsing() const final;
QVector<Utils::FilePath> takeProjectFilesToWatch() final; QSet<Utils::FilePath> projectFilesToWatch() const final;
QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage) final; QList<CMakeBuildTarget> takeBuildTargets(QString &errorMessage) final;
CMakeConfig takeParsedConfiguration(QString &errorMessage) final; CMakeConfig takeParsedConfiguration(QString &errorMessage) final;
std::unique_ptr<CMakeProjectNode> generateProjectTree( std::unique_ptr<CMakeProjectNode> generateProjectTree(

View File

@@ -354,9 +354,9 @@ void Project::setNeedsInitialExpansion(bool needsExpansion)
d->m_needsInitialExpansion = needsExpansion; d->m_needsInitialExpansion = needsExpansion;
} }
void Project::setExtraProjectFiles(const QVector<Utils::FilePath> &projectDocumentPaths) void Project::setExtraProjectFiles(const QSet<Utils::FilePath> &projectDocumentPaths)
{ {
QSet<Utils::FilePath> uniqueNewFiles = Utils::toSet(projectDocumentPaths); QSet<Utils::FilePath> uniqueNewFiles = projectDocumentPaths;
uniqueNewFiles.remove(projectFilePath()); // Make sure to never add the main project file! uniqueNewFiles.remove(projectFilePath()); // Make sure to never add the main project file!
QSet<Utils::FilePath> existingWatches = Utils::transform<QSet>(d->m_extraProjectDocuments, QSet<Utils::FilePath> existingWatches = Utils::transform<QSet>(d->m_extraProjectDocuments,

View File

@@ -164,7 +164,7 @@ public:
// Set project files that will be watched and trigger the same callback // Set project files that will be watched and trigger the same callback
// as the main project file. // as the main project file.
void setExtraProjectFiles(const QVector<Utils::FilePath> &projectDocumentPaths); void setExtraProjectFiles(const QSet<Utils::FilePath> &projectDocumentPaths);
void setDisplayName(const QString &name); void setDisplayName(const QString &name);
void setProjectLanguage(Core::Id id, bool enabled); void setProjectLanguage(Core::Id id, bool enabled);

View File

@@ -700,13 +700,13 @@ void QbsBuildSystem::updateDocuments()
OpTimer opTimer("updateDocuments"); OpTimer opTimer("updateDocuments");
const FilePath buildDir = FilePath::fromString( const FilePath buildDir = FilePath::fromString(
m_projectData.value("build-directory").toString()); m_projectData.value("build-directory").toString());
const auto filePaths = transform<QVector<FilePath>>( const auto filePaths = transform<QSet<FilePath>>(
m_projectData.value("build-system-files").toArray(), m_projectData.value("build-system-files").toArray(),
[](const QJsonValue &v) { return FilePath::fromString(v.toString()); }); [](const QJsonValue &v) { return FilePath::fromString(v.toString()); });
// A changed qbs file (project, module etc) should trigger a re-parse, but not if // A changed qbs file (project, module etc) should trigger a re-parse, but not if
// the file was generated by qbs itself, in which case that might cause an infinite loop. // the file was generated by qbs itself, in which case that might cause an infinite loop.
const QVector<FilePath> nonBuildDirFilePaths = filtered(filePaths, const QSet<FilePath> nonBuildDirFilePaths = filtered(filePaths,
[buildDir](const FilePath &p) { [buildDir](const FilePath &p) {
return !p.isChildOf(buildDir); return !p.isChildOf(buildDir);
}); });

View File

@@ -263,9 +263,9 @@ void QmakeBuildSystem::updateCodeModels()
void QmakeBuildSystem::updateDocuments() void QmakeBuildSystem::updateDocuments()
{ {
QVector<FilePath> projectDocuments; QSet<FilePath> projectDocuments;
project()->rootProjectNode()->forEachProjectNode([&projectDocuments](const ProjectNode *n) { project()->rootProjectNode()->forEachProjectNode([&projectDocuments](const ProjectNode *n) {
projectDocuments << n->filePath(); projectDocuments.insert(n->filePath());
}); });
project()->setExtraProjectFiles(projectDocuments); project()->setExtraProjectFiles(projectDocuments);
} }