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.
|
// Ignore the QtC binary directory path.
|
||||||
if (headerPath != QCoreApplication::applicationDirPath())
|
if (headerPath != QCoreApplication::applicationDirPath())
|
||||||
headerPaths.append({headerPath, HeaderPathType::BuiltIn});
|
headerPaths.append(HeaderPath::makeBuiltIn(headerPath));
|
||||||
|
|
||||||
pos = endQuoteIndex + 1;
|
pos = endQuoteIndex + 1;
|
||||||
}
|
}
|
||||||
|
@@ -342,11 +342,11 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler)
|
|||||||
if (isMcsArchitecture(arch) || isC166Architecture(arch)) {
|
if (isMcsArchitecture(arch) || isC166Architecture(arch)) {
|
||||||
QDir includeDir(toolkitDir);
|
QDir includeDir(toolkitDir);
|
||||||
if (includeDir.cd("inc"))
|
if (includeDir.cd("inc"))
|
||||||
headerPaths.push_back({includeDir.canonicalPath(), HeaderPathType::BuiltIn});
|
headerPaths.push_back(HeaderPath::makeBuiltIn(includeDir.canonicalPath()));
|
||||||
} else if (isArmArchitecture(arch)) {
|
} else if (isArmArchitecture(arch)) {
|
||||||
QDir includeDir(toolkitDir);
|
QDir includeDir(toolkitDir);
|
||||||
if (includeDir.cd("include"))
|
if (includeDir.cd("include"))
|
||||||
headerPaths.push_back({includeDir.canonicalPath(), HeaderPathType::BuiltIn});
|
headerPaths.push_back(HeaderPath::makeBuiltIn(includeDir.canonicalPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return headerPaths;
|
return headerPaths;
|
||||||
|
@@ -135,7 +135,7 @@ static HeaderPaths dumpHeaderPaths(const FilePath &compiler, const Environment &
|
|||||||
} else {
|
} else {
|
||||||
const QString headerPath = QFileInfo(line.trimmed())
|
const QString headerPath = QFileInfo(line.trimmed())
|
||||||
.canonicalFilePath();
|
.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
|
// Make completion for all relevant includes
|
||||||
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
|
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
|
||||||
const ProjectExplorer::HeaderPath currentFilePath(m_interface->filePath().toFileInfo().path(),
|
const auto currentFilePath = ProjectExplorer::HeaderPath::makeUser(
|
||||||
ProjectExplorer::HeaderPathType::User);
|
m_interface->filePath().toFileInfo().path());
|
||||||
if (!headerPaths.contains(currentFilePath))
|
if (!headerPaths.contains(currentFilePath))
|
||||||
headerPaths.append(currentFilePath);
|
headerPaths.append(currentFilePath);
|
||||||
|
|
||||||
|
@@ -95,14 +95,6 @@ public:
|
|||||||
TextEditor::ProposalModelPtr proposalModel;
|
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,
|
TextEditor::ProposalModelPtr completionResults(TextEditor::BaseTextEditor *textEditor,
|
||||||
const QStringList &includePaths,
|
const QStringList &includePaths,
|
||||||
int timeOutInMs)
|
int timeOutInMs)
|
||||||
@@ -116,7 +108,7 @@ TextEditor::ProposalModelPtr completionResults(TextEditor::BaseTextEditor *textE
|
|||||||
QTC_ASSERT(assistInterface, return TextEditor::ProposalModelPtr());
|
QTC_ASSERT(assistInterface, return TextEditor::ProposalModelPtr());
|
||||||
if (!includePaths.isEmpty()) {
|
if (!includePaths.isEmpty()) {
|
||||||
auto clangAssistInterface = static_cast<ClangCompletionAssistInterface *>(assistInterface);
|
auto clangAssistInterface = static_cast<ClangCompletionAssistInterface *>(assistInterface);
|
||||||
clangAssistInterface->setHeaderPaths(toHeaderPaths(includePaths));
|
clangAssistInterface->setHeaderPaths(ProjectExplorer::toUserHeaderPaths(includePaths));
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletionAssistProvider *assistProvider
|
CompletionAssistProvider *assistProvider
|
||||||
|
@@ -172,10 +172,9 @@ void CompilationDatabaseTests::testFilterArguments()
|
|||||||
QCOMPARE(testData.flags, (QStringList{"-m32", "-target", "i686-w64-mingw32", "-std=gnu++14",
|
QCOMPARE(testData.flags, (QStringList{"-m32", "-target", "i686-w64-mingw32", "-std=gnu++14",
|
||||||
"-fcxx-exceptions", "-fexceptions"}));
|
"-fcxx-exceptions", "-fexceptions"}));
|
||||||
QCOMPARE(testData.headerPaths,
|
QCOMPARE(testData.headerPaths,
|
||||||
(HeaderPaths{{QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath1 : otherPath1),
|
toUserHeaderPaths(QStringList{
|
||||||
HeaderPathType::User},
|
QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath1 : otherPath1),
|
||||||
{QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath2 : otherPath2),
|
QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath2 : otherPath2)}));
|
||||||
HeaderPathType::User}}));
|
|
||||||
QCOMPARE(testData.macros, (Macros{{"UNICODE", "1"},
|
QCOMPARE(testData.macros, (Macros{{"UNICODE", "1"},
|
||||||
{"RELATIVE_PLUGIN_PATH", "\"../lib/qtcreator/plugins\""},
|
{"RELATIVE_PLUGIN_PATH", "\"../lib/qtcreator/plugins\""},
|
||||||
{"QT_CREATOR", "1"}}));
|
{"QT_CREATOR", "1"}}));
|
||||||
@@ -243,8 +242,7 @@ void CompilationDatabaseTests::testFilterCommand()
|
|||||||
QCOMPARE(testData.flags,
|
QCOMPARE(testData.flags,
|
||||||
(QStringList{"/Zc:inline", "/Zc:strictStrings", "/Zc:rvalueCast", "/Zi"}));
|
(QStringList{"/Zc:inline", "/Zc:strictStrings", "/Zc:rvalueCast", "/Zi"}));
|
||||||
QCOMPARE(testData.headerPaths,
|
QCOMPARE(testData.headerPaths,
|
||||||
(HeaderPaths{{"C:/build-qt_llvm-msvc2017_64bit-Debug/tools\\clang\\lib\\Sema",
|
toUserHeaderPaths(QStringList{"C:/build-qt_llvm-msvc2017_64bit-Debug/tools\\clang\\lib\\Sema"}));
|
||||||
HeaderPathType::User}}));
|
|
||||||
QCOMPARE(testData.macros, (Macros{{"UNICODE", "1"}, {"_HAS_EXCEPTIONS", "0"}, {"WIN32", "1"},
|
QCOMPARE(testData.macros, (Macros{{"UNICODE", "1"}, {"_HAS_EXCEPTIONS", "0"}, {"WIN32", "1"},
|
||||||
{"_WINDOWS", "1"}}));
|
{"_WINDOWS", "1"}}));
|
||||||
QCOMPARE(testData.fileKind, CppTools::ProjectFile::Kind::CXXSource);
|
QCOMPARE(testData.fileKind, CppTools::ProjectFile::Kind::CXXSource);
|
||||||
|
@@ -294,7 +294,7 @@ void QuickFixOperationTest::run(const QList<QuickFixTestDocument::Ptr> &testDocu
|
|||||||
int operationIndex)
|
int operationIndex)
|
||||||
{
|
{
|
||||||
ProjectExplorer::HeaderPaths headerPaths;
|
ProjectExplorer::HeaderPaths headerPaths;
|
||||||
headerPaths.push_back({headerPath, ProjectExplorer::HeaderPathType::User});
|
headerPaths.push_back(ProjectExplorer::HeaderPath::makeUser(headerPath));
|
||||||
QuickFixOperationTest(testDocuments, factory, headerPaths, operationIndex);
|
QuickFixOperationTest(testDocuments, factory, headerPaths, operationIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5792,12 +5792,10 @@ void QuickfixTest::testAddIncludeForUndefinedIdentifierNoDoubleQtHeaderInclude()
|
|||||||
original = expected = "@QDir dir;\n";
|
original = expected = "@QDir dir;\n";
|
||||||
testDocuments << QuickFixTestDocument::create(base + "/fileWantsToUseQDir.cpp", original, expected);
|
testDocuments << QuickFixTestDocument::create(base + "/fileWantsToUseQDir.cpp", original, expected);
|
||||||
|
|
||||||
ProjectExplorer::HeaderPaths headerPaths{{TestIncludePaths::globalQtCoreIncludePath(),
|
|
||||||
ProjectExplorer::HeaderPathType::User}};
|
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifier factory;
|
AddIncludeForUndefinedIdentifier factory;
|
||||||
const QStringList expectedOperations = QStringList("Add #include <QDir>");
|
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()
|
void QuickfixTest::testAddForwardDeclForUndefinedIdentifier_data()
|
||||||
|
@@ -75,10 +75,7 @@ public:
|
|||||||
return *projectPart;
|
return *projectPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HeaderPath builtIn(const QString &path)
|
static HeaderPath builtIn(const QString &path) { return HeaderPath::makeBuiltIn(path); }
|
||||||
{
|
|
||||||
return HeaderPath{path, HeaderPathType::BuiltIn};
|
|
||||||
}
|
|
||||||
|
|
||||||
QString toNative(const QString &toNative) const
|
QString toNative(const QString &toNative) const
|
||||||
{
|
{
|
||||||
@@ -94,9 +91,9 @@ public:
|
|||||||
QStringList flags;
|
QStringList flags;
|
||||||
Utils::Id toolchainType = Constants::CLANG_TOOLCHAIN_TYPEID;
|
Utils::Id toolchainType = Constants::CLANG_TOOLCHAIN_TYPEID;
|
||||||
QString targetTriple = "x86_64-apple-darwin10";
|
QString targetTriple = "x86_64-apple-darwin10";
|
||||||
HeaderPaths headerPaths = {HeaderPath{"/tmp/builtin_path", HeaderPathType::BuiltIn},
|
HeaderPaths headerPaths{builtIn("/tmp/builtin_path"),
|
||||||
HeaderPath{"/tmp/system_path", HeaderPathType::System},
|
HeaderPath::makeSystem("/tmp/system_path"),
|
||||||
HeaderPath{"/tmp/path", HeaderPathType::User}};
|
HeaderPath::makeUser("/tmp/path")};
|
||||||
Utils::LanguageVersion languageVersion = Utils::LanguageVersion::CXX17;
|
Utils::LanguageVersion languageVersion = Utils::LanguageVersion::CXX17;
|
||||||
Utils::LanguageExtensions languageExtensions;
|
Utils::LanguageExtensions languageExtensions;
|
||||||
Macros toolchainMacros{
|
Macros toolchainMacros{
|
||||||
|
@@ -1264,8 +1264,8 @@ bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cu
|
|||||||
|
|
||||||
// Make completion for all relevant includes
|
// Make completion for all relevant includes
|
||||||
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
|
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
|
||||||
const ProjectExplorer::HeaderPath currentFilePath(m_interface->filePath().toFileInfo().path(),
|
const auto currentFilePath = ProjectExplorer::HeaderPath::makeUser(
|
||||||
ProjectExplorer::HeaderPathType::User);
|
m_interface->filePath().toFileInfo().path());
|
||||||
if (!headerPaths.contains(currentFilePath))
|
if (!headerPaths.contains(currentFilePath))
|
||||||
headerPaths.append(currentFilePath);
|
headerPaths.append(currentFilePath);
|
||||||
|
|
||||||
|
@@ -186,8 +186,8 @@ void ModelManagerTest::testPathsAreClean()
|
|||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
rpp.setQtVersion(Utils::QtVersion::Qt5);
|
rpp.setQtVersion(Utils::QtVersion::Qt5);
|
||||||
rpp.setMacros({ProjectExplorer::Macro("OH_BEHAVE", "-1")});
|
rpp.setMacros({ProjectExplorer::Macro("OH_BEHAVE", "-1")});
|
||||||
rpp.setHeaderPaths({{testDataDir.includeDir(false), HeaderPathType::User},
|
rpp.setHeaderPaths({HeaderPath::makeUser(testDataDir.includeDir(false)),
|
||||||
{testDataDir.frameworksDir(false), HeaderPathType::Framework}});
|
HeaderPath::makeFramework(testDataDir.frameworksDir(false))});
|
||||||
const auto part = ProjectPart::create(project->projectFilePath(), rpp);
|
const auto part = ProjectPart::create(project->projectFilePath(), rpp);
|
||||||
const auto pi = ProjectInfo::create(ProjectUpdateInfo(project, KitInfo(nullptr), {}, {}),
|
const auto pi = ProjectInfo::create(ProjectUpdateInfo(project, KitInfo(nullptr), {}, {}),
|
||||||
{part});
|
{part});
|
||||||
@@ -196,8 +196,8 @@ void ModelManagerTest::testPathsAreClean()
|
|||||||
|
|
||||||
ProjectExplorer::HeaderPaths headerPaths = mm->headerPaths();
|
ProjectExplorer::HeaderPaths headerPaths = mm->headerPaths();
|
||||||
QCOMPARE(headerPaths.size(), 2);
|
QCOMPARE(headerPaths.size(), 2);
|
||||||
QVERIFY(headerPaths.contains({testDataDir.includeDir(), HeaderPathType::User}));
|
QVERIFY(headerPaths.contains(HeaderPath::makeUser(testDataDir.includeDir())));
|
||||||
QVERIFY(headerPaths.contains({testDataDir.frameworksDir(), HeaderPathType::Framework}));
|
QVERIFY(headerPaths.contains(HeaderPath::makeFramework(testDataDir.frameworksDir())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Frameworks headers are resolved.
|
/// Check: Frameworks headers are resolved.
|
||||||
@@ -216,8 +216,8 @@ void ModelManagerTest::testFrameworkHeaders()
|
|||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
rpp.setQtVersion(Utils::QtVersion::Qt5);
|
rpp.setQtVersion(Utils::QtVersion::Qt5);
|
||||||
rpp.setMacros({{"OH_BEHAVE", "-1"}});
|
rpp.setMacros({{"OH_BEHAVE", "-1"}});
|
||||||
rpp.setHeaderPaths({{testDataDir.includeDir(false), HeaderPathType::User},
|
rpp.setHeaderPaths({HeaderPath::makeUser(testDataDir.includeDir(false)),
|
||||||
{testDataDir.frameworksDir(false), HeaderPathType::Framework}});
|
HeaderPath::makeFramework(testDataDir.frameworksDir(false))});
|
||||||
const QString &source = testDataDir.fileFromSourcesDir(
|
const QString &source = testDataDir.fileFromSourcesDir(
|
||||||
_("test_modelmanager_framework_headers.cpp"));
|
_("test_modelmanager_framework_headers.cpp"));
|
||||||
const auto part = ProjectPart::create(project->projectFilePath(), rpp, {},
|
const auto part = ProjectPart::create(project->projectFilePath(), rpp, {},
|
||||||
@@ -264,7 +264,7 @@ void ModelManagerTest::testRefreshAlsoIncludesOfProjectFiles()
|
|||||||
RawProjectPart rpp;
|
RawProjectPart rpp;
|
||||||
rpp.setQtVersion(Utils::QtVersion::Qt5);
|
rpp.setQtVersion(Utils::QtVersion::Qt5);
|
||||||
rpp.setMacros({{"OH_BEHAVE", "-1"}});
|
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, {},
|
auto part = ProjectPart::create(project->projectFilePath(), rpp, {},
|
||||||
{ProjectFile(testCpp, ProjectFile::CXXSource)});
|
{ProjectFile(testCpp, ProjectFile::CXXSource)});
|
||||||
auto pi = ProjectInfo::create(ProjectUpdateInfo(project, KitInfo(nullptr), {}, {}), {part});
|
auto pi = ProjectInfo::create(ProjectUpdateInfo(project, KitInfo(nullptr), {}, {}), {part});
|
||||||
@@ -748,7 +748,7 @@ void ModelManagerTest::testDefinesPerProject()
|
|||||||
rpp1.setProjectFileLocation("project1.projectfile");
|
rpp1.setProjectFileLocation("project1.projectfile");
|
||||||
rpp1.setQtVersion(Utils::QtVersion::None);
|
rpp1.setQtVersion(Utils::QtVersion::None);
|
||||||
rpp1.setMacros({{"SUB1"}});
|
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, {},
|
const auto part1 = ProjectPart::create(project->projectFilePath(), rpp1, {},
|
||||||
{{main1File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
{{main1File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
||||||
|
|
||||||
@@ -756,7 +756,7 @@ void ModelManagerTest::testDefinesPerProject()
|
|||||||
rpp2.setProjectFileLocation("project1.projectfile");
|
rpp2.setProjectFileLocation("project1.projectfile");
|
||||||
rpp2.setQtVersion(Utils::QtVersion::None);
|
rpp2.setQtVersion(Utils::QtVersion::None);
|
||||||
rpp2.setMacros({{"SUB2"}});
|
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, {},
|
const auto part2 = ProjectPart::create(project->projectFilePath(), rpp2, {},
|
||||||
{{main2File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
{{main2File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
||||||
|
|
||||||
@@ -810,7 +810,7 @@ void ModelManagerTest::testPrecompiledHeaders()
|
|||||||
rpp1.setProjectFileLocation("project1.projectfile");
|
rpp1.setProjectFileLocation("project1.projectfile");
|
||||||
rpp1.setQtVersion(Utils::QtVersion::None);
|
rpp1.setQtVersion(Utils::QtVersion::None);
|
||||||
rpp1.setPreCompiledHeaders({pch1File});
|
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, {},
|
const auto part1 = ProjectPart::create(project->projectFilePath(), rpp1, {},
|
||||||
{{main1File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
{{main1File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
||||||
|
|
||||||
@@ -818,7 +818,7 @@ void ModelManagerTest::testPrecompiledHeaders()
|
|||||||
rpp2.setProjectFileLocation("project2.projectfile");
|
rpp2.setProjectFileLocation("project2.projectfile");
|
||||||
rpp2.setQtVersion(Utils::QtVersion::None);
|
rpp2.setQtVersion(Utils::QtVersion::None);
|
||||||
rpp2.setPreCompiledHeaders({pch2File});
|
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, {},
|
const auto part2 = ProjectPart::create(project->projectFilePath(), rpp2, {},
|
||||||
{{main2File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
{{main2File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
||||||
|
|
||||||
@@ -887,13 +887,13 @@ void ModelManagerTest::testDefinesPerEditor()
|
|||||||
|
|
||||||
RawProjectPart rpp1;
|
RawProjectPart rpp1;
|
||||||
rpp1.setQtVersion(Utils::QtVersion::None);
|
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, {},
|
const auto part1 = ProjectPart::create(project->projectFilePath(), rpp1, {},
|
||||||
{{main1File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
{{main1File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
||||||
|
|
||||||
RawProjectPart rpp2;
|
RawProjectPart rpp2;
|
||||||
rpp2.setQtVersion(Utils::QtVersion::None);
|
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, {},
|
const auto part2 = ProjectPart::create(project->projectFilePath(), rpp2, {},
|
||||||
{{main2File, ProjectFile::CXXSource}, {header, ProjectFile::CXXHeader}});
|
{{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
|
// 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
|
// in the frameworks we're linking against. If we would have that, then we could
|
||||||
// add only those private frameworks.
|
// add only those private frameworks.
|
||||||
const ProjectExplorer::HeaderPath cleanFrameworkPath(cleanPath(frameworkPath.path),
|
const auto cleanFrameworkPath = ProjectExplorer::HeaderPath::makeFramework(
|
||||||
ProjectExplorer::HeaderPathType::Framework);
|
cleanPath(frameworkPath.path));
|
||||||
if (!m_headerPaths.contains(cleanFrameworkPath))
|
if (!m_headerPaths.contains(cleanFrameworkPath))
|
||||||
m_headerPaths.append(cleanFrameworkPath);
|
m_headerPaths.append(cleanFrameworkPath);
|
||||||
|
|
||||||
@@ -174,8 +174,8 @@ void CppSourceProcessor::addFrameworkPath(const ProjectExplorer::HeaderPath &fra
|
|||||||
const QFileInfo privateFrameworks(framework.absoluteFilePath(),
|
const QFileInfo privateFrameworks(framework.absoluteFilePath(),
|
||||||
QLatin1String("Frameworks"));
|
QLatin1String("Frameworks"));
|
||||||
if (privateFrameworks.exists() && privateFrameworks.isDir())
|
if (privateFrameworks.exists() && privateFrameworks.isDir())
|
||||||
addFrameworkPath({privateFrameworks.absoluteFilePath(),
|
addFrameworkPath(ProjectExplorer::HeaderPath::makeFramework(
|
||||||
ProjectExplorer::HeaderPathType::Framework});
|
privateFrameworks.absoluteFilePath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,9 +64,8 @@ public:
|
|||||||
{
|
{
|
||||||
QScopedPointer<CppSourceProcessor> sourceProcessor(
|
QScopedPointer<CppSourceProcessor> sourceProcessor(
|
||||||
CppModelManager::createSourceProcessor());
|
CppModelManager::createSourceProcessor());
|
||||||
const ProjectExplorer::HeaderPath hp(TestIncludePaths::directoryOfTestFile(),
|
sourceProcessor->setHeaderPaths({ProjectExplorer::HeaderPath::makeUser(
|
||||||
HeaderPathType::User);
|
TestIncludePaths::directoryOfTestFile())});
|
||||||
sourceProcessor->setHeaderPaths({hp});
|
|
||||||
sourceProcessor->run(filePath);
|
sourceProcessor->run(filePath);
|
||||||
|
|
||||||
Document::Ptr document = m_cmm->document(filePath);
|
Document::Ptr document = m_cmm->document(filePath);
|
||||||
@@ -208,9 +207,8 @@ void SourceProcessorTest::testIncludeNext()
|
|||||||
|
|
||||||
CppSourceProcessor::DocumentCallback documentCallback = [](const Document::Ptr &){};
|
CppSourceProcessor::DocumentCallback documentCallback = [](const Document::Ptr &){};
|
||||||
CppSourceProcessor sourceProcessor(Snapshot(), documentCallback);
|
CppSourceProcessor sourceProcessor(Snapshot(), documentCallback);
|
||||||
ProjectExplorer::HeaderPaths headerPaths = {{customHeaderPath, HeaderPathType::User},
|
sourceProcessor.setHeaderPaths(ProjectExplorer::toUserHeaderPaths(
|
||||||
{systemHeaderPath, HeaderPathType::User}};
|
QStringList{customHeaderPath, systemHeaderPath}));
|
||||||
sourceProcessor.setHeaderPaths(headerPaths);
|
|
||||||
|
|
||||||
sourceProcessor.run(mainFilePath);
|
sourceProcessor.run(mainFilePath);
|
||||||
const Snapshot snapshot = sourceProcessor.snapshot();
|
const Snapshot snapshot = sourceProcessor.snapshot();
|
||||||
|
@@ -159,7 +159,7 @@ void HeaderPathFilter::tweakHeaderPaths()
|
|||||||
if (!clangVersion.isEmpty()) {
|
if (!clangVersion.isEmpty()) {
|
||||||
const FilePath clangIncludePath
|
const FilePath clangIncludePath
|
||||||
= clangIncludeDirectory(clangVersion, clangFallbackIncludeDirectory);
|
= 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()) {
|
if (!projectDirectory.isEmpty()) {
|
||||||
const Utils::FilePath rootProjectDirectory = Utils::FilePath::fromString(projectDirectory)
|
const Utils::FilePath rootProjectDirectory = Utils::FilePath::fromString(projectDirectory)
|
||||||
.pathAppended(".pre_includes");
|
.pathAppended(".pre_includes");
|
||||||
|
systemHeaderPaths.push_back(ProjectExplorer::HeaderPath::makeSystem(rootProjectDirectory));
|
||||||
systemHeaderPaths.push_back(
|
|
||||||
{rootProjectDirectory.toString(), ProjectExplorer::HeaderPathType::System});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -534,8 +534,8 @@ static QList<Include> includesForSource(const QString &filePath)
|
|||||||
CppModelManager *cmm = CppModelManager::instance();
|
CppModelManager *cmm = CppModelManager::instance();
|
||||||
cmm->GC();
|
cmm->GC();
|
||||||
QScopedPointer<CppSourceProcessor> sourceProcessor(CppModelManager::createSourceProcessor());
|
QScopedPointer<CppSourceProcessor> sourceProcessor(CppModelManager::createSourceProcessor());
|
||||||
sourceProcessor->setHeaderPaths({{TestIncludePaths::globalIncludePath(),
|
sourceProcessor->setHeaderPaths({ProjectExplorer::HeaderPath::makeUser(
|
||||||
ProjectExplorer::HeaderPathType::User}});
|
TestIncludePaths::globalIncludePath())});
|
||||||
sourceProcessor->run(filePath);
|
sourceProcessor->run(filePath);
|
||||||
|
|
||||||
Document::Ptr document = cmm->document(filePath);
|
Document::Ptr document = cmm->document(filePath);
|
||||||
|
@@ -514,36 +514,24 @@ public:
|
|||||||
return *projectPart;
|
return *projectPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HeaderPath builtIn(const QString &path)
|
static HeaderPath user(const QString &path) { return HeaderPath::makeUser(path); }
|
||||||
{
|
static HeaderPath builtIn(const QString &path) { return HeaderPath::makeBuiltIn(path); }
|
||||||
return HeaderPath{path, HeaderPathType::BuiltIn};
|
static HeaderPath system(const QString &path) { return HeaderPath::makeSystem(path); }
|
||||||
}
|
static HeaderPath framework(const QString &path) { return HeaderPath::makeFramework(path); }
|
||||||
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};
|
|
||||||
}
|
|
||||||
|
|
||||||
QString targetTriple;
|
QString targetTriple;
|
||||||
Utils::Id toolchainType;
|
Utils::Id toolchainType;
|
||||||
Utils::FilePath toolchainInstallDir;
|
Utils::FilePath toolchainInstallDir;
|
||||||
HeaderPaths headerPaths = {
|
HeaderPaths headerPaths = {
|
||||||
HeaderPath{"", HeaderPathType::BuiltIn},
|
builtIn(""),
|
||||||
HeaderPath{"/builtin_path", HeaderPathType::BuiltIn},
|
builtIn("/builtin_path"),
|
||||||
HeaderPath{"/system_path", HeaderPathType::System},
|
system("/system_path"),
|
||||||
HeaderPath{"/framework_path", HeaderPathType::Framework},
|
framework("/framework_path"),
|
||||||
HeaderPath{"/outside_project_user_path", HeaderPathType::User},
|
user("/outside_project_user_path"),
|
||||||
HeaderPath{"/build/user_path", HeaderPathType::User},
|
user("/build/user_path"),
|
||||||
HeaderPath{"/buildb/user_path", HeaderPathType::User},
|
user("/buildb/user_path"),
|
||||||
HeaderPath{"/projectb/user_path", HeaderPathType::User},
|
user("/projectb/user_path"),
|
||||||
HeaderPath{"/project/user_path", HeaderPathType::User}};
|
user("/project/user_path")};
|
||||||
|
|
||||||
Utils::optional<HeaderPathFilter> filter;
|
Utils::optional<HeaderPathFilter> filter;
|
||||||
|
|
||||||
|
@@ -438,13 +438,8 @@ void GenericBuildSystem::parse(RefreshOptions options)
|
|||||||
else
|
else
|
||||||
normalPaths << rawPath;
|
normalPaths << rawPath;
|
||||||
}
|
}
|
||||||
const auto stringsToHeaderPaths = [this](const QStringList &paths, HeaderPathType type) {
|
m_projectIncludePaths = toUserHeaderPaths(normalPaths);
|
||||||
return transform<HeaderPaths>(processEntries(paths),
|
m_projectIncludePaths << toFrameworkHeaderPaths(frameworkPaths);
|
||||||
[type](const QString &p) { return HeaderPath(p, type);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
m_projectIncludePaths = stringsToHeaderPaths(normalPaths, HeaderPathType::User);
|
|
||||||
m_projectIncludePaths << stringsToHeaderPaths(frameworkPaths, HeaderPathType::Framework);
|
|
||||||
m_cxxflags = readFlags(m_cxxflagsFileName);
|
m_cxxflags = readFlags(m_cxxflagsFileName);
|
||||||
m_cflags = readFlags(m_cflagsFileName);
|
m_cflags = readFlags(m_cflagsFileName);
|
||||||
}
|
}
|
||||||
|
@@ -142,9 +142,8 @@ ToolChain::BuiltInHeaderPathsRunner CustomToolChain::createBuiltInHeaderPathsRun
|
|||||||
return [builtInHeaderPaths](const QStringList &cxxFlags, const QString &, const QString &) {
|
return [builtInHeaderPaths](const QStringList &cxxFlags, const QString &, const QString &) {
|
||||||
HeaderPaths flagHeaderPaths;
|
HeaderPaths flagHeaderPaths;
|
||||||
for (const QString &cxxFlag : cxxFlags) {
|
for (const QString &cxxFlag : cxxFlags) {
|
||||||
if (cxxFlag.startsWith(QLatin1String("-I"))) {
|
if (cxxFlag.startsWith(QLatin1String("-I")))
|
||||||
flagHeaderPaths.push_back({cxxFlag.mid(2).trimmed(), HeaderPathType::BuiltIn});
|
flagHeaderPaths.push_back(HeaderPath::makeBuiltIn(cxxFlag.mid(2).trimmed()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return builtInHeaderPaths + flagHeaderPaths;
|
return builtInHeaderPaths + flagHeaderPaths;
|
||||||
@@ -189,7 +188,7 @@ QStringList CustomToolChain::headerPathsList() const
|
|||||||
void CustomToolChain::setHeaderPaths(const QStringList &list)
|
void CustomToolChain::setHeaderPaths(const QStringList &list)
|
||||||
{
|
{
|
||||||
HeaderPaths tmp = Utils::transform<QVector>(list, [](const QString &headerPath) {
|
HeaderPaths tmp = Utils::transform<QVector>(list, [](const QString &headerPath) {
|
||||||
return HeaderPath(headerPath.trimmed(), HeaderPathType::BuiltIn);
|
return HeaderPath::makeBuiltIn(headerPath.trimmed());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (m_builtInHeaderPaths == tmp)
|
if (m_builtInHeaderPaths == tmp)
|
||||||
|
@@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
@@ -41,9 +44,10 @@ class HeaderPath
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HeaderPath() = default;
|
HeaderPath() = default;
|
||||||
HeaderPath(const QString &path, HeaderPathType type)
|
HeaderPath(const QString &path, HeaderPathType type) : path(path), type(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
|
bool operator==(const HeaderPath &other) const
|
||||||
{
|
{
|
||||||
@@ -55,6 +59,23 @@ public:
|
|||||||
return !(*this == other);
|
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;
|
QString path;
|
||||||
HeaderPathType type = HeaderPathType::User;
|
HeaderPathType type = HeaderPathType::User;
|
||||||
};
|
};
|
||||||
@@ -65,4 +86,23 @@ inline auto qHash(const HeaderPath &key, uint seed = 0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
using HeaderPaths = QVector<HeaderPath>;
|
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
|
} // namespace ProjectExplorer
|
||||||
|
@@ -1129,11 +1129,8 @@ ToolChain::BuiltInHeaderPathsRunner MsvcToolChain::createBuiltInHeaderPathsRunne
|
|||||||
const auto it = m_headerPathsPerEnv.constFind(envList);
|
const auto it = m_headerPathsPerEnv.constFind(envList);
|
||||||
if (it != m_headerPathsPerEnv.cend())
|
if (it != m_headerPathsPerEnv.cend())
|
||||||
return *it;
|
return *it;
|
||||||
const auto mapper = [](const FilePath &p) { // TODO: Define functions for this.
|
|
||||||
return HeaderPath(p.toString(), HeaderPathType::BuiltIn);
|
|
||||||
};
|
|
||||||
return *m_headerPathsPerEnv.insert(envList,
|
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);
|
QString path = trimTrailingSlashes(header.path);
|
||||||
|
|
||||||
if (path.endsWith(".framework")) {
|
if (path.endsWith(".framework"))
|
||||||
path = path.left(path.lastIndexOf(QLatin1Char('/')));
|
return HeaderPath::makeFramework(path.left(path.lastIndexOf('/')));
|
||||||
return {path, HeaderPathType::Framework};
|
|
||||||
}
|
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +121,7 @@ void RawProjectPart::setHeaderPaths(const HeaderPaths &headerPaths)
|
|||||||
void RawProjectPart::setIncludePaths(const QStringList &includePaths)
|
void RawProjectPart::setIncludePaths(const QStringList &includePaths)
|
||||||
{
|
{
|
||||||
this->headerPaths = Utils::transform<QVector>(includePaths, [](const QString &path) {
|
this->headerPaths = Utils::transform<QVector>(includePaths, [](const QString &path) {
|
||||||
HeaderPath hp(path, HeaderPathType::User);
|
return RawProjectPart::frameworkDetectionHeuristic(HeaderPath::makeUser(path));
|
||||||
return RawProjectPart::frameworkDetectionHeuristic(hp);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -914,19 +914,17 @@ static RawProjectParts generateProjectParts(
|
|||||||
QStringList list = arrayToStringList(props.value("cpp.includePaths"));
|
QStringList list = arrayToStringList(props.value("cpp.includePaths"));
|
||||||
list.removeDuplicates();
|
list.removeDuplicates();
|
||||||
for (const QString &p : qAsConst(list))
|
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"))
|
list = arrayToStringList(props.value("cpp.distributionIncludePaths"))
|
||||||
+ arrayToStringList(props.value("cpp.systemIncludePaths"));
|
+ arrayToStringList(props.value("cpp.systemIncludePaths"));
|
||||||
list.removeDuplicates();
|
list.removeDuplicates();
|
||||||
for (const QString &p : qAsConst(list))
|
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 = arrayToStringList(props.value("cpp.frameworkPaths"));
|
||||||
list.append(arrayToStringList(props.value("cpp.systemFrameworkPaths")));
|
list.append(arrayToStringList(props.value("cpp.systemFrameworkPaths")));
|
||||||
list.removeDuplicates();
|
list.removeDuplicates();
|
||||||
for (const QString &p : qAsConst(list)) {
|
for (const QString &p : qAsConst(list))
|
||||||
grpHeaderPaths += {FilePath::fromUserInput(p).toString(),
|
grpHeaderPaths += HeaderPath::makeFramework(FilePath::fromUserInput(p));
|
||||||
HeaderPathType::Framework};
|
|
||||||
}
|
|
||||||
rpp.setHeaderPaths(grpHeaderPaths);
|
rpp.setHeaderPaths(grpHeaderPaths);
|
||||||
rpp.setDisplayName(groupName);
|
rpp.setDisplayName(groupName);
|
||||||
const QJsonObject location = grp.value("location").toObject();
|
const QJsonObject location = grp.value("location").toObject();
|
||||||
|
@@ -373,14 +373,13 @@ void QmakeBuildSystem::updateCppCodeModel()
|
|||||||
// Header paths
|
// Header paths
|
||||||
ProjectExplorer::HeaderPaths headerPaths;
|
ProjectExplorer::HeaderPaths headerPaths;
|
||||||
foreach (const QString &inc, pro->variableValue(Variable::IncludePath)) {
|
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))
|
if (!headerPaths.contains(headerPath))
|
||||||
headerPaths += headerPath;
|
headerPaths += headerPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kitInfo.qtVersion && !kitInfo.qtVersion->frameworkPath().isEmpty())
|
if (kitInfo.qtVersion && !kitInfo.qtVersion->frameworkPath().isEmpty())
|
||||||
headerPaths += {kitInfo.qtVersion->frameworkPath().toString(),
|
headerPaths += HeaderPath::makeFramework(kitInfo.qtVersion->frameworkPath());
|
||||||
HeaderPathType::Framework};
|
|
||||||
rpp.setHeaderPaths(headerPaths);
|
rpp.setHeaderPaths(headerPaths);
|
||||||
|
|
||||||
// Files and generators
|
// Files and generators
|
||||||
|
Reference in New Issue
Block a user