Commit 3bb3f4af authored by Tobias Hunger's avatar Tobias Hunger

CMake: Filter out CMake input files that are already listed

Filter out CMake input files that are already listed elsewhere in the
project tree. This is server-mode only.

Change-Id: Ib62cd5b521a51180d12d76ec2868a99dbdecc272
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 315cede7
...@@ -243,7 +243,7 @@ CMakeConfig ServerModeReader::takeParsedConfiguration() ...@@ -243,7 +243,7 @@ CMakeConfig ServerModeReader::takeParsedConfiguration()
} }
static void addCMakeVFolder(FolderNode *base, const Utils::FileName &basePath, int priority, static void addCMakeVFolder(FolderNode *base, const Utils::FileName &basePath, int priority,
const QString &displayName, QList<FileNode *> &files) const QString &displayName, const QList<FileNode *> &files)
{ {
if (files.isEmpty()) if (files.isEmpty())
return; return;
...@@ -258,6 +258,17 @@ static void addCMakeVFolder(FolderNode *base, const Utils::FileName &basePath, i ...@@ -258,6 +258,17 @@ static void addCMakeVFolder(FolderNode *base, const Utils::FileName &basePath, i
fn->compress(); fn->compress();
} }
static QList<FileNode *> removeKnownNodes(const QSet<Utils::FileName> &knownFiles, const QList<FileNode *> &files)
{
return Utils::filtered(files, [&knownFiles](const FileNode *n) {
if (knownFiles.contains(n->filePath())) {
delete n;
return false;
}
return true;
});
}
static void addCMakeInputs(FolderNode *root, static void addCMakeInputs(FolderNode *root,
const Utils::FileName &sourceDir, const Utils::FileName &sourceDir,
const Utils::FileName &buildDir, const Utils::FileName &buildDir,
...@@ -268,13 +279,19 @@ static void addCMakeInputs(FolderNode *root, ...@@ -268,13 +279,19 @@ static void addCMakeInputs(FolderNode *root,
ProjectNode *cmakeVFolder = new CMakeInputsNode(root->filePath()); ProjectNode *cmakeVFolder = new CMakeInputsNode(root->filePath());
root->addNode(cmakeVFolder); root->addNode(cmakeVFolder);
addCMakeVFolder(cmakeVFolder, sourceDir, 1000, QString(), sourceInputs); QSet<Utils::FileName> knownFiles;
root->forEachGenericNode([&knownFiles](const Node *n) {
if (n->listInProject())
knownFiles.insert(n->filePath());
});
addCMakeVFolder(cmakeVFolder, sourceDir, 1000, QString(), removeKnownNodes(knownFiles, sourceInputs));
addCMakeVFolder(cmakeVFolder, buildDir, 100, addCMakeVFolder(cmakeVFolder, buildDir, 100,
QCoreApplication::translate("CMakeProjectManager::Internal::ServerModeReader", "<Build Directory>"), QCoreApplication::translate("CMakeProjectManager::Internal::ServerModeReader", "<Build Directory>"),
buildInputs); removeKnownNodes(knownFiles, buildInputs));
addCMakeVFolder(cmakeVFolder, Utils::FileName(), 10, addCMakeVFolder(cmakeVFolder, Utils::FileName(), 10,
QCoreApplication::translate("CMakeProjectManager::Internal::ServerModeReader", "<Other Locations>"), QCoreApplication::translate("CMakeProjectManager::Internal::ServerModeReader", "<Other Locations>"),
rootInputs); removeKnownNodes(knownFiles, rootInputs));
} }
void ServerModeReader::generateProjectTree(CMakeProjectNode *root, void ServerModeReader::generateProjectTree(CMakeProjectNode *root,
...@@ -305,15 +322,15 @@ void ServerModeReader::generateProjectTree(CMakeProjectNode *root, ...@@ -305,15 +322,15 @@ void ServerModeReader::generateProjectTree(CMakeProjectNode *root,
if (topLevel) if (topLevel)
root->setDisplayName(topLevel->name); root->setDisplayName(topLevel->name);
if (!cmakeFilesSource.isEmpty() || !cmakeFilesBuild.isEmpty() || !cmakeFilesOther.isEmpty())
addCMakeInputs(root, m_parameters.sourceDirectory, m_parameters.buildDirectory,
cmakeFilesSource, cmakeFilesBuild, cmakeFilesOther);
QHash<Utils::FileName, ProjectNode *> cmakeListsNodes = addCMakeLists(root, cmakeLists); QHash<Utils::FileName, ProjectNode *> cmakeListsNodes = addCMakeLists(root, cmakeLists);
QList<FileNode *> knownHeaders; QList<FileNode *> knownHeaders;
addProjects(cmakeListsNodes, m_projects, knownHeaders); addProjects(cmakeListsNodes, m_projects, knownHeaders);
addHeaderNodes(root, knownHeaders, allFiles); addHeaderNodes(root, knownHeaders, allFiles);
if (!cmakeFilesSource.isEmpty() || !cmakeFilesBuild.isEmpty() || !cmakeFilesOther.isEmpty())
addCMakeInputs(root, m_parameters.sourceDirectory, m_parameters.buildDirectory,
cmakeFilesSource, cmakeFilesBuild, cmakeFilesOther);
} }
void ServerModeReader::updateCodeModel(CppTools::RawProjectParts &rpps) void ServerModeReader::updateCodeModel(CppTools::RawProjectParts &rpps)
......
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