CMake: Simplify based on Project::projectFileIsDirty signal

Delegate all the necessary file watching to Project and connect
to the relevant signal.

Server-mode insists on watching files itself, so that may not
report extra project files.

Change-Id: If821c54a7b0f8b72beed53dd1c83f255973faf3e
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Tobias Hunger
2019-08-15 12:22:09 +02:00
parent c89a8a4084
commit b8be7da158
9 changed files with 45 additions and 69 deletions

View File

@@ -306,6 +306,33 @@ void BuildDirManager::parse(int reparseParameters)
reparseParameters & REPARSE_FORCE_CONFIGURATION);
}
QVector<FilePath> BuildDirManager::takeProjectFilesToWatch()
{
QTC_ASSERT(!m_isHandlingError, return {});
QTC_ASSERT(m_reader, return {});
Utils::FilePath sourceDir = m_parameters.sourceDirectory;
Utils::FilePath buildDir = m_parameters.workDirectory;
const QVector<FilePath> toWatch = Utils::filtered(m_reader->takeProjectFilesToWatch(),
[&sourceDir,
&buildDir](const Utils::FilePath &p) {
return p.isChildOf(sourceDir)
|| p.isChildOf(buildDir);
});
if (!toWatch.isEmpty()) {
connect(project(), &Project::projectFileIsDirty, this, [this]() {
if (m_parameters.cmakeTool() && m_parameters.cmakeTool()->isAutoRun())
requestReparse(REPARSE_DEFAULT);
});
} else {
disconnect(project(), nullptr, this, nullptr);
}
return toWatch;
}
std::unique_ptr<CMakeProjectNode> BuildDirManager::generateProjectTree(
const QList<const FileNode *> &allFiles, QString &errorMessage) const
{