Commit 269e699f authored by Tobias Hunger's avatar Tobias Hunger

CMake: Pass scanned files on to builddirreaders

Change-Id: I226aeafe6800a84fe4bbf8cf6fd21b8237575a88
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 737b7c94
......@@ -326,7 +326,28 @@ bool BuildDirManager::persistCMakeState()
void BuildDirManager::generateProjectTree(CMakeProjectNode *root)
{
QTC_ASSERT(m_reader, return);
m_reader->generateProjectTree(root);
QTC_ASSERT(m_futureInterface, return);
const Utils::FileName projectFile = m_buildConfiguration->target()->project()->projectFilePath();
QList<FileNode *> tmp = Utils::filtered(m_futureInterface->future().result(),
[projectFile](const FileNode *fn) -> bool {
const Utils::FileName &path = fn->filePath();
return path != projectFile && !path.toString().startsWith(projectFile.toString() + ".user");
});
Utils::sort(tmp, ProjectExplorer::Node::sortByPath);
m_futureInterface.reset(); // Make sure to flush the stale results
const QList<FileNode *> allFiles = tmp;
m_reader->generateProjectTree(root, allFiles);
QSet<FileNode *> usedNodes;
foreach (FileNode *fn, root->recursiveFileNodes())
usedNodes.insert(fn);
QList<FileNode *> leftOvers = Utils::filtered(allFiles, [&usedNodes](FileNode *fn) {
return !usedNodes.contains(fn);
});
qDeleteAll(leftOvers);
}
QSet<Core::Id> BuildDirManager::updateCodeModel(CppTools::ProjectPartBuilder &ppBuilder)
......
......@@ -99,7 +99,8 @@ public:
virtual CMakeConfig parsedConfiguration() const = 0;
virtual QList<CMakeBuildTarget> buildTargets() const = 0;
virtual void generateProjectTree(CMakeProjectNode *root) = 0;
virtual void generateProjectTree(CMakeProjectNode *root,
const QList<ProjectExplorer::FileNode *> &allFiles) = 0;
virtual QSet<Core::Id> updateCodeModel(CppTools::ProjectPartBuilder &ppBuilder) = 0;
signals:
......
......@@ -211,8 +211,9 @@ CMakeConfig ServerModeReader::parsedConfiguration() const
return m_cmakeCache;
}
void ServerModeReader::generateProjectTree(CMakeProjectNode *root)
void ServerModeReader::generateProjectTree(CMakeProjectNode *root, const QList<FileNode *> &allFiles)
{
Q_UNUSED(allFiles);
QSet<Utils::FileName> knownFiles;
for (auto it = m_cmakeInputsFileNodes.constBegin(); it != m_cmakeInputsFileNodes.constEnd(); ++it)
knownFiles.insert((*it)->filePath());
......
......@@ -64,7 +64,7 @@ public:
QList<CMakeBuildTarget> buildTargets() const final;
CMakeConfig parsedConfiguration() const final;
void generateProjectTree(CMakeProjectNode *root) final;
void generateProjectTree(CMakeProjectNode *root, const QList<ProjectExplorer::FileNode *> &allFiles) final;
QSet<Core::Id> updateCodeModel(CppTools::ProjectPartBuilder &ppBuilder) final;
private:
......
......@@ -318,8 +318,9 @@ CMakeConfig TeaLeafReader::parseConfiguration(const FileName &cacheFile, QString
return result;
}
void TeaLeafReader::generateProjectTree(CMakeProjectNode *root)
void TeaLeafReader::generateProjectTree(CMakeProjectNode *root, const QList<FileNode *> &allFiles)
{
Q_UNUSED(allFiles);
root->setDisplayName(m_projectName);
// Delete no longer necessary file watcher:
......
......@@ -52,7 +52,8 @@ public:
QList<CMakeBuildTarget> buildTargets() const final;
CMakeConfig parsedConfiguration() const final;
void generateProjectTree(CMakeProjectNode *root) final;
void generateProjectTree(CMakeProjectNode *root,
const QList<ProjectExplorer::FileNode *> &allFiles) final;
QSet<Core::Id> updateCodeModel(CppTools::ProjectPartBuilder &ppBuilder) final;
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment