From 820e4f8177dff43c9ddd4735d6a6e4e575cd4f69 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 4 Jan 2019 09:07:55 +0100 Subject: ClangTools/QMake: Stop analyzing files not part of build configuration ...for the qmake project manager. When parsing the project files, remember whether a file was discovered by the exact or cumulative parse. Only files that were discovered by the exact parse are considered "active" and thus part of the build configuration. The others are not offered for selection. Fixes: QTCREATORBUG-16016 Started-by: Oswald Buddenhagen Change-Id: I7a28b4de15e048975d7f0cd737dd8c11f744315b Reviewed-by: Oswald Buddenhagen Reviewed-by: Christian Kandeler --- src/plugins/cpptools/cppprojectfilecategorizer.cpp | 42 +++++++++++----------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'src/plugins/cpptools/cppprojectfilecategorizer.cpp') diff --git a/src/plugins/cpptools/cppprojectfilecategorizer.cpp b/src/plugins/cpptools/cppprojectfilecategorizer.cpp index 063dfd5dba..d0f4940052 100644 --- a/src/plugins/cpptools/cppprojectfilecategorizer.cpp +++ b/src/plugins/cpptools/cppprojectfilecategorizer.cpp @@ -25,6 +25,8 @@ #include "cppprojectfilecategorizer.h" +#include + namespace CppTools { ProjectFileCategorizer::ProjectFileCategorizer(const QString &projectPartName, @@ -32,7 +34,7 @@ ProjectFileCategorizer::ProjectFileCategorizer(const QString &projectPartName, FileClassifier fileClassifier) : m_partName(projectPartName) { - const QStringList ambiguousHeaders = classifyFiles(filePaths, fileClassifier); + const ProjectFiles ambiguousHeaders = classifyFiles(filePaths, fileClassifier); expandSourcesWithAmbiguousHeaders(ambiguousHeaders); m_partCount = (m_cSources.isEmpty() ? 0 : 1) @@ -50,35 +52,35 @@ QString ProjectFileCategorizer::partName(const QString &languageName) const return m_partName; } -QStringList ProjectFileCategorizer::classifyFiles(const QStringList &filePaths, - FileClassifier fileClassifier) +ProjectFiles ProjectFileCategorizer::classifyFiles(const QStringList &filePaths, + FileClassifier fileClassifier) { - QStringList ambiguousHeaders; + ProjectFiles ambiguousHeaders; foreach (const QString &filePath, filePaths) { - const ProjectFile::Kind kind = fileClassifier + const ProjectFile projectFile = fileClassifier ? fileClassifier(filePath) - : ProjectFile::classify(filePath); + : ProjectFile(filePath, ProjectFile::classify(filePath)); - switch (kind) { + switch (projectFile.kind) { case ProjectFile::AmbiguousHeader: - ambiguousHeaders += filePath; + ambiguousHeaders += projectFile; break; case ProjectFile::CXXSource: case ProjectFile::CXXHeader: - m_cxxSources += ProjectFile(filePath, kind); + m_cxxSources += projectFile; break; case ProjectFile::ObjCXXSource: case ProjectFile::ObjCXXHeader: - m_objcxxSources += ProjectFile(filePath, kind); + m_objcxxSources += projectFile; break; case ProjectFile::CSource: case ProjectFile::CHeader: - m_cSources += ProjectFile(filePath, kind); + m_cSources += projectFile; break; case ProjectFile::ObjCSource: case ProjectFile::ObjCHeader: - m_objcSources += ProjectFile(filePath, kind); + m_objcSources += projectFile; break; default: continue; @@ -88,19 +90,15 @@ QStringList ProjectFileCategorizer::classifyFiles(const QStringList &filePaths, return ambiguousHeaders; } -static ProjectFiles toProjectFilesWithKind(const QStringList &filePaths, - const ProjectFile::Kind kind) +static ProjectFiles toProjectFilesWithKind(const ProjectFiles &ambiguousHeaders, + const ProjectFile::Kind overriddenKind) { - ProjectFiles projectFiles; - projectFiles.reserve(filePaths.size()); - - foreach (const QString &filePath, filePaths) - projectFiles += ProjectFile(filePath, kind); - - return projectFiles; + return Utils::transform(ambiguousHeaders, [overriddenKind](const ProjectFile &projectFile) { + return ProjectFile(projectFile.path, overriddenKind, projectFile.active); + }); } -void ProjectFileCategorizer::expandSourcesWithAmbiguousHeaders(const QStringList &ambiguousHeaders) +void ProjectFileCategorizer::expandSourcesWithAmbiguousHeaders(const ProjectFiles &ambiguousHeaders) { const bool hasC = !m_cSources.isEmpty(); const bool hasCxx = !m_cxxSources.isEmpty(); -- cgit v1.2.1