forked from qt-creator/qt-creator
Add convenience functions for creating ProjectExplorer::HeaderPaths
Change-Id: I7b1f63caca6b70ba4ec1b1870b83cbf20aa6564a Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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()
|
||||
|
@@ -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{
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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}});
|
||||
|
||||
|
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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")));
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user