Add system include path to HeaderPath and merge ProjectPartHeaderPath

System include paths are appended after other includes by the compiler. So
we should set them as system includes and not as normal includes. Otherwise
we change the include order. Headers in system include paths are not
cluttering the screen with unwanted warning and by the way improve
performance too.

ProjectPartHeaderPath was a dopperganger of HeaderPath, so we merged them.

Change-Id: I7c394b4098b697de79761499ffcd5913cc02d652
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Marco Bubke
2018-09-03 16:10:43 +02:00
parent 59e734d9da
commit 3abaf647d0
44 changed files with 237 additions and 320 deletions

View File

@@ -120,14 +120,14 @@ static void addSystemHeaderPaths(QList<ProjectExplorer::HeaderPath> &paths,
Utils::FileName includePath = stdcppPath; Utils::FileName includePath = stdcppPath;
Utils::FileName cppLibsPath = stdcppPath; Utils::FileName cppLibsPath = stdcppPath;
cppLibsPath.appendPath("libs/" + getArch(triple) + "/include/"); cppLibsPath.appendPath("libs/" + getArch(triple) + "/include/");
paths.prepend({cppLibsPath.toString(), ProjectExplorer::HeaderPath::GlobalHeaderPath}); paths.prepend({cppLibsPath.toString(), ProjectExplorer::IncludePathType::System});
includePath.appendPath("include/"); includePath.appendPath("include/");
paths.prepend({includePath.toString(), ProjectExplorer::HeaderPath::GlobalHeaderPath}); paths.prepend({includePath.toString(), ProjectExplorer::IncludePathType::System});
paths.prepend({ndkPath.toString() + "/sysroot/usr/include/" + triple, paths.prepend({ndkPath.toString() + "/sysroot/usr/include/" + triple,
ProjectExplorer::HeaderPath::GlobalHeaderPath}); ProjectExplorer::IncludePathType::System});
paths.prepend({ndkPath.toString() + "/sysroot/usr/include", paths.prepend({ndkPath.toString() + "/sysroot/usr/include",
ProjectExplorer::HeaderPath::GlobalHeaderPath}); ProjectExplorer::IncludePathType::System});
} }
AndroidToolChain::SystemHeaderPathsRunner AndroidToolChain::createSystemHeaderPathsRunner() const AndroidToolChain::SystemHeaderPathsRunner AndroidToolChain::createSystemHeaderPathsRunner() const

View File

@@ -36,7 +36,7 @@ ClangCompletionAssistInterface::ClangCompletionAssistInterface(
int position, int position,
const QString &fileName, const QString &fileName,
TextEditor::AssistReason reason, TextEditor::AssistReason reason,
const CppTools::ProjectPartHeaderPaths &headerPaths, const ProjectExplorer::HeaderPaths &headerPaths,
const CPlusPlus::LanguageFeatures &features) const CPlusPlus::LanguageFeatures &features)
: AssistInterface(textEditorWidget->document(), position, fileName, reason) : AssistInterface(textEditorWidget->document(), position, fileName, reason)
, m_communicator(communicator) , m_communicator(communicator)
@@ -51,7 +51,7 @@ bool ClangCompletionAssistInterface::objcEnabled() const
return true; // TODO: return true; // TODO:
} }
const CppTools::ProjectPartHeaderPaths &ClangCompletionAssistInterface::headerPaths() const const ProjectExplorer::HeaderPaths &ClangCompletionAssistInterface::headerPaths() const
{ {
return m_headerPaths; return m_headerPaths;
} }
@@ -61,7 +61,7 @@ CPlusPlus::LanguageFeatures ClangCompletionAssistInterface::languageFeatures() c
return m_languageFeatures; return m_languageFeatures;
} }
void ClangCompletionAssistInterface::setHeaderPaths(const CppTools::ProjectPartHeaderPaths &headerPaths) void ClangCompletionAssistInterface::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths)
{ {
m_headerPaths = headerPaths; m_headerPaths = headerPaths;
} }

View File

@@ -41,21 +41,21 @@ public:
int position, int position,
const QString &fileName, const QString &fileName,
TextEditor::AssistReason reason, TextEditor::AssistReason reason,
const CppTools::ProjectPartHeaderPaths &headerPaths, const ProjectExplorer::HeaderPaths &headerPaths,
const CPlusPlus::LanguageFeatures &features); const CPlusPlus::LanguageFeatures &features);
BackendCommunicator &communicator() const; BackendCommunicator &communicator() const;
bool objcEnabled() const; bool objcEnabled() const;
const CppTools::ProjectPartHeaderPaths &headerPaths() const; const ProjectExplorer::HeaderPaths &headerPaths() const;
CPlusPlus::LanguageFeatures languageFeatures() const; CPlusPlus::LanguageFeatures languageFeatures() const;
const TextEditor::TextEditorWidget *textEditorWidget() const; const TextEditor::TextEditorWidget *textEditorWidget() const;
void setHeaderPaths(const CppTools::ProjectPartHeaderPaths &headerPaths); // For tests void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths); // For tests
private: private:
BackendCommunicator &m_communicator; BackendCommunicator &m_communicator;
QStringList m_options; QStringList m_options;
CppTools::ProjectPartHeaderPaths m_headerPaths; ProjectExplorer::HeaderPaths m_headerPaths;
CPlusPlus::LanguageFeatures m_languageFeatures; CPlusPlus::LanguageFeatures m_languageFeatures;
const TextEditor::TextEditorWidget *m_textEditorWidget; const TextEditor::TextEditorWidget *m_textEditorWidget;
}; };

View File

@@ -465,16 +465,16 @@ bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
} }
// Make completion for all relevant includes // Make completion for all relevant includes
CppTools::ProjectPartHeaderPaths headerPaths = m_interface->headerPaths(); ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
const CppTools::ProjectPartHeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(), const ProjectExplorer::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
CppTools::ProjectPartHeaderPath::IncludePath); ProjectExplorer::IncludePathType::User);
if (!headerPaths.contains(currentFilePath)) if (!headerPaths.contains(currentFilePath))
headerPaths.append(currentFilePath); headerPaths.append(currentFilePath);
const ::Utils::MimeType mimeType = ::Utils::mimeTypeForName("text/x-c++hdr"); const ::Utils::MimeType mimeType = ::Utils::mimeTypeForName("text/x-c++hdr");
const QStringList suffixes = mimeType.suffixes(); const QStringList suffixes = mimeType.suffixes();
foreach (const CppTools::ProjectPartHeaderPath &headerPath, headerPaths) { foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
QString realPath = headerPath.path; QString realPath = headerPath.path;
if (!directoryPrefix.isEmpty()) { if (!directoryPrefix.isEmpty()) {
realPath += QLatin1Char('/'); realPath += QLatin1Char('/');

View File

@@ -92,13 +92,11 @@ public:
TextEditor::ProposalModelPtr proposalModel; TextEditor::ProposalModelPtr proposalModel;
}; };
static const CppTools::ProjectPartHeaderPaths toHeaderPaths(const QStringList &paths) static const ProjectExplorer::HeaderPaths toHeaderPaths(const QStringList &paths)
{ {
using namespace CppTools; ProjectExplorer::HeaderPaths result;
ProjectPartHeaderPaths result;
foreach (const QString &path, paths) foreach (const QString &path, paths)
result << ProjectPartHeaderPath(path, ProjectPartHeaderPath::IncludePath); result.push_back({path, ProjectExplorer::IncludePathType::User});
return result; return result;
} }

View File

@@ -166,11 +166,11 @@ ClangBackEnd::CompilerMacros ProjectUpdater::createCompilerMacros(const ProjectE
} }
Utils::SmallStringVector ProjectUpdater::createIncludeSearchPaths( Utils::SmallStringVector ProjectUpdater::createIncludeSearchPaths(
const CppTools::ProjectPartHeaderPaths &projectPartHeaderPaths) const ProjectExplorer::HeaderPaths &projectPartHeaderPaths)
{ {
Utils::SmallStringVector includePaths; Utils::SmallStringVector includePaths;
for (const CppTools::ProjectPartHeaderPath &projectPartHeaderPath : projectPartHeaderPaths) { for (const ProjectExplorer::HeaderPath &projectPartHeaderPath : projectPartHeaderPaths) {
if (projectPartHeaderPath.isValid()) if (projectPartHeaderPath.isValid())
includePaths.emplace_back(projectPartHeaderPath.path); includePaths.emplace_back(projectPartHeaderPath.path);
} }

View File

@@ -32,6 +32,8 @@
#include <filepathcachinginterface.h> #include <filepathcachinginterface.h>
#include <generatedfiles.h> #include <generatedfiles.h>
#include <projectexplorer/headerpath.h>
namespace ProjectExplorer { namespace ProjectExplorer {
class Macro; class Macro;
using Macros = QVector<Macro>; using Macros = QVector<Macro>;
@@ -40,8 +42,6 @@ using Macros = QVector<Macro>;
namespace CppTools { namespace CppTools {
class ProjectPart; class ProjectPart;
class ProjectFile; class ProjectFile;
class ProjectPartHeaderPath;
using ProjectPartHeaderPaths = QVector<ProjectPartHeaderPath>;
} }
namespace ClangBackEnd { namespace ClangBackEnd {
@@ -90,7 +90,7 @@ unittest_public:
static ClangBackEnd::CompilerMacros createCompilerMacros( static ClangBackEnd::CompilerMacros createCompilerMacros(
const ProjectExplorer::Macros &projectMacros); const ProjectExplorer::Macros &projectMacros);
static Utils::SmallStringVector createIncludeSearchPaths( static Utils::SmallStringVector createIncludeSearchPaths(
const CppTools::ProjectPartHeaderPaths &projectPartHeaderPaths); const ProjectExplorer::HeaderPaths &projectPartHeaderPaths);
static ClangBackEnd::FilePaths createExcludedPaths( static ClangBackEnd::FilePaths createExcludedPaths(
const ClangBackEnd::V2::FileContainers &generatedFiles); const ClangBackEnd::V2::FileContainers &generatedFiles);

View File

@@ -335,7 +335,7 @@ static void processCMakeIncludes(const CMakeBuildTarget &cbt, const ToolChain *t
return; return;
foreach (const HeaderPath &hp, tc->systemHeaderPaths(flags, sysroot)) foreach (const HeaderPath &hp, tc->systemHeaderPaths(flags, sysroot))
tcIncludes.insert(FileName::fromString(hp.path())); tcIncludes.insert(FileName::fromString(hp.path));
foreach (const FileName &i, cbt.includeFiles) { foreach (const FileName &i, cbt.includeFiles) {
if (!tcIncludes.contains(i)) if (!tcIncludes.contains(i))
includePaths.append(i.toString()); includePaths.append(i.toString());

View File

@@ -288,7 +288,7 @@ class ProjectHeaderPathsModel : public QAbstractListModel
Q_OBJECT Q_OBJECT
public: public:
ProjectHeaderPathsModel(QObject *parent); ProjectHeaderPathsModel(QObject *parent);
void configure(const ProjectPartHeaderPaths &paths); void configure(const ProjectExplorer::HeaderPaths &paths);
void clear(); void clear();
enum Columns { TypeColumn, PathColumn, ColumnCount }; enum Columns { TypeColumn, PathColumn, ColumnCount };
@@ -299,14 +299,14 @@ public:
QVariant headerData(int section, Qt::Orientation orientation, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const;
private: private:
ProjectPartHeaderPaths m_paths; ProjectExplorer::HeaderPaths m_paths;
}; };
ProjectHeaderPathsModel::ProjectHeaderPathsModel(QObject *parent) : QAbstractListModel(parent) ProjectHeaderPathsModel::ProjectHeaderPathsModel(QObject *parent) : QAbstractListModel(parent)
{ {
} }
void ProjectHeaderPathsModel::configure(const ProjectPartHeaderPaths &paths) void ProjectHeaderPathsModel::configure(const ProjectExplorer::HeaderPaths &paths)
{ {
emit layoutAboutToBeChanged(); emit layoutAboutToBeChanged();
m_paths = paths; m_paths = paths;

View File

@@ -107,7 +107,7 @@ QList<QuickFixTestDocument::Ptr> singleDocument(const QByteArray &original,
} }
BaseQuickFixTestCase::BaseQuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &testDocuments, BaseQuickFixTestCase::BaseQuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &testDocuments,
const ProjectPartHeaderPaths &headerPaths) const ProjectExplorer::HeaderPaths &headerPaths)
: m_testDocuments(testDocuments) : m_testDocuments(testDocuments)
, m_cppCodeStylePreferences(0) , m_cppCodeStylePreferences(0)
, m_restoreHeaderPaths(false) , m_restoreHeaderPaths(false)
@@ -227,7 +227,7 @@ static QString &removeTrailingWhitespace(QString &input)
QuickFixOperationTest::QuickFixOperationTest(const QList<QuickFixTestDocument::Ptr> &testDocuments, QuickFixOperationTest::QuickFixOperationTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
CppQuickFixFactory *factory, CppQuickFixFactory *factory,
const ProjectPartHeaderPaths &headerPaths, const ProjectExplorer::HeaderPaths &headerPaths,
int operationIndex, int operationIndex,
const QByteArray &expectedFailMessage) const QByteArray &expectedFailMessage)
: BaseQuickFixTestCase(testDocuments, headerPaths) : BaseQuickFixTestCase(testDocuments, headerPaths)
@@ -269,15 +269,15 @@ void QuickFixOperationTest::run(const QList<QuickFixTestDocument::Ptr> &testDocu
const QString &headerPath, const QString &headerPath,
int operationIndex) int operationIndex)
{ {
ProjectPartHeaderPaths headerPaths; ProjectExplorer::HeaderPaths headerPaths;
headerPaths += ProjectPartHeaderPath(headerPath, ProjectPartHeaderPath::IncludePath); headerPaths.push_back({headerPath, ProjectExplorer::IncludePathType::User});
QuickFixOperationTest(testDocuments, factory, headerPaths, operationIndex); QuickFixOperationTest(testDocuments, factory, headerPaths, operationIndex);
} }
QuickFixOfferedOperationsTest::QuickFixOfferedOperationsTest( QuickFixOfferedOperationsTest::QuickFixOfferedOperationsTest(
const QList<QuickFixTestDocument::Ptr> &testDocuments, const QList<QuickFixTestDocument::Ptr> &testDocuments,
CppQuickFixFactory *factory, CppQuickFixFactory *factory,
const ProjectPartHeaderPaths &headerPaths, const ProjectExplorer::HeaderPaths &headerPaths,
const QStringList &expectedOperations) const QStringList &expectedOperations)
: BaseQuickFixTestCase(testDocuments, headerPaths) : BaseQuickFixTestCase(testDocuments, headerPaths)
{ {
@@ -1912,7 +1912,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_onlyGetter()
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected); testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
GenerateGetterSetter factory; GenerateGetterSetter factory;
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1); QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 1);
} }
/// Checks: Only generate setter /// Checks: Only generate setter
@@ -1949,7 +1949,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_onlySetter()
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected); testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
GenerateGetterSetter factory; GenerateGetterSetter factory;
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 2); QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 2);
} }
class CppCodeStyleSettingsChanger { class CppCodeStyleSettingsChanger {
@@ -2028,7 +2028,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_onlyGetter_DontPreferGe
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected); testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
GenerateGetterSetter factory; GenerateGetterSetter factory;
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1); QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 1);
} }
/// Checks: Offer a "generate getter" quick fix if there is a setter /// Checks: Offer a "generate getter" quick fix if there is a setter
@@ -2149,7 +2149,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected); testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1); QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 1);
} }
/// Check from header file: If there is a source file, insert the definition in the source file. /// Check from header file: If there is a source file, insert the definition in the source file.
@@ -2335,7 +2335,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_insideClass()
"};"; "};";
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixOperationTest(singleDocument(original, expected), &factory, ProjectPartHeaderPaths(), QuickFixOperationTest(singleDocument(original, expected), &factory, ProjectExplorer::HeaderPaths(),
1); 1);
} }
@@ -2349,7 +2349,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio
"void Foo::bar() {}\n"; "void Foo::bar() {}\n";
InsertDefFromDecl factory; InsertDefFromDecl factory;
QuickFixOperationTest(singleDocument(original, ""), &factory, ProjectPartHeaderPaths(), 1); QuickFixOperationTest(singleDocument(original, ""), &factory, ProjectExplorer::HeaderPaths(), 1);
} }
/// Find right implementation file. /// Find right implementation file.
@@ -2813,7 +2813,7 @@ void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex)
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected); testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
InsertDeclFromDef factory; InsertDeclFromDef factory;
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), sectionIndex); QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), sectionIndex);
} }
/// Check from source file: Insert in header file. /// Check from source file: Insert in header file.
@@ -3672,9 +3672,8 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_noDoubleQtH
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);
ProjectPartHeaderPaths headerPaths; ProjectExplorer::HeaderPaths headerPaths{{TestIncludePaths::globalQtCoreIncludePath(),
headerPaths += ProjectPartHeaderPath(TestIncludePaths::globalQtCoreIncludePath(), ProjectExplorer::IncludePathType::User}};
ProjectPartHeaderPath::IncludePath);
AddIncludeForUndefinedIdentifier factory; AddIncludeForUndefinedIdentifier factory;
const QStringList expectedOperations = QStringList("Add #include <QDir>"); const QStringList expectedOperations = QStringList("Add #include <QDir>");
@@ -3842,7 +3841,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside2()
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected); testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory; MoveFuncDefOutside factory;
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1); QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 1);
} }
/// Check: Move definition from header to cpp (with namespace). /// Check: Move definition from header to cpp (with namespace).
@@ -4149,7 +4148,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_afterClass()
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected); testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory; MoveFuncDefOutside factory;
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1); QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 1);
} }
/// Check if whitespace is respected for operator functions /// Check if whitespace is respected for operator functions
@@ -4224,7 +4223,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_macroUses()
MoveFuncDefOutside factory; MoveFuncDefOutside factory;
QuickFixOperationTest(singleDocument(original, expected), &factory, QuickFixOperationTest(singleDocument(original, expected), &factory,
ProjectPartHeaderPaths(), 0, "QTCREATORBUG-12314"); ProjectExplorer::HeaderPaths(), 0, "QTCREATORBUG-12314");
} }
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_template() void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_template()
@@ -4575,7 +4574,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_macroUses()
MoveFuncDefToDecl factory; MoveFuncDefToDecl factory;
QuickFixOperationTest(singleDocument(original, expected), &factory, QuickFixOperationTest(singleDocument(original, expected), &factory,
ProjectPartHeaderPaths(), 0, "QTCREATORBUG-12314"); ProjectExplorer::HeaderPaths(), 0, "QTCREATORBUG-12314");
} }
void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_override() void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_override()

View File

@@ -24,8 +24,9 @@
****************************************************************************/ ****************************************************************************/
#include "cppeditortestcase.h" #include "cppeditortestcase.h"
#include "cppquickfix.h"
#include <cpptools/projectpartheaderpath.h> #include <projectexplorer/headerpath.h>
#include <QByteArray> #include <QByteArray>
#include <QList> #include <QList>
@@ -76,8 +77,8 @@ public:
/// Exactly one QuickFixTestDocument must contain the cursor position marker '@' /// Exactly one QuickFixTestDocument must contain the cursor position marker '@'
/// or "@{start}" and "@{end}" /// or "@{start}" and "@{end}"
BaseQuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &testDocuments, BaseQuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &testDocuments,
const CppTools::ProjectPartHeaderPaths &headerPaths const ProjectExplorer::HeaderPaths &headerPaths
= CppTools::ProjectPartHeaderPaths()); = ProjectExplorer::HeaderPaths());
~BaseQuickFixTestCase(); ~BaseQuickFixTestCase();
@@ -91,7 +92,7 @@ private:
CppTools::CppCodeStylePreferences *m_cppCodeStylePreferences; CppTools::CppCodeStylePreferences *m_cppCodeStylePreferences;
QByteArray m_cppCodeStylePreferencesOriginalDelegateId; QByteArray m_cppCodeStylePreferencesOriginalDelegateId;
CppTools::ProjectPartHeaderPaths m_headerPathsToRestore; ProjectExplorer::HeaderPaths m_headerPathsToRestore;
bool m_restoreHeaderPaths; bool m_restoreHeaderPaths;
}; };
@@ -101,8 +102,8 @@ class QuickFixOperationTest : public BaseQuickFixTestCase
public: public:
QuickFixOperationTest(const QList<QuickFixTestDocument::Ptr> &testDocuments, QuickFixOperationTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
CppQuickFixFactory *factory, CppQuickFixFactory *factory,
const CppTools::ProjectPartHeaderPaths &headerPaths const ProjectExplorer::HeaderPaths &headerPaths
= CppTools::ProjectPartHeaderPaths(), = ProjectExplorer::HeaderPaths(),
int operationIndex = 0, int operationIndex = 0,
const QByteArray &expectedFailMessage = QByteArray()); const QByteArray &expectedFailMessage = QByteArray());
@@ -118,8 +119,8 @@ class QuickFixOfferedOperationsTest : public BaseQuickFixTestCase
public: public:
QuickFixOfferedOperationsTest(const QList<QuickFixTestDocument::Ptr> &testDocuments, QuickFixOfferedOperationsTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
CppQuickFixFactory *factory, CppQuickFixFactory *factory,
const CppTools::ProjectPartHeaderPaths &headerPaths const ProjectExplorer::HeaderPaths &headerPaths
= CppTools::ProjectPartHeaderPaths(), = ProjectExplorer::HeaderPaths(),
const QStringList &expectedOperations = QStringList()); const QStringList &expectedOperations = QStringList());
}; };

View File

@@ -1740,7 +1740,7 @@ namespace {
QString findShortestInclude(const QString currentDocumentFilePath, QString findShortestInclude(const QString currentDocumentFilePath,
const QString candidateFilePath, const QString candidateFilePath,
const ProjectPartHeaderPaths &headerPaths) const ProjectExplorer::HeaderPaths &headerPaths)
{ {
QString result; QString result;
@@ -1749,7 +1749,7 @@ QString findShortestInclude(const QString currentDocumentFilePath,
if (fileInfo.path() == QFileInfo(currentDocumentFilePath).path()) { if (fileInfo.path() == QFileInfo(currentDocumentFilePath).path()) {
result = QLatin1Char('"') + fileInfo.fileName() + QLatin1Char('"'); result = QLatin1Char('"') + fileInfo.fileName() + QLatin1Char('"');
} else { } else {
foreach (const ProjectPartHeaderPath &headerPath, headerPaths) { foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
if (!candidateFilePath.startsWith(headerPath.path)) if (!candidateFilePath.startsWith(headerPath.path))
continue; continue;
QString relativePath = candidateFilePath.mid(headerPath.path.size()); QString relativePath = candidateFilePath.mid(headerPath.path.size());
@@ -1764,12 +1764,12 @@ QString findShortestInclude(const QString currentDocumentFilePath,
} }
QString findQtIncludeWithSameName(const QString &className, QString findQtIncludeWithSameName(const QString &className,
const ProjectPartHeaderPaths &headerPaths) const ProjectExplorer::HeaderPaths &headerPaths)
{ {
QString result; QString result;
// Check for a header file with the same name in the Qt include paths // Check for a header file with the same name in the Qt include paths
foreach (const ProjectPartHeaderPath &headerPath, headerPaths) { foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
if (!headerPath.path.contains(QLatin1String("/Qt"))) // "QtCore", "QtGui" etc... if (!headerPath.path.contains(QLatin1String("/Qt"))) // "QtCore", "QtGui" etc...
continue; continue;
@@ -1784,9 +1784,9 @@ QString findQtIncludeWithSameName(const QString &className,
return result; return result;
} }
ProjectPartHeaderPaths relevantHeaderPaths(const QString &filePath) ProjectExplorer::HeaderPaths relevantHeaderPaths(const QString &filePath)
{ {
ProjectPartHeaderPaths headerPaths; ProjectExplorer::HeaderPaths headerPaths;
CppModelManager *modelManager = CppModelManager::instance(); CppModelManager *modelManager = CppModelManager::instance();
const QList<ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath); const QList<ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
@@ -1931,7 +1931,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
QString className; QString className;
QList<Core::LocatorFilterEntry> matches; QList<Core::LocatorFilterEntry> matches;
const QString currentDocumentFilePath = interface.semanticInfo().doc->fileName(); const QString currentDocumentFilePath = interface.semanticInfo().doc->fileName();
const ProjectPartHeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath); const ProjectExplorer::HeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath);
bool qtHeaderFileIncludeOffered = false; bool qtHeaderFileIncludeOffered = false;
// Find an include file through the locator // Find an include file through the locator

View File

@@ -73,7 +73,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
CppModelManager *modelManager = CppModelManager::instance(); CppModelManager *modelManager = CppModelManager::instance();
QByteArray configFile = modelManager->codeModelConfiguration(); QByteArray configFile = modelManager->codeModelConfiguration();
ProjectPartHeaderPaths headerPaths; ProjectExplorer::HeaderPaths headerPaths;
QStringList precompiledHeaders; QStringList precompiledHeaders;
QString projectConfigFile; QString projectConfigFile;
LanguageFeatures features = LanguageFeatures::defaultFeatures(); LanguageFeatures features = LanguageFeatures::defaultFeatures();
@@ -245,7 +245,7 @@ Snapshot BuiltinEditorDocumentParser::snapshot() const
return extraState().snapshot; return extraState().snapshot;
} }
ProjectPartHeaderPaths BuiltinEditorDocumentParser::headerPaths() const ProjectExplorer::HeaderPaths BuiltinEditorDocumentParser::headerPaths() const
{ {
return extraState().headerPaths; return extraState().headerPaths;
} }

View File

@@ -46,7 +46,7 @@ public:
CPlusPlus::Document::Ptr document() const; CPlusPlus::Document::Ptr document() const;
CPlusPlus::Snapshot snapshot() const; CPlusPlus::Snapshot snapshot() const;
ProjectPartHeaderPaths headerPaths() const; ProjectExplorer::HeaderPaths headerPaths() const;
void releaseResources(); void releaseResources();
@@ -67,7 +67,7 @@ private:
struct ExtraState { struct ExtraState {
QByteArray configFile; QByteArray configFile;
ProjectPartHeaderPaths headerPaths; ProjectExplorer::HeaderPaths headerPaths;
QString projectConfigFile; QString projectConfigFile;
QStringList precompiledHeaders; QStringList precompiledHeaders;

View File

@@ -58,7 +58,7 @@ namespace {
class ParseParams class ParseParams
{ {
public: public:
ProjectPartHeaderPaths headerPaths; ProjectExplorer::HeaderPaths headerPaths;
WorkingCopy workingCopy; WorkingCopy workingCopy;
QSet<QString> sourceFiles; QSet<QString> sourceFiles;
int indexerFileSizeLimitInMb = -1; int indexerFileSizeLimitInMb = -1;
@@ -203,7 +203,7 @@ void index(QFutureInterface<void> &indexingFuture,
bool processingHeaders = false; bool processingHeaders = false;
CppModelManager *cmm = CppModelManager::instance(); CppModelManager *cmm = CppModelManager::instance();
const ProjectPartHeaderPaths fallbackHeaderPaths = cmm->headerPaths(); const ProjectExplorer::HeaderPaths fallbackHeaderPaths = cmm->headerPaths();
const CPlusPlus::LanguageFeatures defaultFeatures = const CPlusPlus::LanguageFeatures defaultFeatures =
CPlusPlus::LanguageFeatures::defaultFeatures(); CPlusPlus::LanguageFeatures::defaultFeatures();
for (int i = 0; i < files.size(); ++i) { for (int i = 0; i < files.size(); ++i) {
@@ -226,7 +226,7 @@ void index(QFutureInterface<void> &indexingFuture,
processingHeaders = true; processingHeaders = true;
} }
ProjectPartHeaderPaths headerPaths = parts.isEmpty() ProjectExplorer::HeaderPaths headerPaths = parts.isEmpty()
? fallbackHeaderPaths ? fallbackHeaderPaths
: parts.first()->headerPaths; : parts.first()->headerPaths;
sourceProcessor->setHeaderPaths(headerPaths); sourceProcessor->setHeaderPaths(headerPaths);

View File

@@ -198,11 +198,11 @@ void CompilerOptionsBuilder::enableExceptions()
void CompilerOptionsBuilder::addHeaderPathOptions() void CompilerOptionsBuilder::addHeaderPathOptions()
{ {
typedef ProjectPartHeaderPath HeaderPath; using ProjectExplorer::IncludePathType;
QStringList result; QStringList result;
foreach (const HeaderPath &headerPath , m_projectPart.headerPaths) { for (const ProjectExplorer::HeaderPath &headerPath : qAsConst(m_projectPart.headerPaths)) {
if (headerPath.path.isEmpty()) if (headerPath.path.isEmpty())
continue; continue;
@@ -212,12 +212,15 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
QString prefix; QString prefix;
Utils::FileName path; Utils::FileName path;
switch (headerPath.type) { switch (headerPath.type) {
case HeaderPath::FrameworkPath: case IncludePathType::Framework:
prefix = QLatin1String("-F"); prefix = QLatin1String("-F");
break; break;
case IncludePathType::System:
prefix = "-isystem";
break;
default: // This shouldn't happen, but let's be nice..: default: // This shouldn't happen, but let's be nice..:
// intentional fall-through: // intentional fall-through:
case HeaderPath::IncludePath: case IncludePathType::User:
prefix = includeDirOptionForPath(headerPath.path); prefix = includeDirOptionForPath(headerPath.path);
break; break;
} }

View File

@@ -89,13 +89,14 @@ QString Utils::toString(CPlusPlus::Document::DiagnosticMessage::Level level)
return QString(); return QString();
} }
QString Utils::toString(ProjectPartHeaderPath::Type type) QString Utils::toString(ProjectExplorer::IncludePathType type)
{ {
#define CASE_LANGUAGEVERSION(x) case ProjectPartHeaderPath::x: return QLatin1String(#x) #define CASE_LANGUAGEVERSION(x) case ProjectExplorer::IncludePathType::x: return QLatin1String(#x"Path")
switch (type) { switch (type) {
CASE_LANGUAGEVERSION(InvalidPath); CASE_LANGUAGEVERSION(Invalid);
CASE_LANGUAGEVERSION(IncludePath); CASE_LANGUAGEVERSION(User);
CASE_LANGUAGEVERSION(FrameworkPath); CASE_LANGUAGEVERSION(System);
CASE_LANGUAGEVERSION(Framework);
// no default to get a compiler warning if anything is added // no default to get a compiler warning if anything is added
} }
#undef CASE_LANGUAGEVERSION #undef CASE_LANGUAGEVERSION
@@ -409,14 +410,12 @@ QString Utils::pathListToString(const QStringList &pathList)
return result.join(QLatin1Char('\n')); return result.join(QLatin1Char('\n'));
} }
QString Utils::pathListToString(const ProjectPartHeaderPaths &pathList) QString Utils::pathListToString(const ProjectExplorer::HeaderPaths &pathList)
{ {
QStringList result; QStringList result;
foreach (const ProjectPartHeaderPath &path, pathList) { foreach (const ProjectExplorer::HeaderPath &path, pathList) {
result << QString(QLatin1String("%1 (%2 path)")).arg( result << QString(QLatin1String("%1 (%2 path)")).arg(
QDir::toNativeSeparators(path.path), QDir::toNativeSeparators(path.path), toString(path.type));
path.isFrameworkPath() ? QLatin1String("framework") : QLatin1String("include")
);
} }
return result.join(QLatin1Char('\n')); return result.join(QLatin1Char('\n'));
} }
@@ -467,6 +466,17 @@ Dumper::~Dumper()
m_out << "*** END Code Model Inspection Report\n"; m_out << "*** END Code Model Inspection Report\n";
} }
static void printIncludeType(QTextStream &out, ProjectExplorer::IncludePathType type)
{
using ProjectExplorer::IncludePathType;
switch (type) {
case IncludePathType::Invalid: out << "(invalid include path)"; break;
case IncludePathType::User: out << "(user include path)"; break;
case IncludePathType::System: out << "(system include path)"; break;
case IncludePathType::Framework: out << "(framework path)"; break;
}
}
void Dumper::dumpProjectInfos( const QList<ProjectInfo> &projectInfos) void Dumper::dumpProjectInfos( const QList<ProjectInfo> &projectInfos)
{ {
const QByteArray i1 = indent(1); const QByteArray i1 = indent(1);
@@ -526,12 +536,11 @@ void Dumper::dumpProjectInfos( const QList<ProjectInfo> &projectInfos)
if (!part->headerPaths.isEmpty()) { if (!part->headerPaths.isEmpty()) {
m_out << i3 << "Header Paths:{{{4\n"; m_out << i3 << "Header Paths:{{{4\n";
foreach (const ProjectPartHeaderPath &headerPath, part->headerPaths) foreach (const ProjectExplorer::HeaderPath &headerPath, part->headerPaths) {
m_out << i4 << headerPath.path m_out << i4 << headerPath.path;
<< (headerPath.type == ProjectPartHeaderPath::IncludePath printIncludeType(m_out, headerPath.type);
? "(include path)" m_out << "\n";
: "(framework path)") }
<< "\n";
} }
if (!part->precompiledHeaders.isEmpty()) { if (!part->precompiledHeaders.isEmpty()) {
@@ -593,7 +602,7 @@ void Dumper::dumpWorkingCopy(const WorkingCopy &workingCopy)
} }
} }
void Dumper::dumpMergedEntities(const ProjectPartHeaderPaths &mergedHeaderPaths, void Dumper::dumpMergedEntities(const ProjectExplorer::HeaderPaths &mergedHeaderPaths,
const QByteArray &mergedMacros) const QByteArray &mergedMacros)
{ {
m_out << "Merged Entities{{{1\n"; m_out << "Merged Entities{{{1\n";
@@ -601,10 +610,11 @@ void Dumper::dumpMergedEntities(const ProjectPartHeaderPaths &mergedHeaderPaths,
const QByteArray i3 = indent(3); const QByteArray i3 = indent(3);
m_out << i2 << "Merged Header Paths{{{2\n"; m_out << i2 << "Merged Header Paths{{{2\n";
foreach (const ProjectPartHeaderPath &hp, mergedHeaderPaths) foreach (const ProjectExplorer::HeaderPath &hp, mergedHeaderPaths) {
m_out << i3 << hp.path m_out << i3 << hp.path;
<< (hp.isFrameworkPath() ? " (framework path)" : " (include path)") printIncludeType(m_out, hp.type);
<< "\n"; m_out << "\n";
}
m_out << i2 << "Merged Defines{{{2\n"; m_out << i2 << "Merged Defines{{{2\n";
m_out << mergedMacros; m_out << mergedMacros;
} }

View File

@@ -46,7 +46,7 @@ struct CPPTOOLS_EXPORT Utils
static QString toString(const QDateTime &dateTime); static QString toString(const QDateTime &dateTime);
static QString toString(CPlusPlus::Document::CheckMode checkMode); static QString toString(CPlusPlus::Document::CheckMode checkMode);
static QString toString(CPlusPlus::Document::DiagnosticMessage::Level level); static QString toString(CPlusPlus::Document::DiagnosticMessage::Level level);
static QString toString(ProjectPartHeaderPath::Type type); static QString toString(ProjectExplorer::IncludePathType type);
static QString toString(CppTools::ProjectPart::LanguageVersion languageVersion); static QString toString(CppTools::ProjectPart::LanguageVersion languageVersion);
static QString toString(CppTools::ProjectPart::LanguageExtensions languageExtension); static QString toString(CppTools::ProjectPart::LanguageExtensions languageExtension);
static QString toString(CppTools::ProjectPart::QtVersion qtVersion); static QString toString(CppTools::ProjectPart::QtVersion qtVersion);
@@ -57,7 +57,7 @@ struct CPPTOOLS_EXPORT Utils
static QString partsForFile(const QString &fileName); static QString partsForFile(const QString &fileName);
static QString unresolvedFileNameWithDelimiters(const CPlusPlus::Document::Include &include); static QString unresolvedFileNameWithDelimiters(const CPlusPlus::Document::Include &include);
static QString pathListToString(const QStringList &pathList); static QString pathListToString(const QStringList &pathList);
static QString pathListToString(const ProjectPartHeaderPaths &pathList); static QString pathListToString(const ProjectExplorer::HeaderPaths &pathList);
static QList<CPlusPlus::Document::Ptr> snapshotToList(const CPlusPlus::Snapshot &snapshot); static QList<CPlusPlus::Document::Ptr> snapshotToList(const CPlusPlus::Snapshot &snapshot);
}; };
@@ -73,7 +73,7 @@ public:
const QString &title, const QString &title,
bool isGlobalSnapshot = false); bool isGlobalSnapshot = false);
void dumpWorkingCopy(const CppTools::WorkingCopy &workingCopy); void dumpWorkingCopy(const CppTools::WorkingCopy &workingCopy);
void dumpMergedEntities(const ProjectPartHeaderPaths &mergedHeaderPaths, void dumpMergedEntities(const ProjectExplorer::HeaderPaths &mergedHeaderPaths,
const QByteArray &mergedMacros); const QByteArray &mergedMacros);
private: private:

View File

@@ -109,7 +109,7 @@ public:
= new CppCompletionAssistInterface(m_editorWidget->textDocument()->filePath().toString(), = new CppCompletionAssistInterface(m_editorWidget->textDocument()->filePath().toString(),
m_textDocument, m_position, m_textDocument, m_position,
ExplicitlyInvoked, m_snapshot, ExplicitlyInvoked, m_snapshot,
ProjectPartHeaderPaths(), ProjectExplorer::HeaderPaths(),
languageFeatures); languageFeatures);
ai->prepareForAsyncUse(); ai->prepareForAsyncUse();
ai->recreateTextDocument(); ai->recreateTextDocument();

View File

@@ -1258,15 +1258,15 @@ bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cu
} }
// Make completion for all relevant includes // Make completion for all relevant includes
ProjectPartHeaderPaths headerPaths = m_interface->headerPaths(); ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
const ProjectPartHeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(), const ProjectExplorer::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
ProjectPartHeaderPath::IncludePath); ProjectExplorer::IncludePathType::User);
if (!headerPaths.contains(currentFilePath)) if (!headerPaths.contains(currentFilePath))
headerPaths.append(currentFilePath); headerPaths.append(currentFilePath);
const QStringList suffixes = Utils::mimeTypeForName(QLatin1String("text/x-c++hdr")).suffixes(); const QStringList suffixes = Utils::mimeTypeForName(QLatin1String("text/x-c++hdr")).suffixes();
foreach (const ProjectPartHeaderPath &headerPath, headerPaths) { foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
QString realPath = headerPath.path; QString realPath = headerPath.path;
if (!directoryPrefix.isEmpty()) { if (!directoryPrefix.isEmpty()) {
realPath += QLatin1Char('/'); realPath += QLatin1Char('/');

View File

@@ -185,7 +185,7 @@ public:
int position, int position,
TextEditor::AssistReason reason, TextEditor::AssistReason reason,
const CPlusPlus::Snapshot &snapshot, const CPlusPlus::Snapshot &snapshot,
const ProjectPartHeaderPaths &headerPaths, const ProjectExplorer::HeaderPaths &headerPaths,
const CPlusPlus::LanguageFeatures &features) const CPlusPlus::LanguageFeatures &features)
: TextEditor::AssistInterface(textDocument, position, filePath, reason) : TextEditor::AssistInterface(textDocument, position, filePath, reason)
, m_gotCppSpecifics(true) , m_gotCppSpecifics(true)
@@ -195,7 +195,7 @@ public:
{} {}
const CPlusPlus::Snapshot &snapshot() const { getCppSpecifics(); return m_snapshot; } const CPlusPlus::Snapshot &snapshot() const { getCppSpecifics(); return m_snapshot; }
const ProjectPartHeaderPaths &headerPaths() const const ProjectExplorer::HeaderPaths &headerPaths() const
{ getCppSpecifics(); return m_headerPaths; } { getCppSpecifics(); return m_headerPaths; }
CPlusPlus::LanguageFeatures languageFeatures() const CPlusPlus::LanguageFeatures languageFeatures() const
{ getCppSpecifics(); return m_languageFeatures; } { getCppSpecifics(); return m_languageFeatures; }
@@ -207,7 +207,7 @@ private:
mutable bool m_gotCppSpecifics; mutable bool m_gotCppSpecifics;
WorkingCopy m_workingCopy; WorkingCopy m_workingCopy;
mutable CPlusPlus::Snapshot m_snapshot; mutable CPlusPlus::Snapshot m_snapshot;
mutable ProjectPartHeaderPaths m_headerPaths; mutable ProjectExplorer::HeaderPaths m_headerPaths;
mutable CPlusPlus::LanguageFeatures m_languageFeatures; mutable CPlusPlus::LanguageFeatures m_languageFeatures;
}; };

View File

@@ -151,7 +151,7 @@ public:
// The members below are cached/(re)calculated from the projects and/or their project parts // The members below are cached/(re)calculated from the projects and/or their project parts
bool m_dirty; bool m_dirty;
QStringList m_projectFiles; QStringList m_projectFiles;
ProjectPartHeaderPaths m_headerPaths; ProjectExplorer::HeaderPaths m_headerPaths;
ProjectExplorer::Macros m_definedMacros; ProjectExplorer::Macros m_definedMacros;
// Editor integration // Editor integration
@@ -615,18 +615,18 @@ QStringList CppModelManager::internalProjectFiles() const
return files; return files;
} }
ProjectPartHeaderPaths CppModelManager::internalHeaderPaths() const ProjectExplorer::HeaderPaths CppModelManager::internalHeaderPaths() const
{ {
ProjectPartHeaderPaths headerPaths; ProjectExplorer::HeaderPaths headerPaths;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(d->m_projectToProjectsInfo); QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(d->m_projectToProjectsInfo);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
const ProjectInfo pinfo = it.value(); const ProjectInfo pinfo = it.value();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) { foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
foreach (const ProjectPartHeaderPath &path, part->headerPaths) { foreach (const ProjectExplorer::HeaderPath &path, part->headerPaths) {
const ProjectPartHeaderPath hp(QDir::cleanPath(path.path), path.type); ProjectExplorer::HeaderPath hp(QDir::cleanPath(path.path), path.type);
if (!headerPaths.contains(hp)) if (!headerPaths.contains(hp))
headerPaths += hp; headerPaths.push_back(std::move(hp));
} }
} }
} }
@@ -1433,7 +1433,7 @@ QStringList CppModelManager::projectFiles()
return d->m_projectFiles; return d->m_projectFiles;
} }
ProjectPartHeaderPaths CppModelManager::headerPaths() ProjectExplorer::HeaderPaths CppModelManager::headerPaths()
{ {
QMutexLocker locker(&d->m_projectMutex); QMutexLocker locker(&d->m_projectMutex);
ensureUpdated(); ensureUpdated();
@@ -1441,7 +1441,7 @@ ProjectPartHeaderPaths CppModelManager::headerPaths()
return d->m_headerPaths; return d->m_headerPaths;
} }
void CppModelManager::setHeaderPaths(const ProjectPartHeaderPaths &headerPaths) void CppModelManager::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths)
{ {
QMutexLocker locker(&d->m_projectMutex); QMutexLocker locker(&d->m_projectMutex);
d->m_headerPaths = headerPaths; d->m_headerPaths = headerPaths;

View File

@@ -30,7 +30,7 @@
#include "refactoringengineinterface.h" #include "refactoringengineinterface.h"
#include "projectinfo.h" #include "projectinfo.h"
#include "projectpart.h" #include "projectpart.h"
#include "projectpartheaderpath.h" #include <projectexplorer/headerpath.h>
#include <cplusplus/cppmodelmanagerbase.h> #include <cplusplus/cppmodelmanagerbase.h>
#include <coreplugin/find/ifindfilter.h> #include <coreplugin/find/ifindfilter.h>
@@ -189,10 +189,10 @@ public:
QStringList projectFiles(); QStringList projectFiles();
ProjectPartHeaderPaths headerPaths(); ProjectExplorer::HeaderPaths headerPaths();
// Use this *only* for auto tests // Use this *only* for auto tests
void setHeaderPaths(const ProjectPartHeaderPaths &headerPaths); void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths);
ProjectExplorer::Macros definedMacros(); ProjectExplorer::Macros definedMacros();
@@ -274,7 +274,7 @@ private:
void ensureUpdated(); void ensureUpdated();
QStringList internalProjectFiles() const; QStringList internalProjectFiles() const;
ProjectPartHeaderPaths internalHeaderPaths() const; ProjectExplorer::HeaderPaths internalHeaderPaths() const;
ProjectExplorer::Macros internalDefinedMacros() const; ProjectExplorer::Macros internalDefinedMacros() const;
void dumpModelManagerConfiguration(const QString &logFileId); void dumpModelManagerConfiguration(const QString &logFileId);

View File

@@ -183,22 +183,19 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
Project *project = helper.createProject(_("test_modelmanager_paths_are_clean")); Project *project = helper.createProject(_("test_modelmanager_paths_are_clean"));
ProjectInfo pi = ProjectInfo(project); ProjectInfo pi = ProjectInfo(project);
typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart); ProjectPart::Ptr part(new ProjectPart);
part->qtVersion = ProjectPart::Qt5; part->qtVersion = ProjectPart::Qt5;
part->projectMacros = {ProjectExplorer::Macro("OH_BEHAVE", "-1")}; part->projectMacros = {ProjectExplorer::Macro("OH_BEHAVE", "-1")};
part->headerPaths = {HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath), part->headerPaths = {{testDataDir.includeDir(false), IncludePathType::User},
HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath)}; {testDataDir.frameworksDir(false), IncludePathType::Framework}};
pi.appendProjectPart(part); pi.appendProjectPart(part);
mm->updateProjectInfo(pi); mm->updateProjectInfo(pi);
ProjectPartHeaderPaths headerPaths = mm->headerPaths(); ProjectExplorer::HeaderPaths headerPaths = mm->headerPaths();
QCOMPARE(headerPaths.size(), 2); QCOMPARE(headerPaths.size(), 2);
QVERIFY(headerPaths.contains(HeaderPath(testDataDir.includeDir(), HeaderPath::IncludePath))); QVERIFY(headerPaths.contains({testDataDir.includeDir(), IncludePathType::User}));
QVERIFY(headerPaths.contains(HeaderPath(testDataDir.frameworksDir(), QVERIFY(headerPaths.contains({testDataDir.frameworksDir(), IncludePathType::Framework}));
HeaderPath::FrameworkPath)));
} }
/// Check: Frameworks headers are resolved. /// Check: Frameworks headers are resolved.
@@ -215,13 +212,11 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
Project *project = helper.createProject(_("test_modelmanager_framework_headers")); Project *project = helper.createProject(_("test_modelmanager_framework_headers"));
ProjectInfo pi = ProjectInfo(project); ProjectInfo pi = ProjectInfo(project);
typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart); ProjectPart::Ptr part(new ProjectPart);
part->qtVersion = ProjectPart::Qt5; part->qtVersion = ProjectPart::Qt5;
part->projectMacros = {{"OH_BEHAVE", "-1"}}; part->projectMacros = {{"OH_BEHAVE", "-1"}};
part->headerPaths = {HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath), part->headerPaths = {{testDataDir.includeDir(false), IncludePathType::User},
HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath)}; {testDataDir.frameworksDir(false), IncludePathType::Framework}};
const QString &source = testDataDir.fileFromSourcesDir( const QString &source = testDataDir.fileFromSourcesDir(
_("test_modelmanager_framework_headers.cpp")); _("test_modelmanager_framework_headers.cpp"));
part->files << ProjectFile(source, ProjectFile::CXXSource); part->files << ProjectFile(source, ProjectFile::CXXSource);
@@ -264,12 +259,10 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
_("test_modelmanager_refresh_also_includes_of_project_files")); _("test_modelmanager_refresh_also_includes_of_project_files"));
ProjectInfo pi = ProjectInfo(project); ProjectInfo pi = ProjectInfo(project);
typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart); ProjectPart::Ptr part(new ProjectPart);
part->qtVersion = ProjectPart::Qt5; part->qtVersion = ProjectPart::Qt5;
part->projectMacros = {{"OH_BEHAVE", "-1"}}; part->projectMacros = {{"OH_BEHAVE", "-1"}};
part->headerPaths = {HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath)}; part->headerPaths = {{testDataDir.includeDir(false), IncludePathType::User}};
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource)); part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part); pi.appendProjectPart(part);
@@ -755,15 +748,13 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
Project *project = helper.createProject(_("test_modelmanager_defines_per_project")); Project *project = helper.createProject(_("test_modelmanager_defines_per_project"));
typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part1(new ProjectPart); ProjectPart::Ptr part1(new ProjectPart);
part1->projectFile = QLatin1String("project1.projectfile"); part1->projectFile = QLatin1String("project1.projectfile");
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource)); part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader)); part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part1->qtVersion = ProjectPart::NoQt; part1->qtVersion = ProjectPart::NoQt;
part1->projectMacros = {{"SUB1"}}; part1->projectMacros = {{"SUB1"}};
part1->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)}; part1->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
ProjectPart::Ptr part2(new ProjectPart); ProjectPart::Ptr part2(new ProjectPart);
part2->projectFile = QLatin1String("project1.projectfile"); part2->projectFile = QLatin1String("project1.projectfile");
@@ -771,7 +762,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader)); part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part2->qtVersion = ProjectPart::NoQt; part2->qtVersion = ProjectPart::NoQt;
part2->projectMacros = {{"SUB2"}}; part2->projectMacros = {{"SUB2"}};
part2->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)}; part2->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
ProjectInfo pi = ProjectInfo(project); ProjectInfo pi = ProjectInfo(project);
pi.appendProjectPart(part1); pi.appendProjectPart(part1);
@@ -821,15 +812,13 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
Project *project = helper.createProject(_("test_modelmanager_defines_per_project_pch")); Project *project = helper.createProject(_("test_modelmanager_defines_per_project_pch"));
typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part1(new ProjectPart); ProjectPart::Ptr part1(new ProjectPart);
part1->projectFile = QLatin1String("project1.projectfile"); part1->projectFile = QLatin1String("project1.projectfile");
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource)); part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader)); part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part1->qtVersion = ProjectPart::NoQt; part1->qtVersion = ProjectPart::NoQt;
part1->precompiledHeaders.append(pch1File); part1->precompiledHeaders.append(pch1File);
part1->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)}; part1->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
part1->updateLanguageFeatures(); part1->updateLanguageFeatures();
ProjectPart::Ptr part2(new ProjectPart); ProjectPart::Ptr part2(new ProjectPart);
@@ -838,7 +827,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader)); part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part2->qtVersion = ProjectPart::NoQt; part2->qtVersion = ProjectPart::NoQt;
part2->precompiledHeaders.append(pch2File); part2->precompiledHeaders.append(pch2File);
part2->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)}; part2->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
part2->updateLanguageFeatures(); part2->updateLanguageFeatures();
ProjectInfo pi = ProjectInfo(project); ProjectInfo pi = ProjectInfo(project);
@@ -906,19 +895,17 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
Project *project = helper.createProject(_("test_modelmanager_defines_per_editor")); Project *project = helper.createProject(_("test_modelmanager_defines_per_editor"));
typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part1(new ProjectPart); ProjectPart::Ptr part1(new ProjectPart);
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource)); part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader)); part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part1->qtVersion = ProjectPart::NoQt; part1->qtVersion = ProjectPart::NoQt;
part1->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)}; part1->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
ProjectPart::Ptr part2(new ProjectPart); ProjectPart::Ptr part2(new ProjectPart);
part2->files.append(ProjectFile(main2File, ProjectFile::CXXSource)); part2->files.append(ProjectFile(main2File, ProjectFile::CXXSource));
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader)); part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part2->qtVersion = ProjectPart::NoQt; part2->qtVersion = ProjectPart::NoQt;
part2->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)}; part2->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
ProjectInfo pi = ProjectInfo(project); ProjectInfo pi = ProjectInfo(project);
pi.appendProjectPart(part1); pi.appendProjectPart(part1);

View File

@@ -111,17 +111,6 @@ private:
languageExtensions |= ProjectPart::ObjectiveCExtensions; languageExtensions |= ProjectPart::ObjectiveCExtensions;
} }
static ProjectPartHeaderPath toProjectPartHeaderPath(
const ProjectExplorer::HeaderPath &headerPath)
{
const ProjectPartHeaderPath::Type headerPathType =
headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath
? ProjectPartHeaderPath::FrameworkPath
: ProjectPartHeaderPath::IncludePath;
return ProjectPartHeaderPath(headerPath.path(), headerPathType);
}
void addHeaderPaths() void addHeaderPaths()
{ {
if (!m_tcInfo.headerPathsRunner) if (!m_tcInfo.headerPathsRunner)
@@ -131,9 +120,9 @@ private:
= m_tcInfo.headerPathsRunner(m_flags.commandLineFlags, = m_tcInfo.headerPathsRunner(m_flags.commandLineFlags,
m_tcInfo.sysRootPath); m_tcInfo.sysRootPath);
ProjectPartHeaderPaths &headerPaths = m_projectPart.headerPaths; ProjectExplorer::HeaderPaths &headerPaths = m_projectPart.headerPaths;
for (const ProjectExplorer::HeaderPath &header : systemHeaderPaths) { for (const ProjectExplorer::HeaderPath &header : systemHeaderPaths) {
const ProjectPartHeaderPath headerPath = toProjectPartHeaderPath(header); const ProjectExplorer::HeaderPath headerPath{header.path, header.type};
if (!headerPaths.contains(headerPath)) if (!headerPaths.contains(headerPath))
headerPaths.push_back(headerPath); headerPaths.push_back(headerPath);
} }

View File

@@ -86,7 +86,7 @@ void RawProjectPart::setMacros(const ProjectExplorer::Macros &macros)
this->projectMacros = macros; this->projectMacros = macros;
} }
void RawProjectPart::setHeaderPaths(const ProjectPartHeaderPaths &headerPaths) void RawProjectPart::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths)
{ {
this->headerPaths = headerPaths; this->headerPaths = headerPaths;
} }
@@ -96,7 +96,7 @@ void RawProjectPart::setIncludePaths(const QStringList &includePaths)
headerPaths.clear(); headerPaths.clear();
foreach (const QString &includeFile, includePaths) { foreach (const QString &includeFile, includePaths) {
ProjectPartHeaderPath hp(includeFile, ProjectPartHeaderPath::IncludePath); ProjectExplorer::HeaderPath hp(includeFile, ProjectExplorer::IncludePathType::User);
// The simple project managers are utterly ignorant of frameworks on macOS, and won't report // The simple project managers are utterly ignorant of frameworks on macOS, and won't report
// framework paths. The work-around is to check if the include path ends in ".framework", // framework paths. The work-around is to check if the include path ends in ".framework",
@@ -104,12 +104,11 @@ void RawProjectPart::setIncludePaths(const QStringList &includePaths)
if (includeFile.endsWith(QLatin1String(".framework"))) { if (includeFile.endsWith(QLatin1String(".framework"))) {
const int slashIdx = includeFile.lastIndexOf(QLatin1Char('/')); const int slashIdx = includeFile.lastIndexOf(QLatin1Char('/'));
if (slashIdx != -1) { if (slashIdx != -1) {
hp = ProjectPartHeaderPath(includeFile.left(slashIdx), hp = {includeFile.left(slashIdx), ProjectExplorer::IncludePathType::Framework};
ProjectPartHeaderPath::FrameworkPath);
} }
} }
headerPaths += hp; headerPaths.push_back(std::move(hp));
} }
} }

View File

@@ -68,7 +68,7 @@ public:
void setQtVersion(ProjectPart::QtVersion qtVersion); void setQtVersion(ProjectPart::QtVersion qtVersion);
void setMacros(const ProjectExplorer::Macros &macros); void setMacros(const ProjectExplorer::Macros &macros);
void setHeaderPaths(const ProjectPartHeaderPaths &headerPaths); void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths);
void setIncludePaths(const QStringList &includePaths); void setIncludePaths(const QStringList &includePaths);
void setPreCompiledHeaders(const QStringList &preCompiledHeaders); void setPreCompiledHeaders(const QStringList &preCompiledHeaders);
@@ -88,7 +88,7 @@ public:
QString callGroupId; QString callGroupId;
QString buildSystemTarget; QString buildSystemTarget;
QStringList precompiledHeaders; QStringList precompiledHeaders;
ProjectPartHeaderPaths headerPaths; ProjectExplorer::HeaderPaths headerPaths;
ProjectExplorer::Macros projectMacros; ProjectExplorer::Macros projectMacros;
ProjectPart::QtVersion qtVersion = ProjectPart::UnknownQt; ProjectPart::QtVersion qtVersion = ProjectPart::UnknownQt;
bool selectedForBuilding = true; bool selectedForBuilding = true;

View File

@@ -130,15 +130,16 @@ void CppSourceProcessor::setCancelChecker(const CppSourceProcessor::CancelChecke
void CppSourceProcessor::setWorkingCopy(const WorkingCopy &workingCopy) void CppSourceProcessor::setWorkingCopy(const WorkingCopy &workingCopy)
{ m_workingCopy = workingCopy; } { m_workingCopy = workingCopy; }
void CppSourceProcessor::setHeaderPaths(const ProjectPartHeaderPaths &headerPaths) void CppSourceProcessor::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths)
{ {
using ProjectExplorer::IncludePathType;
m_headerPaths.clear(); m_headerPaths.clear();
for (int i = 0, ei = headerPaths.size(); i < ei; ++i) { for (int i = 0, ei = headerPaths.size(); i < ei; ++i) {
const ProjectPartHeaderPath &path = headerPaths.at(i); const ProjectExplorer::HeaderPath &path = headerPaths.at(i);
if (path.type == ProjectPartHeaderPath::IncludePath) if (path.type == IncludePathType::User || path.type == IncludePathType::System)
m_headerPaths.append(ProjectPartHeaderPath(cleanPath(path.path), path.type)); m_headerPaths.append({cleanPath(path.path), path.type});
else else
addFrameworkPath(path); addFrameworkPath(path);
} }
@@ -156,15 +157,15 @@ void CppSourceProcessor::setLanguageFeatures(const LanguageFeatures languageFeat
// has private frameworks in: // has private frameworks in:
// <framework-path>/ApplicationServices.framework/Frameworks // <framework-path>/ApplicationServices.framework/Frameworks
// if the "Frameworks" folder exists inside the top level framework. // if the "Frameworks" folder exists inside the top level framework.
void CppSourceProcessor::addFrameworkPath(const ProjectPartHeaderPath &frameworkPath) void CppSourceProcessor::addFrameworkPath(const ProjectExplorer::HeaderPath &frameworkPath)
{ {
QTC_ASSERT(frameworkPath.isFrameworkPath(), return); QTC_ASSERT(frameworkPath.isFrameworkPath(), return);
// 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 ProjectPartHeaderPath cleanFrameworkPath(cleanPath(frameworkPath.path), const ProjectExplorer::HeaderPath cleanFrameworkPath(cleanPath(frameworkPath.path),
frameworkPath.type); ProjectExplorer::IncludePathType::Framework);
if (!m_headerPaths.contains(cleanFrameworkPath)) if (!m_headerPaths.contains(cleanFrameworkPath))
m_headerPaths.append(cleanFrameworkPath); m_headerPaths.append(cleanFrameworkPath);
@@ -176,8 +177,8 @@ void CppSourceProcessor::addFrameworkPath(const ProjectPartHeaderPath &framework
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(ProjectPartHeaderPath(privateFrameworks.absoluteFilePath(), addFrameworkPath({privateFrameworks.absoluteFilePath(),
frameworkPath.type)); ProjectExplorer::IncludePathType::Framework});
} }
} }
@@ -295,7 +296,7 @@ QString CppSourceProcessor::resolveFile(const QString &fileName, IncludeType typ
} }
QString CppSourceProcessor::resolveFile_helper(const QString &fileName, QString CppSourceProcessor::resolveFile_helper(const QString &fileName,
ProjectPartHeaderPaths::Iterator headerPathsIt) ProjectExplorer::HeaderPaths::Iterator headerPathsIt)
{ {
auto headerPathsEnd = m_headerPaths.end(); auto headerPathsEnd = m_headerPaths.end();
const int index = fileName.indexOf(QLatin1Char('/')); const int index = fileName.indexOf(QLatin1Char('/'));

View File

@@ -63,7 +63,7 @@ public:
void setCancelChecker(const CancelChecker &cancelChecker); void setCancelChecker(const CancelChecker &cancelChecker);
void setWorkingCopy(const CppTools::WorkingCopy &workingCopy); void setWorkingCopy(const CppTools::WorkingCopy &workingCopy);
void setHeaderPaths(const ProjectPartHeaderPaths &headerPaths); void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths);
void setLanguageFeatures(CPlusPlus::LanguageFeatures languageFeatures); void setLanguageFeatures(CPlusPlus::LanguageFeatures languageFeatures);
void setFileSizeLimitInMb(int fileSizeLimitInMb); void setFileSizeLimitInMb(int fileSizeLimitInMb);
void setTodo(const QSet<QString> &files); void setTodo(const QSet<QString> &files);
@@ -78,7 +78,7 @@ public:
void setGlobalSnapshot(const CPlusPlus::Snapshot &snapshot) { m_globalSnapshot = snapshot; } void setGlobalSnapshot(const CPlusPlus::Snapshot &snapshot) { m_globalSnapshot = snapshot; }
private: private:
void addFrameworkPath(const ProjectPartHeaderPath &frameworkPath); void addFrameworkPath(const ProjectExplorer::HeaderPath &frameworkPath);
CPlusPlus::Document::Ptr switchCurrentDocument(CPlusPlus::Document::Ptr doc); CPlusPlus::Document::Ptr switchCurrentDocument(CPlusPlus::Document::Ptr doc);
@@ -87,7 +87,7 @@ private:
bool checkFile(const QString &absoluteFilePath) const; bool checkFile(const QString &absoluteFilePath) const;
QString resolveFile(const QString &fileName, IncludeType type); QString resolveFile(const QString &fileName, IncludeType type);
QString resolveFile_helper(const QString &fileName, QString resolveFile_helper(const QString &fileName,
ProjectPartHeaderPaths::Iterator headerPathsIt); ProjectExplorer::HeaderPaths::Iterator headerPathsIt);
void mergeEnvironment(CPlusPlus::Document::Ptr doc); void mergeEnvironment(CPlusPlus::Document::Ptr doc);
@@ -115,7 +115,7 @@ private:
DocumentCallback m_documentFinished; DocumentCallback m_documentFinished;
CPlusPlus::Environment m_env; CPlusPlus::Environment m_env;
CPlusPlus::Preprocessor m_preprocess; CPlusPlus::Preprocessor m_preprocess;
ProjectPartHeaderPaths m_headerPaths; ProjectExplorer::HeaderPaths m_headerPaths;
CPlusPlus::LanguageFeatures m_languageFeatures; CPlusPlus::LanguageFeatures m_languageFeatures;
CppTools::WorkingCopy m_workingCopy; CppTools::WorkingCopy m_workingCopy;
QSet<QString> m_included; QSet<QString> m_included;

View File

@@ -47,6 +47,7 @@ using namespace CPlusPlus;
using namespace CppTools; using namespace CppTools;
using namespace CppTools::Tests; using namespace CppTools::Tests;
using namespace CppTools::Internal; using namespace CppTools::Internal;
using ProjectExplorer::IncludePathType;
typedef Document::Include Include; typedef Document::Include Include;
@@ -63,9 +64,9 @@ public:
{ {
QScopedPointer<CppSourceProcessor> sourceProcessor( QScopedPointer<CppSourceProcessor> sourceProcessor(
CppModelManager::createSourceProcessor()); CppModelManager::createSourceProcessor());
const ProjectPartHeaderPath hp(TestIncludePaths::directoryOfTestFile(), const ProjectExplorer::HeaderPath hp(TestIncludePaths::directoryOfTestFile(),
ProjectPartHeaderPath::IncludePath); IncludePathType::User);
sourceProcessor->setHeaderPaths(ProjectPartHeaderPaths() << hp); sourceProcessor->setHeaderPaths({hp});
sourceProcessor->run(filePath); sourceProcessor->run(filePath);
Document::Ptr document = m_cmm->document(filePath); Document::Ptr document = m_cmm->document(filePath);
@@ -207,9 +208,8 @@ void CppToolsPlugin::test_cppsourceprocessor_includeNext()
CppSourceProcessor::DocumentCallback documentCallback = [](const Document::Ptr &){}; CppSourceProcessor::DocumentCallback documentCallback = [](const Document::Ptr &){};
CppSourceProcessor sourceProcessor(Snapshot(), documentCallback); CppSourceProcessor sourceProcessor(Snapshot(), documentCallback);
ProjectPartHeaderPaths headerPaths = ProjectPartHeaderPaths() ProjectExplorer::HeaderPaths headerPaths = {{customHeaderPath, IncludePathType::User},
<< ProjectPartHeaderPath(customHeaderPath, ProjectPartHeaderPath::IncludePath) {systemHeaderPath, IncludePathType::User}};
<< ProjectPartHeaderPath(systemHeaderPath, ProjectPartHeaderPath::IncludePath);
sourceProcessor.setHeaderPaths(headerPaths); sourceProcessor.setHeaderPaths(headerPaths);
sourceProcessor.run(mainFilePath); sourceProcessor.run(mainFilePath);

View File

@@ -90,7 +90,6 @@ HEADERS += \
cpptoolsbridgeinterface.h \ cpptoolsbridgeinterface.h \
cpptoolsbridgeqtcreatorimplementation.h \ cpptoolsbridgeqtcreatorimplementation.h \
projectpart.h \ projectpart.h \
projectpartheaderpath.h \
projectinfo.h \ projectinfo.h \
cppprojectinfogenerator.h \ cppprojectinfogenerator.h \
compileroptionsbuilder.h \ compileroptionsbuilder.h \

View File

@@ -200,7 +200,6 @@ Project {
"projectinfo.h", "projectinfo.h",
"projectpart.cpp", "projectpart.cpp",
"projectpart.h", "projectpart.h",
"projectpartheaderpath.h",
"searchsymbols.cpp", "searchsymbols.cpp",
"searchsymbols.h", "searchsymbols.h",
"semantichighlighter.cpp", "semantichighlighter.cpp",

View File

@@ -534,10 +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(ProjectPartHeaderPaths() sourceProcessor->setHeaderPaths({{TestIncludePaths::globalIncludePath(),
<< ProjectPartHeaderPath( ProjectExplorer::IncludePathType::User}});
TestIncludePaths::globalIncludePath(),
ProjectPartHeaderPath::IncludePath));
sourceProcessor->run(filePath); sourceProcessor->run(filePath);
Document::Ptr document = cmm->document(filePath); Document::Ptr document = cmm->document(filePath);

View File

@@ -128,11 +128,11 @@ void ProjectInfo::appendProjectPart(const ProjectPart::Ptr &projectPart)
void ProjectInfo::finish() void ProjectInfo::finish()
{ {
QSet<ProjectPartHeaderPath> uniqueHeaderPaths; QSet<ProjectExplorer::HeaderPath> uniqueHeaderPaths;
foreach (const ProjectPart::Ptr &part, m_projectParts) { foreach (const ProjectPart::Ptr &part, m_projectParts) {
// Update header paths // Update header paths
foreach (const ProjectPartHeaderPath &headerPath, part->headerPaths) { foreach (const ProjectExplorer::HeaderPath &headerPath, part->headerPaths) {
const int count = uniqueHeaderPaths.count(); const int count = uniqueHeaderPaths.count();
uniqueHeaderPaths.insert(headerPath); uniqueHeaderPaths.insert(headerPath);
if (count < uniqueHeaderPaths.count()) if (count < uniqueHeaderPaths.count())

View File

@@ -111,7 +111,7 @@ private:
QVector<ProjectPart::Ptr> m_projectParts; QVector<ProjectPart::Ptr> m_projectParts;
// The members below are (re)calculated from the project parts with finish() // The members below are (re)calculated from the project parts with finish()
ProjectPartHeaderPaths m_headerPaths; ProjectExplorer::HeaderPaths m_headerPaths;
QSet<QString> m_sourceFiles; QSet<QString> m_sourceFiles;
ProjectExplorer::Macros m_defines; ProjectExplorer::Macros m_defines;
}; };

View File

@@ -28,8 +28,8 @@
#include "cpptools_global.h" #include "cpptools_global.h"
#include "cppprojectfile.h" #include "cppprojectfile.h"
#include "projectpartheaderpath.h"
#include <projectexplorer/headerpath.h>
#include <projectexplorer/projectexplorer_global.h> #include <projectexplorer/projectexplorer_global.h>
#include <projectexplorer/projectmacro.h> #include <projectexplorer/projectmacro.h>
@@ -123,7 +123,7 @@ public:
ProjectFiles files; ProjectFiles files;
QStringList precompiledHeaders; QStringList precompiledHeaders;
ProjectPartHeaderPaths headerPaths; ProjectExplorer::HeaderPaths headerPaths;
ProjectExplorer::Macros projectMacros; ProjectExplorer::Macros projectMacros;

View File

@@ -1,80 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <QVector>
namespace CppTools {
class ProjectPartHeaderPath {
public:
enum Type {
InvalidPath,
IncludePath,
FrameworkPath
};
QString path;
Type type;
ProjectPartHeaderPath()
: type(InvalidPath)
{}
ProjectPartHeaderPath(const QString &path, Type type)
: path(path),
type(type)
{}
bool isValid() const
{
return type != InvalidPath;
}
bool isFrameworkPath() const
{
return type == FrameworkPath;
}
bool operator==(const ProjectPartHeaderPath &other) const
{
return path == other.path
&& type == other.type;
}
bool operator!=(const ProjectPartHeaderPath &other) const
{
return !(*this == other);
}
};
using ProjectPartHeaderPaths = QVector<ProjectPartHeaderPath>;
inline uint qHash(const ProjectPartHeaderPath &key, uint seed = 0)
{
return ((qHash(key.path) << 2) | key.type) ^ seed;
}
} // namespace CppTools

View File

@@ -219,7 +219,7 @@ ToolChain::SystemHeaderPathsRunner AbstractMsvcToolChain::createSystemHeaderPath
QMutexLocker locker(m_headerPathsMutex); QMutexLocker locker(m_headerPathsMutex);
if (m_headerPaths.isEmpty()) { if (m_headerPaths.isEmpty()) {
foreach (const QString &path, env.value(QLatin1String("INCLUDE")).split(QLatin1Char(';'))) foreach (const QString &path, env.value(QLatin1String("INCLUDE")).split(QLatin1Char(';')))
m_headerPaths.append(HeaderPath(path, HeaderPath::GlobalHeaderPath)); m_headerPaths.append({path, IncludePathType::System});
} }
return m_headerPaths; return m_headerPaths;
}; };

View File

@@ -174,8 +174,9 @@ ToolChain::SystemHeaderPathsRunner CustomToolChain::createSystemHeaderPathsRunne
return [systemHeaderPaths](const QStringList &cxxFlags, const QString &) { return [systemHeaderPaths](const QStringList &cxxFlags, const QString &) {
QList<HeaderPath> flagHeaderPaths; QList<HeaderPath> flagHeaderPaths;
for (const QString &cxxFlag : cxxFlags) { for (const QString &cxxFlag : cxxFlags) {
if (cxxFlag.startsWith(QLatin1String("-I"))) if (cxxFlag.startsWith(QLatin1String("-I"))) {
flagHeaderPaths << HeaderPath(cxxFlag.mid(2).trimmed(), HeaderPath::GlobalHeaderPath); flagHeaderPaths.push_back({cxxFlag.mid(2).trimmed(), IncludePathType::System});
}
} }
return systemHeaderPaths + flagHeaderPaths; return systemHeaderPaths + flagHeaderPaths;
@@ -227,7 +228,7 @@ QStringList CustomToolChain::headerPathsList() const
void CustomToolChain::setHeaderPaths(const QStringList &list) void CustomToolChain::setHeaderPaths(const QStringList &list)
{ {
QList<HeaderPath> tmp = Utils::transform(list, [](const QString &headerPath) { QList<HeaderPath> tmp = Utils::transform(list, [](const QString &headerPath) {
return HeaderPath(headerPath.trimmed(), HeaderPath::GlobalHeaderPath); return HeaderPath(headerPath.trimmed(), IncludePathType::System);
}); });
if (m_systemHeaderPaths == tmp) if (m_systemHeaderPaths == tmp)

View File

@@ -151,24 +151,24 @@ QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStrin
} }
if (!line.isEmpty() && line.startsWith("#include")) { if (!line.isEmpty() && line.startsWith("#include")) {
HeaderPath::Kind kind = HeaderPath::UserHeaderPath; auto kind = IncludePathType::User;
while (cpp.canReadLine()) { while (cpp.canReadLine()) {
line = cpp.readLine(); line = cpp.readLine();
if (line.startsWith("#include")) { if (line.startsWith("#include")) {
kind = HeaderPath::GlobalHeaderPath; kind = IncludePathType::System;
} else if (! line.isEmpty() && QChar(line.at(0)).isSpace()) { } else if (! line.isEmpty() && QChar(line.at(0)).isSpace()) {
HeaderPath::Kind thisHeaderKind = kind; IncludePathType thisHeaderKind = kind;
line = line.trimmed(); line = line.trimmed();
const int index = line.indexOf(" (framework directory)"); const int index = line.indexOf(" (framework directory)");
if (index != -1) { if (index != -1) {
line.truncate(index); line.truncate(index);
thisHeaderKind = HeaderPath::FrameworkHeaderPath; thisHeaderKind = IncludePathType::Framework;
} }
const QString headerPath = QFileInfo(QFile::decodeName(line)).canonicalFilePath(); const QString headerPath = QFileInfo(QFile::decodeName(line)).canonicalFilePath();
systemHeaderPaths.append(HeaderPath(headerPath, thisHeaderKind)); systemHeaderPaths.append({headerPath, thisHeaderKind});
} else if (line.startsWith("End of search list.")) { } else if (line.startsWith("End of search list.")) {
break; break;
} else { } else {
@@ -657,7 +657,7 @@ ToolChain::SystemHeaderPathsRunner GccToolChain::createSystemHeaderPathsRunner()
qCDebug(gccLog) << compilerCommand.toUserOutput() qCDebug(gccLog) << compilerCommand.toUserOutput()
<< (languageId == Constants::CXX_LANGUAGE_ID ? ": C++ [" : ": C [") << (languageId == Constants::CXX_LANGUAGE_ID ? ": C++ [" : ": C [")
<< arguments.join(", ") << "]" << arguments.join(", ") << "]"
<< hp.path(); << hp.path;
} }
return paths; return paths;

View File

@@ -24,36 +24,55 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <QString>
#include "projectexplorer_export.h" #include <QString>
#include <QVector>
namespace ProjectExplorer { namespace ProjectExplorer {
class PROJECTEXPLORER_EXPORT HeaderPath enum class IncludePathType {
{ Invalid,
public: User,
enum Kind { System,
GlobalHeaderPath, Framework
UserHeaderPath,
FrameworkHeaderPath
}; };
class HeaderPath
{
public:
HeaderPath() = default; HeaderPath() = default;
HeaderPath(const QString &path, Kind kind) : m_path(path), m_kind(kind) HeaderPath(const QString &path, IncludePathType type)
: path(path), type(type)
{ } { }
QString path() const { return m_path; } bool isValid() const
Kind kind() const { return m_kind; } {
return type != IncludePathType::Invalid;
}
bool isFrameworkPath() const
{
return type == IncludePathType::Framework;
}
bool operator==(const HeaderPath &other) const bool operator==(const HeaderPath &other) const
{ {
return m_kind == other.m_kind && m_path == other.m_path; return type == other.type && path == other.path;
} }
private: bool operator!=(const HeaderPath &other) const
QString m_path; {
Kind m_kind = GlobalHeaderPath; return !(*this == other);
}
QString path;
IncludePathType type = IncludePathType::Invalid;
}; };
inline uint qHash(const HeaderPath &key, uint seed = 0)
{
return ((qHash(key.path) << 2) | uint(key.type)) ^ seed;
}
using HeaderPaths = QVector<HeaderPath>;
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -981,11 +981,9 @@ void QbsProject::updateCppCodeModel()
list.append(props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE), list.append(props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_SYSTEM_INCLUDEPATHS))); QLatin1String(CONFIG_SYSTEM_INCLUDEPATHS)));
list.removeDuplicates(); list.removeDuplicates();
CppTools::ProjectPartHeaderPaths grpHeaderPaths; ProjectExplorer::HeaderPaths grpHeaderPaths;
foreach (const QString &p, list) foreach (const QString &p, list)
grpHeaderPaths += CppTools::ProjectPartHeaderPath( grpHeaderPaths += {FileName::fromUserInput(p).toString(), IncludePathType::User};
FileName::fromUserInput(p).toString(),
CppTools::ProjectPartHeaderPath::IncludePath);
list = props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE), list = props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_FRAMEWORKPATHS)); QLatin1String(CONFIG_FRAMEWORKPATHS));
@@ -993,9 +991,7 @@ void QbsProject::updateCppCodeModel()
QLatin1String(CONFIG_SYSTEM_FRAMEWORKPATHS))); QLatin1String(CONFIG_SYSTEM_FRAMEWORKPATHS)));
list.removeDuplicates(); list.removeDuplicates();
foreach (const QString &p, list) foreach (const QString &p, list)
grpHeaderPaths += CppTools::ProjectPartHeaderPath( grpHeaderPaths += {FileName::fromUserInput(p).toString(), IncludePathType::Framework};
FileName::fromUserInput(p).toString(),
CppTools::ProjectPartHeaderPath::FrameworkPath);
rpp.setHeaderPaths(grpHeaderPaths); rpp.setHeaderPaths(grpHeaderPaths);

View File

@@ -41,7 +41,7 @@
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
#include <cpptools/cpprawprojectpart.h> #include <cpptools/cpprawprojectpart.h>
#include <cpptools/projectinfo.h> #include <cpptools/projectinfo.h>
#include <cpptools/projectpartheaderpath.h> #include <projectexplorer/headerpath.h>
#include <cpptools/cppprojectupdater.h> #include <cpptools/cppprojectupdater.h>
#include <cpptools/cppmodelmanager.h> #include <cpptools/cppmodelmanager.h>
#include <qmljs/qmljsmodelmanagerinterface.h> #include <qmljs/qmljsmodelmanagerinterface.h>
@@ -313,17 +313,15 @@ void QmakeProject::updateCppCodeModel()
rpp.setQtVersion(ProjectPart::NoQt); rpp.setQtVersion(ProjectPart::NoQt);
// Header paths // Header paths
CppTools::ProjectPartHeaderPaths headerPaths; ProjectExplorer::HeaderPaths headerPaths;
using CppToolsHeaderPath = CppTools::ProjectPartHeaderPath;
foreach (const QString &inc, pro->variableValue(Variable::IncludePath)) { foreach (const QString &inc, pro->variableValue(Variable::IncludePath)) {
const auto headerPath = CppToolsHeaderPath(inc, CppToolsHeaderPath::IncludePath); const ProjectExplorer::HeaderPath headerPath{inc, IncludePathType::User};
if (!headerPaths.contains(headerPath)) if (!headerPaths.contains(headerPath))
headerPaths += headerPath; headerPaths += headerPath;
} }
if (qtVersion && !qtVersion->frameworkInstallPath().isEmpty()) { if (qtVersion && !qtVersion->frameworkInstallPath().isEmpty()) {
headerPaths += CppToolsHeaderPath(qtVersion->frameworkInstallPath(), headerPaths += {qtVersion->frameworkInstallPath(), IncludePathType::Framework};
CppToolsHeaderPath::FrameworkPath);
} }
rpp.setHeaderPaths(headerPaths); rpp.setHeaderPaths(headerPaths);

View File

@@ -59,7 +59,7 @@ using ClangBackEnd::CompilerMacro;
using ClangBackEnd::V2::FileContainer; using ClangBackEnd::V2::FileContainer;
using ClangBackEnd::V2::ProjectPartContainer; using ClangBackEnd::V2::ProjectPartContainer;
using CppTools::CompilerOptionsBuilder; using CppTools::CompilerOptionsBuilder;
using CppTools::ProjectPartHeaderPath; using ProjectExplorer::HeaderPath;
class ProjectUpdater : public testing::Test class ProjectUpdater : public testing::Test
{ {
@@ -250,10 +250,10 @@ TEST_F(ProjectUpdater, CreateSortedCompilerMacros)
TEST_F(ProjectUpdater, CreateSortedIncludeSearchPaths) TEST_F(ProjectUpdater, CreateSortedIncludeSearchPaths)
{ {
ProjectPartHeaderPath includePath{"/to/path1", ProjectPartHeaderPath::IncludePath}; ProjectExplorer::HeaderPath includePath{"/to/path1", ProjectExplorer::IncludePathType::User};
ProjectPartHeaderPath includePath2{"/to/path2", ProjectPartHeaderPath::IncludePath}; ProjectExplorer::HeaderPath includePath2{"/to/path2", ProjectExplorer::IncludePathType::User};
ProjectPartHeaderPath invalidPath; ProjectExplorer::HeaderPath invalidPath;
ProjectPartHeaderPath frameworkPath{"/framework/path", ProjectPartHeaderPath::FrameworkPath}; ProjectExplorer::HeaderPath frameworkPath{"/framework/path", ProjectExplorer::IncludePathType::Framework};
auto paths = updater.createIncludeSearchPaths({frameworkPath, includePath2, includePath, invalidPath}); auto paths = updater.createIncludeSearchPaths({frameworkPath, includePath2, includePath, invalidPath});