summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppprojectfilecategorizer.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2019-01-04 09:07:55 +0100
committerNikolai Kosjar <nikolai.kosjar@qt.io>2019-01-08 14:09:52 +0000
commit820e4f8177dff43c9ddd4735d6a6e4e575cd4f69 (patch)
tree967820d022d8e6eb8224e032029fc55494e10e7b /src/plugins/cpptools/cppprojectfilecategorizer.cpp
parente4f488cb5c8d9ec752dc14895c6132a9a82030cd (diff)
downloadqt-creator-820e4f8177dff43c9ddd4735d6a6e4e575cd4f69.tar.gz
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 <oswald.buddenhagen@qt.io> Change-Id: I7a28b4de15e048975d7f0cd737dd8c11f744315b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cppprojectfilecategorizer.cpp')
-rw-r--r--src/plugins/cpptools/cppprojectfilecategorizer.cpp42
1 files changed, 20 insertions, 22 deletions
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 <utils/algorithm.h>
+
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();