aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2021-08-24 15:30:04 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2021-08-30 10:46:56 +0000
commit25ff15a1fbe2288b6dc53abdb4a50a642491d118 (patch)
tree3a8f9877a88a0e6ebc450147867622ccbe1a5de9
parent5805208cec8ed90f6caa6b1b0263ecdf162227c5 (diff)
Add convenience functions for creating ProjectExplorer::HeaderPaths
Change-Id: I7b1f63caca6b70ba4ec1b1870b83cbf20aa6564a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/plugins/baremetal/iarewtoolchain.cpp2
-rw-r--r--src/plugins/baremetal/keiltoolchain.cpp4
-rw-r--r--src/plugins/baremetal/sdcctoolchain.cpp2
-rw-r--r--src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp4
-rw-r--r--src/plugins/clangcodemodel/test/clangautomationutils.cpp10
-rw-r--r--src/plugins/compilationdatabaseprojectmanager/compilationdatabasetests.cpp10
-rw-r--r--src/plugins/cppeditor/cppquickfix_test.cpp8
-rw-r--r--src/plugins/cpptools/compileroptionsbuilder_test.cpp11
-rw-r--r--src/plugins/cpptools/cppcompletionassist.cpp4
-rw-r--r--src/plugins/cpptools/cppmodelmanager_test.cpp26
-rw-r--r--src/plugins/cpptools/cppsourceprocessor.cpp8
-rw-r--r--src/plugins/cpptools/cppsourceprocessor_test.cpp10
-rw-r--r--src/plugins/cpptools/headerpathfilter.cpp6
-rw-r--r--src/plugins/cpptools/includeutils.cpp4
-rw-r--r--src/plugins/cpptools/projectinfo_test.cpp38
-rw-r--r--src/plugins/genericprojectmanager/genericproject.cpp9
-rw-r--r--src/plugins/projectexplorer/customtoolchain.cpp7
-rw-r--r--src/plugins/projectexplorer/headerpath.h46
-rw-r--r--src/plugins/projectexplorer/msvctoolchain.cpp5
-rw-r--r--src/plugins/projectexplorer/rawprojectpart.cpp9
-rw-r--r--src/plugins/qbsprojectmanager/qbsproject.cpp10
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeproject.cpp5
22 files changed, 116 insertions, 122 deletions
diff --git a/src/plugins/baremetal/iarewtoolchain.cpp b/src/plugins/baremetal/iarewtoolchain.cpp
index ef6a4d7d46e..d4f56db3535 100644
--- a/src/plugins/baremetal/iarewtoolchain.cpp
+++ b/src/plugins/baremetal/iarewtoolchain.cpp
@@ -181,7 +181,7 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Id languageId
// Ignore the QtC binary directory path.
if (headerPath != QCoreApplication::applicationDirPath())
- headerPaths.append({headerPath, HeaderPathType::BuiltIn});
+ headerPaths.append(HeaderPath::makeBuiltIn(headerPath));
pos = endQuoteIndex + 1;
}
diff --git a/src/plugins/baremetal/keiltoolchain.cpp b/src/plugins/baremetal/keiltoolchain.cpp
index de2d8f644ca..ff4a2759a5a 100644
--- a/src/plugins/baremetal/keiltoolchain.cpp
+++ b/src/plugins/baremetal/keiltoolchain.cpp
@@ -342,11 +342,11 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler)
if (isMcsArchitecture(arch) || isC166Architecture(arch)) {
QDir includeDir(toolkitDir);
if (includeDir.cd("inc"))
- headerPaths.push_back({includeDir.canonicalPath(), HeaderPathType::BuiltIn});
+ headerPaths.push_back(HeaderPath::makeBuiltIn(includeDir.canonicalPath()));
} else if (isArmArchitecture(arch)) {
QDir includeDir(toolkitDir);
if (includeDir.cd("include"))
- headerPaths.push_back({includeDir.canonicalPath(), HeaderPathType::BuiltIn});
+ headerPaths.push_back(HeaderPath::makeBuiltIn(includeDir.canonicalPath()));
}
return headerPaths;
diff --git a/src/plugins/baremetal/sdcctoolchain.cpp b/src/plugins/baremetal/sdcctoolchain.cpp
index cf8495b6781..98aef855f7a 100644
--- a/src/plugins/baremetal/sdcctoolchain.cpp
+++ b/src/plugins/baremetal/sdcctoolchain.cpp
@@ -135,7 +135,7 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Environment &
} else {
const QString headerPath = QFileInfo(line.trimmed())
.canonicalFilePath();
- headerPaths.append({headerPath, HeaderPathType::BuiltIn});
+ headerPaths.append(HeaderPath::makeBuiltIn(headerPath));
}
}
}
diff --git a/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp b/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp
index 90644fd6e4e..edc52a1ed83 100644
--- a/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp
+++ b/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp
@@ -496,8 +496,8 @@ bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
// Make completion for all relevant includes
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
- const ProjectExplorer::HeaderPath currentFilePath(m_interface->filePath().toFileInfo().path(),
- ProjectExplorer::HeaderPathType::User);
+ const auto currentFilePath = ProjectExplorer::HeaderPath::makeUser(
+ m_interface->filePath().toFileInfo().path());
if (!headerPaths.contains(currentFilePath))
headerPaths.append(currentFilePath);
diff --git a/src/plugins/clangcodemodel/test/clangautomationutils.cpp b/src/plugins/clangcodemodel/test/clangautomationutils.cpp
index 1ebb6c71b92..73f5587612f 100644
--- a/src/plugins/clangcodemodel/test/clangautomationutils.cpp
+++ b/src/plugins/clangcodemodel/test/clangautomationutils.cpp
@@ -95,14 +95,6 @@ public:
TextEditor::ProposalModelPtr proposalModel;
};
-static const ProjectExplorer::HeaderPaths toHeaderPaths(const QStringList &paths)
-{
- ProjectExplorer::HeaderPaths result;
- foreach (const QString &path, paths)
- result.push_back({path, ProjectExplorer::HeaderPathType::User});
- return result;
-}
-
TextEditor::ProposalModelPtr completionResults(TextEditor::BaseTextEditor *textEditor,
const QStringList &includePaths,
int timeOutInMs)
@@ -116,7 +108,7 @@ TextEditor::ProposalModelPtr completionResults(TextEditor::BaseTextEditor *textE
QTC_ASSERT(assistInterface, return TextEditor::ProposalModelPtr());
if (!includePaths.isEmpty()) {
auto clangAssistInterface = static_cast<ClangCompletionAssistInterface *>(assistInterface);
- clangAssistInterface->setHeaderPaths(toHeaderPaths(includePaths));
+ clangAssistInterface->setHeaderPaths(ProjectExplorer::toUserHeaderPaths(includePaths));
}
CompletionAssistProvider *assistProvider
diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabasetests.cpp b/src/plugins/compilationdatabaseprojectmanager/compilationdatabasetests.cpp
index 122d596de72..f15b134dd35 100644
--- a/src/plugins/compilationdatabaseprojectmanager/compilationdatabasetests.cpp
+++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabasetests.cpp
@@ -172,10 +172,9 @@ void CompilationDatabaseTests::testFilterArguments()
QCOMPARE(testData.flags, (QStringList{"-m32", "-target", "i686-w64-mingw32", "-std=gnu++14",
"-fcxx-exceptions", "-fexceptions"}));
QCOMPARE(testData.headerPaths,
- (HeaderPaths{{QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath1 : otherPath1),
- HeaderPathType::User},
- {QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath2 : otherPath2),
- HeaderPathType::User}}));
+ toUserHeaderPaths(QStringList{
+ QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath1 : otherPath1),
+ QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath2 : otherPath2)}));
QCOMPARE(testData.macros, (Macros{{"UNICODE", "1"},
{"RELATIVE_PLUGIN_PATH", "\"../lib/qtcreator/plugins\""},
{"QT_CREATOR", "1"}}));
@@ -243,8 +242,7 @@ void CompilationDatabaseTests::testFilterCommand()
QCOMPARE(testData.flags,
(QStringList{"/Zc:inline", "/Zc:strictStrings", "/Zc:rvalueCast", "/Zi"}));
QCOMPARE(testData.headerPaths,
- (HeaderPaths{{"C:/build-qt_llvm-msvc2017_64bit-Debug/tools\\clang\\lib\\Sema",
- HeaderPathType::User}}));
+ toUserHeaderPaths(QStringList{"C:/build-qt_llvm-msvc2017_64bit-Debug/tools\\clang\\lib\\Sema"}));
QCOMPARE(testData.macros, (Macros{{"UNICODE", "1"}, {"_HAS_EXCEPTIONS", "0"}, {"WIN32", "1"},
{"_WINDOWS", "1"}}));
QCOMPARE(testData.fileKind, CppTools::ProjectFile::Kind::CXXSource);
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp
index 53816d54121..7b0a650568d 100644
--- a/src/plugins/cppeditor/cppquickfix_test.cpp
+++ b/src/plugins/cppeditor/cppquickfix_test.cpp
@@ -294,7 +294,7 @@ void QuickFixOperationTest::run(const QList<QuickFixTestDocument::Ptr> &testDocu
int operationIndex)
{
ProjectExplorer::HeaderPaths headerPaths;
- headerPaths.push_back({headerPath, ProjectExplorer::HeaderPathType::User});
+ headerPaths.push_back(ProjectExplorer::HeaderPath::makeUser(headerPath));
QuickFixOperationTest(testDocuments, factory, headerPaths, operationIndex);
}
@@ -5792,12 +5792,10 @@ void QuickfixTest::testAddIncludeForUndefinedIdentifierNoDoubleQtHeaderInclude()
original = expected = "@QDir dir;\n";
testDocuments << QuickFixTestDocument::create(base + "/fileWantsToUseQDir.cpp", original, expected);
- ProjectExplorer::HeaderPaths headerPaths{{TestIncludePaths::globalQtCoreIncludePath(),
- ProjectExplorer::HeaderPathType::User}};
-
AddIncludeForUndefinedIdentifier factory;
const QStringList expectedOperations = QStringList("Add #include <QDir>");
- QuickFixOfferedOperationsTest(testDocuments, &factory, headerPaths, expectedOperations);
+ QuickFixOfferedOperationsTest(testDocuments, &factory, ProjectExplorer::toUserHeaderPaths(
+ QStringList{TestIncludePaths::globalQtCoreIncludePath()}), expectedOperations);
}
void QuickfixTest::testAddForwardDeclForUndefinedIdentifier_data()
diff --git a/src/plugins/cpptools/compileroptionsbuilder_test.cpp b/src/plugins/cpptools/compileroptionsbuilder_test.cpp
index 2c26940b090..1a0b2193e68 100644
--- a/src/plugins/cpptools/compileroptionsbuilder_test.cpp
+++ b/src/plugins/cpptools/compileroptionsbuilder_test.cpp
@@ -75,10 +75,7 @@ public:
return *projectPart;
}
- static HeaderPath builtIn(const QString &path)
- {
- return HeaderPath{path, HeaderPathType::BuiltIn};
- }
+ static HeaderPath builtIn(const QString &path) { return HeaderPath::makeBuiltIn(path); }
QString toNative(const QString &toNative) const
{
@@ -94,9 +91,9 @@ public:
QStringList flags;
Utils::Id toolchainType = Constants::CLANG_TOOLCHAIN_TYPEID;
QString targetTriple = "x86_64-apple-darwin10";
- HeaderPaths headerPaths = {HeaderPath{"/tmp/builtin_path", HeaderPathType::BuiltIn},
- HeaderPath{"/tmp/system_path", HeaderPathType::System},
- HeaderPath{"/tmp/path", HeaderPathType::User}};
+ HeaderPaths headerPaths{builtIn("/tmp/builtin_path"),
+ HeaderPath::makeSystem("/tmp/system_path"),
+ HeaderPath::makeUser("/tmp/path")};
Utils::LanguageVersion languageVersion = Utils::LanguageVersion::CXX17;
Utils::LanguageExtensions languageExtensions;
Macros toolchainMacros{
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index d52e4fa0fbb..464d803bcf6 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -1264,8 +1264,8 @@ bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cu
// Make completion for all relevant includes
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
- const ProjectExplorer::HeaderPath currentFilePath(m_interface->filePath().toFileInfo().path(),
- ProjectExplorer::HeaderPathType::User);
+ const auto currentFilePath = ProjectExplorer::HeaderPath::makeUser(
+ m_interface->filePath().toFileInfo().path());
if (!headerPaths.contains(currentFilePath))
headerPaths.append(currentFilePath);
diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp
index d7203bd4141..e3da466aad9 100644
--- a/src/plugins/cpptools/cppmodelmanager_test.cpp
+++ b/src/plugins/cpptools/cppmodelmanager_test.cpp
@@ -186,8 +186,8 @@ void ModelManagerTest::testPathsAreClean()
RawProjectPart rpp;
rpp.setQtVersion(Utils::QtVersion::Qt5);
rpp.setMacros({ProjectExplorer::Macro("OH_BEHAVE", "-1")});
- rpp.setHeaderPaths({{testDataDir.includeDir(false), HeaderPathType::User},
- {testDataDir.frameworksDir(false), HeaderPathType::Framework}});
+ rpp.setHeaderPaths({HeaderPath::makeUser(testDataDir.includeDir(false)),
+ HeaderPath::makeFramework(testDataDir.frameworksDir(false))});
const auto part = ProjectPart::create(project->projectFilePath(), rpp);
const auto pi = ProjectInfo::create(ProjectUpdateInfo(project, KitInfo(nullptr), {}, {}),
{part});
@@ -196,8 +196,8 @@ void ModelManagerTest::testPathsAreClean()
ProjectExplorer::HeaderPaths headerPaths = mm->headerPaths();
QCOMPARE(headerPaths.size(), 2);
- QVERIFY(headerPaths.contains({testDataDir.includeDir(), HeaderPathType::User}));
- QVERIFY(headerPaths.contains({testDataDir.frameworksDir(), HeaderPathType::Framework}));
+ QVERIFY(headerPaths.contains(HeaderPath::makeUser(testDataDir.includeDir())));
+ QVERIFY(headerPaths.contains(HeaderPath::makeFramework(testDataDir.frameworksDir())));
}
/// Check: Frameworks headers are resolved.
@@ -216,8 +216,8 @@ void ModelManagerTest::testFrameworkHeaders()
RawProjectPart rpp;
rpp.setQtVersion(Utils::QtVersion::Qt5);
rpp.setMacros({{"OH_BEHAVE", "-1"}});
- rpp.setHeaderPaths({{testDataDir.includeDir(false), HeaderPathType::User},
- {testDataDir.frameworksDir(false), HeaderPathType::Framework}});
+ rpp.setHeaderPaths({HeaderPath::makeUser(testDataDir.includeDir(false)),
+ HeaderPath::makeFramework(testDataDir.frameworksDir(false))});
const QString &source = testDataDir.fileFromSourcesDir(
_("test_modelmanager_framework_headers.cpp"));
const auto part = ProjectPart::create(project->projectFilePath(), rpp, {},
@@ -264,7 +264,7 @@ void ModelManagerTest::testRefreshAlsoIncludesOfProjectFiles()
RawProjectPart rpp;
rpp.setQtVersion(Utils::QtVersion::Qt5);
rpp.setMacros({{"OH_BEHAVE", "-1"}});
- rpp.setHeaderPaths({{testDataDir.includeDir(false), HeaderPathType::User}});
+ rpp.setHeaderPaths({HeaderPath::makeUser(testDataDir.includeDir(false))});
auto part = ProjectPart::create(project->projectFilePath(), rpp, {},
{ProjectFile(testCpp, ProjectFile::CXXSource)});
auto pi = ProjectInfo::create(ProjectUpdateInfo(project, KitInfo(nullptr), {}, {}), {part});
@@ -748,7 +748,7 @@ void ModelManagerTest::testDefinesPerProject()
rpp1.setProjectFileLocation("project1.projectfile");
rpp1.setQtVersion(Utils::QtVersion::None);
rpp1.setMacros({{"SUB1"}});
- rpp1.setHeaderPaths({{testDataDirectory.includeDir(false), HeaderPathType::User}});
+ rpp1.setHeaderPaths({HeaderPath::makeUser(testDataDirectory.includeDir(false))});
const auto part1 = ProjectPart::create(project->projectFilePath(), rpp1, {},
{{main1File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
@@ -756,7 +756,7 @@ void ModelManagerTest::testDefinesPerProject()
rpp2.setProjectFileLocation("project1.projectfile");
rpp2.setQtVersion(Utils::QtVersion::None);
rpp2.setMacros({{"SUB2"}});
- rpp2.setHeaderPaths({{testDataDirectory.includeDir(false), HeaderPathType::User}});
+ rpp2.setHeaderPaths({HeaderPath::makeUser(testDataDirectory.includeDir(false))});
const auto part2 = ProjectPart::create(project->projectFilePath(), rpp2, {},
{{main2File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
@@ -810,7 +810,7 @@ void ModelManagerTest::testPrecompiledHeaders()
rpp1.setProjectFileLocation("project1.projectfile");
rpp1.setQtVersion(Utils::QtVersion::None);
rpp1.setPreCompiledHeaders({pch1File});
- rpp1.setHeaderPaths({{testDataDirectory.includeDir(false), HeaderPathType::User}});
+ rpp1.setHeaderPaths({HeaderPath::makeUser(testDataDirectory.includeDir(false))});
const auto part1 = ProjectPart::create(project->projectFilePath(), rpp1, {},
{{main1File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
@@ -818,7 +818,7 @@ void ModelManagerTest::testPrecompiledHeaders()
rpp2.setProjectFileLocation("project2.projectfile");
rpp2.setQtVersion(Utils::QtVersion::None);
rpp2.setPreCompiledHeaders({pch2File});
- rpp2.setHeaderPaths({{testDataDirectory.includeDir(false), HeaderPathType::User}});
+ rpp2.setHeaderPaths({HeaderPath::makeUser(testDataDirectory.includeDir(false))});
const auto part2 = ProjectPart::create(project->projectFilePath(), rpp2, {},
{{main2File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
@@ -887,13 +887,13 @@ void ModelManagerTest::testDefinesPerEditor()
RawProjectPart rpp1;
rpp1.setQtVersion(Utils::QtVersion::None);
- rpp1.setHeaderPaths({{testDataDirectory.includeDir(false), HeaderPathType::User}});
+ rpp1.setHeaderPaths({HeaderPath::makeUser(testDataDirectory.includeDir(false))});
const auto part1 = ProjectPart::create(project->projectFilePath(), rpp1, {},
{{main1File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
RawProjectPart rpp2;
rpp2.setQtVersion(Utils::QtVersion::None);
- rpp2.setHeaderPaths({{testDataDirectory.includeDir(false), HeaderPathType::User}});
+ rpp2.setHeaderPaths({HeaderPath::makeUser(testDataDirectory.includeDir(false))});
const auto part2 = ProjectPart::create(project->projectFilePath(), rpp2, {},
{{main2File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
diff --git a/src/plugins/cpptools/cppsourceprocessor.cpp b/src/plugins/cpptools/cppsourceprocessor.cpp
index b9585f7acae..0ae4d9a5a10 100644
--- a/src/plugins/cpptools/cppsourceprocessor.cpp
+++ b/src/plugins/cpptools/cppsourceprocessor.cpp
@@ -161,8 +161,8 @@ void CppSourceProcessor::addFrameworkPath(const ProjectExplorer::HeaderPath &fra
// The algorithm below is a bit too eager, but that's because we're not getting
// in the frameworks we're linking against. If we would have that, then we could
// add only those private frameworks.
- const ProjectExplorer::HeaderPath cleanFrameworkPath(cleanPath(frameworkPath.path),
- ProjectExplorer::HeaderPathType::Framework);
+ const auto cleanFrameworkPath = ProjectExplorer::HeaderPath::makeFramework(
+ cleanPath(frameworkPath.path));
if (!m_headerPaths.contains(cleanFrameworkPath))
m_headerPaths.append(cleanFrameworkPath);
@@ -174,8 +174,8 @@ void CppSourceProcessor::addFrameworkPath(const ProjectExplorer::HeaderPath &fra
const QFileInfo privateFrameworks(framework.absoluteFilePath(),
QLatin1String("Frameworks"));
if (privateFrameworks.exists() && privateFrameworks.isDir())
- addFrameworkPath({privateFrameworks.absoluteFilePath(),
- ProjectExplorer::HeaderPathType::Framework});
+ addFrameworkPath(ProjectExplorer::HeaderPath::makeFramework(
+ privateFrameworks.absoluteFilePath()));
}
}
diff --git a/src/plugins/cpptools/cppsourceprocessor_test.cpp b/src/plugins/cpptools/cppsourceprocessor_test.cpp
index a30c3e42808..35503af42af 100644
--- a/src/plugins/cpptools/cppsourceprocessor_test.cpp
+++ b/src/plugins/cpptools/cppsourceprocessor_test.cpp
@@ -64,9 +64,8 @@ public:
{
QScopedPointer<CppSourceProcessor> sourceProcessor(
CppModelManager::createSourceProcessor());
- const ProjectExplorer::HeaderPath hp(TestIncludePaths::directoryOfTestFile(),
- HeaderPathType::User);
- sourceProcessor->setHeaderPaths({hp});
+ sourceProcessor->setHeaderPaths({ProjectExplorer::HeaderPath::makeUser(
+ TestIncludePaths::directoryOfTestFile())});
sourceProcessor->run(filePath);
Document::Ptr document = m_cmm->document(filePath);
@@ -208,9 +207,8 @@ void SourceProcessorTest::testIncludeNext()
CppSourceProcessor::DocumentCallback documentCallback = [](const Document::Ptr &){};
CppSourceProcessor sourceProcessor(Snapshot(), documentCallback);
- ProjectExplorer::HeaderPaths headerPaths = {{customHeaderPath, HeaderPathType::User},
- {systemHeaderPath, HeaderPathType::User}};
- sourceProcessor.setHeaderPaths(headerPaths);
+ sourceProcessor.setHeaderPaths(ProjectExplorer::toUserHeaderPaths(
+ QStringList{customHeaderPath, systemHeaderPath}));
sourceProcessor.run(mainFilePath);
const Snapshot snapshot = sourceProcessor.snapshot();
diff --git a/src/plugins/cpptools/headerpathfilter.cpp b/src/plugins/cpptools/headerpathfilter.cpp
index 73913ed7b25..8ffcc23eb62 100644
--- a/src/plugins/cpptools/headerpathfilter.cpp
+++ b/src/plugins/cpptools/headerpathfilter.cpp
@@ -159,7 +159,7 @@ void HeaderPathFilter::tweakHeaderPaths()
if (!clangVersion.isEmpty()) {
const FilePath clangIncludePath
= clangIncludeDirectory(clangVersion, clangFallbackIncludeDirectory);
- builtInHeaderPaths.insert(split, HeaderPath{clangIncludePath.toString(), HeaderPathType::BuiltIn});
+ builtInHeaderPaths.insert(split, HeaderPath::makeBuiltIn(clangIncludePath));
}
}
@@ -168,9 +168,7 @@ void HeaderPathFilter::addPreIncludesPath()
if (!projectDirectory.isEmpty()) {
const Utils::FilePath rootProjectDirectory = Utils::FilePath::fromString(projectDirectory)
.pathAppended(".pre_includes");
-
- systemHeaderPaths.push_back(
- {rootProjectDirectory.toString(), ProjectExplorer::HeaderPathType::System});
+ systemHeaderPaths.push_back(ProjectExplorer::HeaderPath::makeSystem(rootProjectDirectory));
}
}
diff --git a/src/plugins/cpptools/includeutils.cpp b/src/plugins/cpptools/includeutils.cpp
index 114093ce0ff..01ad33245f9 100644
--- a/src/plugins/cpptools/includeutils.cpp
+++ b/src/plugins/cpptools/includeutils.cpp
@@ -534,8 +534,8 @@ static QList<Include> includesForSource(const QString &filePath)
CppModelManager *cmm = CppModelManager::instance();
cmm->GC();
QScopedPointer<CppSourceProcessor> sourceProcessor(CppModelManager::createSourceProcessor());
- sourceProcessor->setHeaderPaths({{TestIncludePaths::globalIncludePath(),
- ProjectExplorer::HeaderPathType::User}});
+ sourceProcessor->setHeaderPaths({ProjectExplorer::HeaderPath::makeUser(
+ TestIncludePaths::globalIncludePath())});
sourceProcessor->run(filePath);
Document::Ptr document = cmm->document(filePath);
diff --git a/src/plugins/cpptools/projectinfo_test.cpp b/src/plugins/cpptools/projectinfo_test.cpp
index 48abfc3c58b..d11b97205d9 100644
--- a/src/plugins/cpptools/projectinfo_test.cpp
+++ b/src/plugins/cpptools/projectinfo_test.cpp
@@ -514,36 +514,24 @@ public:
return *projectPart;
}
- static HeaderPath builtIn(const QString &path)
- {
- return HeaderPath{path, HeaderPathType::BuiltIn};
- }
- static HeaderPath system(const QString &path)
- {
- return HeaderPath{path, HeaderPathType::System};
- }
- static HeaderPath framework(const QString &path)
- {
- return HeaderPath{path, HeaderPathType::Framework};
- }
- static HeaderPath user(const QString &path)
- {
- return HeaderPath{path, HeaderPathType::User};
- }
+ static HeaderPath user(const QString &path) { return HeaderPath::makeUser(path); }
+ static HeaderPath builtIn(const QString &path) { return HeaderPath::makeBuiltIn(path); }
+ static HeaderPath system(const QString &path) { return HeaderPath::makeSystem(path); }
+ static HeaderPath framework(const QString &path) { return HeaderPath::makeFramework(path); }
QString targetTriple;
Utils::Id toolchainType;
Utils::FilePath toolchainInstallDir;
HeaderPaths headerPaths = {
- HeaderPath{"", HeaderPathType::BuiltIn},
- HeaderPath{"/builtin_path", HeaderPathType::BuiltIn},
- HeaderPath{"/system_path", HeaderPathType::System},
- HeaderPath{"/framework_path", HeaderPathType::Framework},
- HeaderPath{"/outside_project_user_path", HeaderPathType::User},
- HeaderPath{"/build/user_path", HeaderPathType::User},
- HeaderPath{"/buildb/user_path", HeaderPathType::User},
- HeaderPath{"/projectb/user_path", HeaderPathType::User},
- HeaderPath{"/project/user_path", HeaderPathType::User}};
+ builtIn(""),
+ builtIn("/builtin_path"),
+ system("/system_path"),
+ framework("/framework_path"),
+ user("/outside_project_user_path"),
+ user("/build/user_path"),
+ user("/buildb/user_path"),
+ user("/projectb/user_path"),
+ user("/project/user_path")};
Utils::optional<HeaderPathFilter> filter;
diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp
index 8887eff5573..4ecd8d35bb6 100644
--- a/src/plugins/genericprojectmanager/genericproject.cpp
+++ b/src/plugins/genericprojectmanager/genericproject.cpp
@@ -438,13 +438,8 @@ void GenericBuildSystem::parse(RefreshOptions options)
else
normalPaths << rawPath;
}
- const auto stringsToHeaderPaths = [this](const QStringList &paths, HeaderPathType type) {
- return transform<HeaderPaths>(processEntries(paths),
- [type](const QString &p) { return HeaderPath(p, type);
- });
- };
- m_projectIncludePaths = stringsToHeaderPaths(normalPaths, HeaderPathType::User);
- m_projectIncludePaths << stringsToHeaderPaths(frameworkPaths, HeaderPathType::Framework);
+ m_projectIncludePaths = toUserHeaderPaths(normalPaths);
+ m_projectIncludePaths << toFrameworkHeaderPaths(frameworkPaths);
m_cxxflags = readFlags(m_cxxflagsFileName);
m_cflags = readFlags(m_cflagsFileName);
}
diff --git a/src/plugins/projectexplorer/customtoolchain.cpp b/src/plugins/projectexplorer/customtoolchain.cpp
index b5f05ba2a2a..e6223c3cf15 100644
--- a/src/plugins/projectexplorer/customtoolchain.cpp
+++ b/src/plugins/projectexplorer/customtoolchain.cpp
@@ -142,9 +142,8 @@ ToolChain::BuiltInHeaderPathsRunner CustomToolChain::createBuiltInHeaderPathsRun
return [builtInHeaderPaths](const QStringList &cxxFlags, const QString &, const QString &) {
HeaderPaths flagHeaderPaths;
for (const QString &cxxFlag : cxxFlags) {
- if (cxxFlag.startsWith(QLatin1String("-I"))) {
- flagHeaderPaths.push_back({cxxFlag.mid(2).trimmed(), HeaderPathType::BuiltIn});
- }
+ if (cxxFlag.startsWith(QLatin1String("-I")))
+ flagHeaderPaths.push_back(HeaderPath::makeBuiltIn(cxxFlag.mid(2).trimmed()));
}
return builtInHeaderPaths + flagHeaderPaths;
@@ -189,7 +188,7 @@ QStringList CustomToolChain::headerPathsList() const
void CustomToolChain::setHeaderPaths(const QStringList &list)
{
HeaderPaths tmp = Utils::transform<QVector>(list, [](const QString &headerPath) {
- return HeaderPath(headerPath.trimmed(), HeaderPathType::BuiltIn);
+ return HeaderPath::makeBuiltIn(headerPath.trimmed());
});
if (m_builtInHeaderPaths == tmp)
diff --git a/src/plugins/projectexplorer/headerpath.h b/src/plugins/projectexplorer/headerpath.h
index 09337684b34..37492fe9f1e 100644
--- a/src/plugins/projectexplorer/headerpath.h
+++ b/src/plugins/projectexplorer/headerpath.h
@@ -25,6 +25,9 @@
#pragma once
+#include <utils/algorithm.h>
+#include <utils/fileutils.h>
+
#include <QString>
#include <QVector>
@@ -41,9 +44,10 @@ class HeaderPath
{
public:
HeaderPath() = default;
- HeaderPath(const QString &path, HeaderPathType type)
- : path(path), type(type)
- { }
+ HeaderPath(const QString &path, HeaderPathType type) : path(path), type(type) { }
+ HeaderPath(const char *path, HeaderPathType type) : HeaderPath(QLatin1String(path), type) {}
+ HeaderPath(const Utils::FilePath &path, HeaderPathType type)
+ : HeaderPath(path.toString(), type) { }
bool operator==(const HeaderPath &other) const
{
@@ -55,6 +59,23 @@ public:
return !(*this == other);
}
+ template<typename F> static HeaderPath makeUser(const F &fp)
+ {
+ return {fp, HeaderPathType::User};
+ }
+ template<typename F> static HeaderPath makeBuiltIn(const F &fp)
+ {
+ return {fp, HeaderPathType::BuiltIn};
+ }
+ template<typename F> static HeaderPath makeSystem(const F &fp)
+ {
+ return {fp, HeaderPathType::System};
+ }
+ template<typename F> static HeaderPath makeFramework(const F &fp)
+ {
+ return {fp, HeaderPathType::Framework};
+ }
+
QString path;
HeaderPathType type = HeaderPathType::User;
};
@@ -65,4 +86,23 @@ inline auto qHash(const HeaderPath &key, uint seed = 0)
}
using HeaderPaths = QVector<HeaderPath>;
+template<typename C> HeaderPaths toHeaderPaths(const C &list, HeaderPathType type)
+{
+ return Utils::transform<HeaderPaths>(list, [type](const auto &fp) {
+ return HeaderPath(fp, type);
+ });
+}
+template<typename C> HeaderPaths toUserHeaderPaths(const C &list)
+{
+ return toHeaderPaths(list, HeaderPathType::User);
+}
+template<typename C> HeaderPaths toBuiltInHeaderPaths(const C &list)
+{
+ return toHeaderPaths(list, HeaderPathType::BuiltIn);
+}
+template<typename C> HeaderPaths toFrameworkHeaderPaths(const C &list)
+{
+ return toHeaderPaths(list, HeaderPathType::Framework);
+}
+
} // namespace ProjectExplorer
diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp
index 3467df0af1e..691bb82eed4 100644
--- a/src/plugins/projectexplorer/msvctoolchain.cpp
+++ b/src/plugins/projectexplorer/msvctoolchain.cpp
@@ -1129,11 +1129,8 @@ ToolChain::BuiltInHeaderPathsRunner MsvcToolChain::createBuiltInHeaderPathsRunne
const auto it = m_headerPathsPerEnv.constFind(envList);
if (it != m_headerPathsPerEnv.cend())
return *it;
- const auto mapper = [](const FilePath &p) { // TODO: Define functions for this.
- return HeaderPath(p.toString(), HeaderPathType::BuiltIn);
- };
return *m_headerPathsPerEnv.insert(envList,
- transform<QVector>(fullEnv.pathListValue("INCLUDE"), mapper));
+ toBuiltInHeaderPaths(fullEnv.pathListValue("INCLUDE")));
};
}
diff --git a/src/plugins/projectexplorer/rawprojectpart.cpp b/src/plugins/projectexplorer/rawprojectpart.cpp
index 74e9c1b8e12..45aa810aa4f 100644
--- a/src/plugins/projectexplorer/rawprojectpart.cpp
+++ b/src/plugins/projectexplorer/rawprojectpart.cpp
@@ -76,10 +76,8 @@ HeaderPath RawProjectPart::frameworkDetectionHeuristic(const HeaderPath &header)
{
QString path = trimTrailingSlashes(header.path);
- if (path.endsWith(".framework")) {
- path = path.left(path.lastIndexOf(QLatin1Char('/')));
- return {path, HeaderPathType::Framework};
- }
+ if (path.endsWith(".framework"))
+ return HeaderPath::makeFramework(path.left(path.lastIndexOf('/')));
return header;
}
@@ -123,8 +121,7 @@ void RawProjectPart::setHeaderPaths(const HeaderPaths &headerPaths)
void RawProjectPart::setIncludePaths(const QStringList &includePaths)
{
this->headerPaths = Utils::transform<QVector>(includePaths, [](const QString &path) {
- HeaderPath hp(path, HeaderPathType::User);
- return RawProjectPart::frameworkDetectionHeuristic(hp);
+ return RawProjectPart::frameworkDetectionHeuristic(HeaderPath::makeUser(path));
});
}
diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp
index 123e2b2ca0c..8c92b19445a 100644
--- a/src/plugins/qbsprojectmanager/qbsproject.cpp
+++ b/src/plugins/qbsprojectmanager/qbsproject.cpp
@@ -914,19 +914,17 @@ static RawProjectParts generateProjectParts(
QStringList list = arrayToStringList(props.value("cpp.includePaths"));
list.removeDuplicates();
for (const QString &p : qAsConst(list))
- grpHeaderPaths += {FilePath::fromUserInput(p).toString(), HeaderPathType::User};
+ grpHeaderPaths += HeaderPath::makeUser(FilePath::fromUserInput(p));
list = arrayToStringList(props.value("cpp.distributionIncludePaths"))
+ arrayToStringList(props.value("cpp.systemIncludePaths"));
list.removeDuplicates();
for (const QString &p : qAsConst(list))
- grpHeaderPaths += {FilePath::fromUserInput(p).toString(), HeaderPathType::System};
+ grpHeaderPaths += HeaderPath::makeSystem(FilePath::fromUserInput(p));
list = arrayToStringList(props.value("cpp.frameworkPaths"));
list.append(arrayToStringList(props.value("cpp.systemFrameworkPaths")));
list.removeDuplicates();
- for (const QString &p : qAsConst(list)) {
- grpHeaderPaths += {FilePath::fromUserInput(p).toString(),
- HeaderPathType::Framework};
- }
+ for (const QString &p : qAsConst(list))
+ grpHeaderPaths += HeaderPath::makeFramework(FilePath::fromUserInput(p));
rpp.setHeaderPaths(grpHeaderPaths);
rpp.setDisplayName(groupName);
const QJsonObject location = grp.value("location").toObject();
diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
index b339cc07cd1..eba8dc41337 100644
--- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
@@ -373,14 +373,13 @@ void QmakeBuildSystem::updateCppCodeModel()
// Header paths
ProjectExplorer::HeaderPaths headerPaths;
foreach (const QString &inc, pro->variableValue(Variable::IncludePath)) {
- const ProjectExplorer::HeaderPath headerPath{inc, HeaderPathType::User};
+ const auto headerPath = HeaderPath::makeUser(inc);
if (!headerPaths.contains(headerPath))
headerPaths += headerPath;
}
if (kitInfo.qtVersion && !kitInfo.qtVersion->frameworkPath().isEmpty())
- headerPaths += {kitInfo.qtVersion->frameworkPath().toString(),
- HeaderPathType::Framework};
+ headerPaths += HeaderPath::makeFramework(kitInfo.qtVersion->frameworkPath());
rpp.setHeaderPaths(headerPaths);
// Files and generators