forked from qt-creator/qt-creator
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:
@@ -120,14 +120,14 @@ static void addSystemHeaderPaths(QList<ProjectExplorer::HeaderPath> &paths,
|
||||
Utils::FileName includePath = stdcppPath;
|
||||
Utils::FileName cppLibsPath = stdcppPath;
|
||||
cppLibsPath.appendPath("libs/" + getArch(triple) + "/include/");
|
||||
paths.prepend({cppLibsPath.toString(), ProjectExplorer::HeaderPath::GlobalHeaderPath});
|
||||
paths.prepend({cppLibsPath.toString(), ProjectExplorer::IncludePathType::System});
|
||||
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,
|
||||
ProjectExplorer::HeaderPath::GlobalHeaderPath});
|
||||
ProjectExplorer::IncludePathType::System});
|
||||
paths.prepend({ndkPath.toString() + "/sysroot/usr/include",
|
||||
ProjectExplorer::HeaderPath::GlobalHeaderPath});
|
||||
ProjectExplorer::IncludePathType::System});
|
||||
}
|
||||
|
||||
AndroidToolChain::SystemHeaderPathsRunner AndroidToolChain::createSystemHeaderPathsRunner() const
|
||||
|
||||
@@ -36,7 +36,7 @@ ClangCompletionAssistInterface::ClangCompletionAssistInterface(
|
||||
int position,
|
||||
const QString &fileName,
|
||||
TextEditor::AssistReason reason,
|
||||
const CppTools::ProjectPartHeaderPaths &headerPaths,
|
||||
const ProjectExplorer::HeaderPaths &headerPaths,
|
||||
const CPlusPlus::LanguageFeatures &features)
|
||||
: AssistInterface(textEditorWidget->document(), position, fileName, reason)
|
||||
, m_communicator(communicator)
|
||||
@@ -51,7 +51,7 @@ bool ClangCompletionAssistInterface::objcEnabled() const
|
||||
return true; // TODO:
|
||||
}
|
||||
|
||||
const CppTools::ProjectPartHeaderPaths &ClangCompletionAssistInterface::headerPaths() const
|
||||
const ProjectExplorer::HeaderPaths &ClangCompletionAssistInterface::headerPaths() const
|
||||
{
|
||||
return m_headerPaths;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ CPlusPlus::LanguageFeatures ClangCompletionAssistInterface::languageFeatures() c
|
||||
return m_languageFeatures;
|
||||
}
|
||||
|
||||
void ClangCompletionAssistInterface::setHeaderPaths(const CppTools::ProjectPartHeaderPaths &headerPaths)
|
||||
void ClangCompletionAssistInterface::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths)
|
||||
{
|
||||
m_headerPaths = headerPaths;
|
||||
}
|
||||
|
||||
@@ -41,21 +41,21 @@ public:
|
||||
int position,
|
||||
const QString &fileName,
|
||||
TextEditor::AssistReason reason,
|
||||
const CppTools::ProjectPartHeaderPaths &headerPaths,
|
||||
const ProjectExplorer::HeaderPaths &headerPaths,
|
||||
const CPlusPlus::LanguageFeatures &features);
|
||||
|
||||
BackendCommunicator &communicator() const;
|
||||
bool objcEnabled() const;
|
||||
const CppTools::ProjectPartHeaderPaths &headerPaths() const;
|
||||
const ProjectExplorer::HeaderPaths &headerPaths() const;
|
||||
CPlusPlus::LanguageFeatures languageFeatures() const;
|
||||
const TextEditor::TextEditorWidget *textEditorWidget() const;
|
||||
|
||||
void setHeaderPaths(const CppTools::ProjectPartHeaderPaths &headerPaths); // For tests
|
||||
void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths); // For tests
|
||||
|
||||
private:
|
||||
BackendCommunicator &m_communicator;
|
||||
QStringList m_options;
|
||||
CppTools::ProjectPartHeaderPaths m_headerPaths;
|
||||
ProjectExplorer::HeaderPaths m_headerPaths;
|
||||
CPlusPlus::LanguageFeatures m_languageFeatures;
|
||||
const TextEditor::TextEditorWidget *m_textEditorWidget;
|
||||
};
|
||||
|
||||
@@ -465,16 +465,16 @@ bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
|
||||
}
|
||||
|
||||
// Make completion for all relevant includes
|
||||
CppTools::ProjectPartHeaderPaths headerPaths = m_interface->headerPaths();
|
||||
const CppTools::ProjectPartHeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
|
||||
CppTools::ProjectPartHeaderPath::IncludePath);
|
||||
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
|
||||
const ProjectExplorer::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
|
||||
ProjectExplorer::IncludePathType::User);
|
||||
if (!headerPaths.contains(currentFilePath))
|
||||
headerPaths.append(currentFilePath);
|
||||
|
||||
const ::Utils::MimeType mimeType = ::Utils::mimeTypeForName("text/x-c++hdr");
|
||||
const QStringList suffixes = mimeType.suffixes();
|
||||
|
||||
foreach (const CppTools::ProjectPartHeaderPath &headerPath, headerPaths) {
|
||||
foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
|
||||
QString realPath = headerPath.path;
|
||||
if (!directoryPrefix.isEmpty()) {
|
||||
realPath += QLatin1Char('/');
|
||||
|
||||
@@ -92,13 +92,11 @@ public:
|
||||
TextEditor::ProposalModelPtr proposalModel;
|
||||
};
|
||||
|
||||
static const CppTools::ProjectPartHeaderPaths toHeaderPaths(const QStringList &paths)
|
||||
static const ProjectExplorer::HeaderPaths toHeaderPaths(const QStringList &paths)
|
||||
{
|
||||
using namespace CppTools;
|
||||
|
||||
ProjectPartHeaderPaths result;
|
||||
ProjectExplorer::HeaderPaths result;
|
||||
foreach (const QString &path, paths)
|
||||
result << ProjectPartHeaderPath(path, ProjectPartHeaderPath::IncludePath);
|
||||
result.push_back({path, ProjectExplorer::IncludePathType::User});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -166,11 +166,11 @@ ClangBackEnd::CompilerMacros ProjectUpdater::createCompilerMacros(const ProjectE
|
||||
}
|
||||
|
||||
Utils::SmallStringVector ProjectUpdater::createIncludeSearchPaths(
|
||||
const CppTools::ProjectPartHeaderPaths &projectPartHeaderPaths)
|
||||
const ProjectExplorer::HeaderPaths &projectPartHeaderPaths)
|
||||
{
|
||||
Utils::SmallStringVector includePaths;
|
||||
|
||||
for (const CppTools::ProjectPartHeaderPath &projectPartHeaderPath : projectPartHeaderPaths) {
|
||||
for (const ProjectExplorer::HeaderPath &projectPartHeaderPath : projectPartHeaderPaths) {
|
||||
if (projectPartHeaderPath.isValid())
|
||||
includePaths.emplace_back(projectPartHeaderPath.path);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
#include <filepathcachinginterface.h>
|
||||
#include <generatedfiles.h>
|
||||
|
||||
#include <projectexplorer/headerpath.h>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class Macro;
|
||||
using Macros = QVector<Macro>;
|
||||
@@ -40,8 +42,6 @@ using Macros = QVector<Macro>;
|
||||
namespace CppTools {
|
||||
class ProjectPart;
|
||||
class ProjectFile;
|
||||
class ProjectPartHeaderPath;
|
||||
using ProjectPartHeaderPaths = QVector<ProjectPartHeaderPath>;
|
||||
}
|
||||
|
||||
namespace ClangBackEnd {
|
||||
@@ -90,7 +90,7 @@ unittest_public:
|
||||
static ClangBackEnd::CompilerMacros createCompilerMacros(
|
||||
const ProjectExplorer::Macros &projectMacros);
|
||||
static Utils::SmallStringVector createIncludeSearchPaths(
|
||||
const CppTools::ProjectPartHeaderPaths &projectPartHeaderPaths);
|
||||
const ProjectExplorer::HeaderPaths &projectPartHeaderPaths);
|
||||
static ClangBackEnd::FilePaths createExcludedPaths(
|
||||
const ClangBackEnd::V2::FileContainers &generatedFiles);
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ static void processCMakeIncludes(const CMakeBuildTarget &cbt, const ToolChain *t
|
||||
return;
|
||||
|
||||
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) {
|
||||
if (!tcIncludes.contains(i))
|
||||
includePaths.append(i.toString());
|
||||
|
||||
@@ -288,7 +288,7 @@ class ProjectHeaderPathsModel : public QAbstractListModel
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectHeaderPathsModel(QObject *parent);
|
||||
void configure(const ProjectPartHeaderPaths &paths);
|
||||
void configure(const ProjectExplorer::HeaderPaths &paths);
|
||||
void clear();
|
||||
|
||||
enum Columns { TypeColumn, PathColumn, ColumnCount };
|
||||
@@ -299,14 +299,14 @@ public:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
|
||||
private:
|
||||
ProjectPartHeaderPaths m_paths;
|
||||
ProjectExplorer::HeaderPaths m_paths;
|
||||
};
|
||||
|
||||
ProjectHeaderPathsModel::ProjectHeaderPathsModel(QObject *parent) : QAbstractListModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void ProjectHeaderPathsModel::configure(const ProjectPartHeaderPaths &paths)
|
||||
void ProjectHeaderPathsModel::configure(const ProjectExplorer::HeaderPaths &paths)
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
m_paths = paths;
|
||||
|
||||
@@ -107,7 +107,7 @@ QList<QuickFixTestDocument::Ptr> singleDocument(const QByteArray &original,
|
||||
}
|
||||
|
||||
BaseQuickFixTestCase::BaseQuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||
const ProjectPartHeaderPaths &headerPaths)
|
||||
const ProjectExplorer::HeaderPaths &headerPaths)
|
||||
: m_testDocuments(testDocuments)
|
||||
, m_cppCodeStylePreferences(0)
|
||||
, m_restoreHeaderPaths(false)
|
||||
@@ -227,7 +227,7 @@ static QString &removeTrailingWhitespace(QString &input)
|
||||
|
||||
QuickFixOperationTest::QuickFixOperationTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||
CppQuickFixFactory *factory,
|
||||
const ProjectPartHeaderPaths &headerPaths,
|
||||
const ProjectExplorer::HeaderPaths &headerPaths,
|
||||
int operationIndex,
|
||||
const QByteArray &expectedFailMessage)
|
||||
: BaseQuickFixTestCase(testDocuments, headerPaths)
|
||||
@@ -269,15 +269,15 @@ void QuickFixOperationTest::run(const QList<QuickFixTestDocument::Ptr> &testDocu
|
||||
const QString &headerPath,
|
||||
int operationIndex)
|
||||
{
|
||||
ProjectPartHeaderPaths headerPaths;
|
||||
headerPaths += ProjectPartHeaderPath(headerPath, ProjectPartHeaderPath::IncludePath);
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
headerPaths.push_back({headerPath, ProjectExplorer::IncludePathType::User});
|
||||
QuickFixOperationTest(testDocuments, factory, headerPaths, operationIndex);
|
||||
}
|
||||
|
||||
QuickFixOfferedOperationsTest::QuickFixOfferedOperationsTest(
|
||||
const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||
CppQuickFixFactory *factory,
|
||||
const ProjectPartHeaderPaths &headerPaths,
|
||||
const ProjectExplorer::HeaderPaths &headerPaths,
|
||||
const QStringList &expectedOperations)
|
||||
: BaseQuickFixTestCase(testDocuments, headerPaths)
|
||||
{
|
||||
@@ -1912,7 +1912,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_onlyGetter()
|
||||
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||
|
||||
GenerateGetterSetter factory;
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1);
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 1);
|
||||
}
|
||||
|
||||
/// Checks: Only generate setter
|
||||
@@ -1949,7 +1949,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_onlySetter()
|
||||
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||
|
||||
GenerateGetterSetter factory;
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 2);
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 2);
|
||||
}
|
||||
|
||||
class CppCodeStyleSettingsChanger {
|
||||
@@ -2028,7 +2028,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_onlyGetter_DontPreferGe
|
||||
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||
|
||||
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
|
||||
@@ -2149,7 +2149,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
|
||||
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||
|
||||
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.
|
||||
@@ -2335,7 +2335,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_insideClass()
|
||||
"};";
|
||||
|
||||
InsertDefFromDecl factory;
|
||||
QuickFixOperationTest(singleDocument(original, expected), &factory, ProjectPartHeaderPaths(),
|
||||
QuickFixOperationTest(singleDocument(original, expected), &factory, ProjectExplorer::HeaderPaths(),
|
||||
1);
|
||||
}
|
||||
|
||||
@@ -2349,7 +2349,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio
|
||||
"void Foo::bar() {}\n";
|
||||
|
||||
InsertDefFromDecl factory;
|
||||
QuickFixOperationTest(singleDocument(original, ""), &factory, ProjectPartHeaderPaths(), 1);
|
||||
QuickFixOperationTest(singleDocument(original, ""), &factory, ProjectExplorer::HeaderPaths(), 1);
|
||||
}
|
||||
|
||||
/// Find right implementation file.
|
||||
@@ -2813,7 +2813,7 @@ void insertToSectionDeclFromDef(const QByteArray §ion, int sectionIndex)
|
||||
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||
|
||||
InsertDeclFromDef factory;
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), sectionIndex);
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), sectionIndex);
|
||||
}
|
||||
|
||||
/// Check from source file: Insert in header file.
|
||||
@@ -3672,9 +3672,8 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_noDoubleQtH
|
||||
original = expected = "@QDir dir;\n";
|
||||
testDocuments << QuickFixTestDocument::create(base + "/fileWantsToUseQDir.cpp", original, expected);
|
||||
|
||||
ProjectPartHeaderPaths headerPaths;
|
||||
headerPaths += ProjectPartHeaderPath(TestIncludePaths::globalQtCoreIncludePath(),
|
||||
ProjectPartHeaderPath::IncludePath);
|
||||
ProjectExplorer::HeaderPaths headerPaths{{TestIncludePaths::globalQtCoreIncludePath(),
|
||||
ProjectExplorer::IncludePathType::User}};
|
||||
|
||||
AddIncludeForUndefinedIdentifier factory;
|
||||
const QStringList expectedOperations = QStringList("Add #include <QDir>");
|
||||
@@ -3842,7 +3841,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside2()
|
||||
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||
|
||||
MoveFuncDefOutside factory;
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1);
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 1);
|
||||
}
|
||||
|
||||
/// 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);
|
||||
|
||||
MoveFuncDefOutside factory;
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1);
|
||||
QuickFixOperationTest(testDocuments, &factory, ProjectExplorer::HeaderPaths(), 1);
|
||||
}
|
||||
|
||||
/// Check if whitespace is respected for operator functions
|
||||
@@ -4224,7 +4223,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_macroUses()
|
||||
|
||||
MoveFuncDefOutside factory;
|
||||
QuickFixOperationTest(singleDocument(original, expected), &factory,
|
||||
ProjectPartHeaderPaths(), 0, "QTCREATORBUG-12314");
|
||||
ProjectExplorer::HeaderPaths(), 0, "QTCREATORBUG-12314");
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_template()
|
||||
@@ -4575,7 +4574,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_macroUses()
|
||||
|
||||
MoveFuncDefToDecl factory;
|
||||
QuickFixOperationTest(singleDocument(original, expected), &factory,
|
||||
ProjectPartHeaderPaths(), 0, "QTCREATORBUG-12314");
|
||||
ProjectExplorer::HeaderPaths(), 0, "QTCREATORBUG-12314");
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_override()
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppquickfix.h"
|
||||
|
||||
#include <cpptools/projectpartheaderpath.h>
|
||||
#include <projectexplorer/headerpath.h>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QList>
|
||||
@@ -76,8 +77,8 @@ public:
|
||||
/// Exactly one QuickFixTestDocument must contain the cursor position marker '@'
|
||||
/// or "@{start}" and "@{end}"
|
||||
BaseQuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||
const CppTools::ProjectPartHeaderPaths &headerPaths
|
||||
= CppTools::ProjectPartHeaderPaths());
|
||||
const ProjectExplorer::HeaderPaths &headerPaths
|
||||
= ProjectExplorer::HeaderPaths());
|
||||
|
||||
~BaseQuickFixTestCase();
|
||||
|
||||
@@ -91,7 +92,7 @@ private:
|
||||
CppTools::CppCodeStylePreferences *m_cppCodeStylePreferences;
|
||||
QByteArray m_cppCodeStylePreferencesOriginalDelegateId;
|
||||
|
||||
CppTools::ProjectPartHeaderPaths m_headerPathsToRestore;
|
||||
ProjectExplorer::HeaderPaths m_headerPathsToRestore;
|
||||
bool m_restoreHeaderPaths;
|
||||
};
|
||||
|
||||
@@ -101,8 +102,8 @@ class QuickFixOperationTest : public BaseQuickFixTestCase
|
||||
public:
|
||||
QuickFixOperationTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||
CppQuickFixFactory *factory,
|
||||
const CppTools::ProjectPartHeaderPaths &headerPaths
|
||||
= CppTools::ProjectPartHeaderPaths(),
|
||||
const ProjectExplorer::HeaderPaths &headerPaths
|
||||
= ProjectExplorer::HeaderPaths(),
|
||||
int operationIndex = 0,
|
||||
const QByteArray &expectedFailMessage = QByteArray());
|
||||
|
||||
@@ -118,8 +119,8 @@ class QuickFixOfferedOperationsTest : public BaseQuickFixTestCase
|
||||
public:
|
||||
QuickFixOfferedOperationsTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||
CppQuickFixFactory *factory,
|
||||
const CppTools::ProjectPartHeaderPaths &headerPaths
|
||||
= CppTools::ProjectPartHeaderPaths(),
|
||||
const ProjectExplorer::HeaderPaths &headerPaths
|
||||
= ProjectExplorer::HeaderPaths(),
|
||||
const QStringList &expectedOperations = QStringList());
|
||||
};
|
||||
|
||||
|
||||
@@ -1740,7 +1740,7 @@ namespace {
|
||||
|
||||
QString findShortestInclude(const QString currentDocumentFilePath,
|
||||
const QString candidateFilePath,
|
||||
const ProjectPartHeaderPaths &headerPaths)
|
||||
const ProjectExplorer::HeaderPaths &headerPaths)
|
||||
{
|
||||
QString result;
|
||||
|
||||
@@ -1749,7 +1749,7 @@ QString findShortestInclude(const QString currentDocumentFilePath,
|
||||
if (fileInfo.path() == QFileInfo(currentDocumentFilePath).path()) {
|
||||
result = QLatin1Char('"') + fileInfo.fileName() + QLatin1Char('"');
|
||||
} else {
|
||||
foreach (const ProjectPartHeaderPath &headerPath, headerPaths) {
|
||||
foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
|
||||
if (!candidateFilePath.startsWith(headerPath.path))
|
||||
continue;
|
||||
QString relativePath = candidateFilePath.mid(headerPath.path.size());
|
||||
@@ -1764,12 +1764,12 @@ QString findShortestInclude(const QString currentDocumentFilePath,
|
||||
}
|
||||
|
||||
QString findQtIncludeWithSameName(const QString &className,
|
||||
const ProjectPartHeaderPaths &headerPaths)
|
||||
const ProjectExplorer::HeaderPaths &headerPaths)
|
||||
{
|
||||
QString result;
|
||||
|
||||
// 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...
|
||||
continue;
|
||||
|
||||
@@ -1784,9 +1784,9 @@ QString findQtIncludeWithSameName(const QString &className,
|
||||
return result;
|
||||
}
|
||||
|
||||
ProjectPartHeaderPaths relevantHeaderPaths(const QString &filePath)
|
||||
ProjectExplorer::HeaderPaths relevantHeaderPaths(const QString &filePath)
|
||||
{
|
||||
ProjectPartHeaderPaths headerPaths;
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
|
||||
CppModelManager *modelManager = CppModelManager::instance();
|
||||
const QList<ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
|
||||
@@ -1931,7 +1931,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
|
||||
QString className;
|
||||
QList<Core::LocatorFilterEntry> matches;
|
||||
const QString currentDocumentFilePath = interface.semanticInfo().doc->fileName();
|
||||
const ProjectPartHeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath);
|
||||
const ProjectExplorer::HeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath);
|
||||
bool qtHeaderFileIncludeOffered = false;
|
||||
|
||||
// Find an include file through the locator
|
||||
|
||||
@@ -73,7 +73,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
||||
|
||||
CppModelManager *modelManager = CppModelManager::instance();
|
||||
QByteArray configFile = modelManager->codeModelConfiguration();
|
||||
ProjectPartHeaderPaths headerPaths;
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
QStringList precompiledHeaders;
|
||||
QString projectConfigFile;
|
||||
LanguageFeatures features = LanguageFeatures::defaultFeatures();
|
||||
@@ -245,7 +245,7 @@ Snapshot BuiltinEditorDocumentParser::snapshot() const
|
||||
return extraState().snapshot;
|
||||
}
|
||||
|
||||
ProjectPartHeaderPaths BuiltinEditorDocumentParser::headerPaths() const
|
||||
ProjectExplorer::HeaderPaths BuiltinEditorDocumentParser::headerPaths() const
|
||||
{
|
||||
return extraState().headerPaths;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
|
||||
CPlusPlus::Document::Ptr document() const;
|
||||
CPlusPlus::Snapshot snapshot() const;
|
||||
ProjectPartHeaderPaths headerPaths() const;
|
||||
ProjectExplorer::HeaderPaths headerPaths() const;
|
||||
|
||||
void releaseResources();
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
struct ExtraState {
|
||||
QByteArray configFile;
|
||||
|
||||
ProjectPartHeaderPaths headerPaths;
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
QString projectConfigFile;
|
||||
QStringList precompiledHeaders;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace {
|
||||
class ParseParams
|
||||
{
|
||||
public:
|
||||
ProjectPartHeaderPaths headerPaths;
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
WorkingCopy workingCopy;
|
||||
QSet<QString> sourceFiles;
|
||||
int indexerFileSizeLimitInMb = -1;
|
||||
@@ -203,7 +203,7 @@ void index(QFutureInterface<void> &indexingFuture,
|
||||
bool processingHeaders = false;
|
||||
|
||||
CppModelManager *cmm = CppModelManager::instance();
|
||||
const ProjectPartHeaderPaths fallbackHeaderPaths = cmm->headerPaths();
|
||||
const ProjectExplorer::HeaderPaths fallbackHeaderPaths = cmm->headerPaths();
|
||||
const CPlusPlus::LanguageFeatures defaultFeatures =
|
||||
CPlusPlus::LanguageFeatures::defaultFeatures();
|
||||
for (int i = 0; i < files.size(); ++i) {
|
||||
@@ -226,7 +226,7 @@ void index(QFutureInterface<void> &indexingFuture,
|
||||
processingHeaders = true;
|
||||
}
|
||||
|
||||
ProjectPartHeaderPaths headerPaths = parts.isEmpty()
|
||||
ProjectExplorer::HeaderPaths headerPaths = parts.isEmpty()
|
||||
? fallbackHeaderPaths
|
||||
: parts.first()->headerPaths;
|
||||
sourceProcessor->setHeaderPaths(headerPaths);
|
||||
|
||||
@@ -198,11 +198,11 @@ void CompilerOptionsBuilder::enableExceptions()
|
||||
|
||||
void CompilerOptionsBuilder::addHeaderPathOptions()
|
||||
{
|
||||
typedef ProjectPartHeaderPath HeaderPath;
|
||||
using ProjectExplorer::IncludePathType;
|
||||
|
||||
QStringList result;
|
||||
|
||||
foreach (const HeaderPath &headerPath , m_projectPart.headerPaths) {
|
||||
for (const ProjectExplorer::HeaderPath &headerPath : qAsConst(m_projectPart.headerPaths)) {
|
||||
if (headerPath.path.isEmpty())
|
||||
continue;
|
||||
|
||||
@@ -212,12 +212,15 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
|
||||
QString prefix;
|
||||
Utils::FileName path;
|
||||
switch (headerPath.type) {
|
||||
case HeaderPath::FrameworkPath:
|
||||
case IncludePathType::Framework:
|
||||
prefix = QLatin1String("-F");
|
||||
break;
|
||||
case IncludePathType::System:
|
||||
prefix = "-isystem";
|
||||
break;
|
||||
default: // This shouldn't happen, but let's be nice..:
|
||||
// intentional fall-through:
|
||||
case HeaderPath::IncludePath:
|
||||
case IncludePathType::User:
|
||||
prefix = includeDirOptionForPath(headerPath.path);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -89,13 +89,14 @@ QString Utils::toString(CPlusPlus::Document::DiagnosticMessage::Level level)
|
||||
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) {
|
||||
CASE_LANGUAGEVERSION(InvalidPath);
|
||||
CASE_LANGUAGEVERSION(IncludePath);
|
||||
CASE_LANGUAGEVERSION(FrameworkPath);
|
||||
CASE_LANGUAGEVERSION(Invalid);
|
||||
CASE_LANGUAGEVERSION(User);
|
||||
CASE_LANGUAGEVERSION(System);
|
||||
CASE_LANGUAGEVERSION(Framework);
|
||||
// no default to get a compiler warning if anything is added
|
||||
}
|
||||
#undef CASE_LANGUAGEVERSION
|
||||
@@ -409,14 +410,12 @@ QString Utils::pathListToString(const QStringList &pathList)
|
||||
return result.join(QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
QString Utils::pathListToString(const ProjectPartHeaderPaths &pathList)
|
||||
QString Utils::pathListToString(const ProjectExplorer::HeaderPaths &pathList)
|
||||
{
|
||||
QStringList result;
|
||||
foreach (const ProjectPartHeaderPath &path, pathList) {
|
||||
foreach (const ProjectExplorer::HeaderPath &path, pathList) {
|
||||
result << QString(QLatin1String("%1 (%2 path)")).arg(
|
||||
QDir::toNativeSeparators(path.path),
|
||||
path.isFrameworkPath() ? QLatin1String("framework") : QLatin1String("include")
|
||||
);
|
||||
QDir::toNativeSeparators(path.path), toString(path.type));
|
||||
}
|
||||
return result.join(QLatin1Char('\n'));
|
||||
}
|
||||
@@ -467,6 +466,17 @@ Dumper::~Dumper()
|
||||
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)
|
||||
{
|
||||
const QByteArray i1 = indent(1);
|
||||
@@ -526,12 +536,11 @@ void Dumper::dumpProjectInfos( const QList<ProjectInfo> &projectInfos)
|
||||
|
||||
if (!part->headerPaths.isEmpty()) {
|
||||
m_out << i3 << "Header Paths:{{{4\n";
|
||||
foreach (const ProjectPartHeaderPath &headerPath, part->headerPaths)
|
||||
m_out << i4 << headerPath.path
|
||||
<< (headerPath.type == ProjectPartHeaderPath::IncludePath
|
||||
? "(include path)"
|
||||
: "(framework path)")
|
||||
<< "\n";
|
||||
foreach (const ProjectExplorer::HeaderPath &headerPath, part->headerPaths) {
|
||||
m_out << i4 << headerPath.path;
|
||||
printIncludeType(m_out, headerPath.type);
|
||||
m_out << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
m_out << "Merged Entities{{{1\n";
|
||||
@@ -601,10 +610,11 @@ void Dumper::dumpMergedEntities(const ProjectPartHeaderPaths &mergedHeaderPaths,
|
||||
const QByteArray i3 = indent(3);
|
||||
|
||||
m_out << i2 << "Merged Header Paths{{{2\n";
|
||||
foreach (const ProjectPartHeaderPath &hp, mergedHeaderPaths)
|
||||
m_out << i3 << hp.path
|
||||
<< (hp.isFrameworkPath() ? " (framework path)" : " (include path)")
|
||||
<< "\n";
|
||||
foreach (const ProjectExplorer::HeaderPath &hp, mergedHeaderPaths) {
|
||||
m_out << i3 << hp.path;
|
||||
printIncludeType(m_out, hp.type);
|
||||
m_out << "\n";
|
||||
}
|
||||
m_out << i2 << "Merged Defines{{{2\n";
|
||||
m_out << mergedMacros;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ struct CPPTOOLS_EXPORT Utils
|
||||
static QString toString(const QDateTime &dateTime);
|
||||
static QString toString(CPlusPlus::Document::CheckMode checkMode);
|
||||
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::LanguageExtensions languageExtension);
|
||||
static QString toString(CppTools::ProjectPart::QtVersion qtVersion);
|
||||
@@ -57,7 +57,7 @@ struct CPPTOOLS_EXPORT Utils
|
||||
static QString partsForFile(const QString &fileName);
|
||||
static QString unresolvedFileNameWithDelimiters(const CPlusPlus::Document::Include &include);
|
||||
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);
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
const QString &title,
|
||||
bool isGlobalSnapshot = false);
|
||||
void dumpWorkingCopy(const CppTools::WorkingCopy &workingCopy);
|
||||
void dumpMergedEntities(const ProjectPartHeaderPaths &mergedHeaderPaths,
|
||||
void dumpMergedEntities(const ProjectExplorer::HeaderPaths &mergedHeaderPaths,
|
||||
const QByteArray &mergedMacros);
|
||||
|
||||
private:
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
= new CppCompletionAssistInterface(m_editorWidget->textDocument()->filePath().toString(),
|
||||
m_textDocument, m_position,
|
||||
ExplicitlyInvoked, m_snapshot,
|
||||
ProjectPartHeaderPaths(),
|
||||
ProjectExplorer::HeaderPaths(),
|
||||
languageFeatures);
|
||||
ai->prepareForAsyncUse();
|
||||
ai->recreateTextDocument();
|
||||
|
||||
@@ -1258,15 +1258,15 @@ bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cu
|
||||
}
|
||||
|
||||
// Make completion for all relevant includes
|
||||
ProjectPartHeaderPaths headerPaths = m_interface->headerPaths();
|
||||
const ProjectPartHeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
|
||||
ProjectPartHeaderPath::IncludePath);
|
||||
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
|
||||
const ProjectExplorer::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
|
||||
ProjectExplorer::IncludePathType::User);
|
||||
if (!headerPaths.contains(currentFilePath))
|
||||
headerPaths.append(currentFilePath);
|
||||
|
||||
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;
|
||||
if (!directoryPrefix.isEmpty()) {
|
||||
realPath += QLatin1Char('/');
|
||||
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
int position,
|
||||
TextEditor::AssistReason reason,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const ProjectPartHeaderPaths &headerPaths,
|
||||
const ProjectExplorer::HeaderPaths &headerPaths,
|
||||
const CPlusPlus::LanguageFeatures &features)
|
||||
: TextEditor::AssistInterface(textDocument, position, filePath, reason)
|
||||
, m_gotCppSpecifics(true)
|
||||
@@ -195,7 +195,7 @@ public:
|
||||
{}
|
||||
|
||||
const CPlusPlus::Snapshot &snapshot() const { getCppSpecifics(); return m_snapshot; }
|
||||
const ProjectPartHeaderPaths &headerPaths() const
|
||||
const ProjectExplorer::HeaderPaths &headerPaths() const
|
||||
{ getCppSpecifics(); return m_headerPaths; }
|
||||
CPlusPlus::LanguageFeatures languageFeatures() const
|
||||
{ getCppSpecifics(); return m_languageFeatures; }
|
||||
@@ -207,7 +207,7 @@ private:
|
||||
mutable bool m_gotCppSpecifics;
|
||||
WorkingCopy m_workingCopy;
|
||||
mutable CPlusPlus::Snapshot m_snapshot;
|
||||
mutable ProjectPartHeaderPaths m_headerPaths;
|
||||
mutable ProjectExplorer::HeaderPaths m_headerPaths;
|
||||
mutable CPlusPlus::LanguageFeatures m_languageFeatures;
|
||||
};
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
// The members below are cached/(re)calculated from the projects and/or their project parts
|
||||
bool m_dirty;
|
||||
QStringList m_projectFiles;
|
||||
ProjectPartHeaderPaths m_headerPaths;
|
||||
ProjectExplorer::HeaderPaths m_headerPaths;
|
||||
ProjectExplorer::Macros m_definedMacros;
|
||||
|
||||
// Editor integration
|
||||
@@ -615,18 +615,18 @@ QStringList CppModelManager::internalProjectFiles() const
|
||||
return files;
|
||||
}
|
||||
|
||||
ProjectPartHeaderPaths CppModelManager::internalHeaderPaths() const
|
||||
ProjectExplorer::HeaderPaths CppModelManager::internalHeaderPaths() const
|
||||
{
|
||||
ProjectPartHeaderPaths headerPaths;
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(d->m_projectToProjectsInfo);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
const ProjectInfo pinfo = it.value();
|
||||
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
|
||||
foreach (const ProjectPartHeaderPath &path, part->headerPaths) {
|
||||
const ProjectPartHeaderPath hp(QDir::cleanPath(path.path), path.type);
|
||||
foreach (const ProjectExplorer::HeaderPath &path, part->headerPaths) {
|
||||
ProjectExplorer::HeaderPath hp(QDir::cleanPath(path.path), path.type);
|
||||
if (!headerPaths.contains(hp))
|
||||
headerPaths += hp;
|
||||
headerPaths.push_back(std::move(hp));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1433,7 +1433,7 @@ QStringList CppModelManager::projectFiles()
|
||||
return d->m_projectFiles;
|
||||
}
|
||||
|
||||
ProjectPartHeaderPaths CppModelManager::headerPaths()
|
||||
ProjectExplorer::HeaderPaths CppModelManager::headerPaths()
|
||||
{
|
||||
QMutexLocker locker(&d->m_projectMutex);
|
||||
ensureUpdated();
|
||||
@@ -1441,7 +1441,7 @@ ProjectPartHeaderPaths CppModelManager::headerPaths()
|
||||
return d->m_headerPaths;
|
||||
}
|
||||
|
||||
void CppModelManager::setHeaderPaths(const ProjectPartHeaderPaths &headerPaths)
|
||||
void CppModelManager::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths)
|
||||
{
|
||||
QMutexLocker locker(&d->m_projectMutex);
|
||||
d->m_headerPaths = headerPaths;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "refactoringengineinterface.h"
|
||||
#include "projectinfo.h"
|
||||
#include "projectpart.h"
|
||||
#include "projectpartheaderpath.h"
|
||||
#include <projectexplorer/headerpath.h>
|
||||
|
||||
#include <cplusplus/cppmodelmanagerbase.h>
|
||||
#include <coreplugin/find/ifindfilter.h>
|
||||
@@ -189,10 +189,10 @@ public:
|
||||
|
||||
QStringList projectFiles();
|
||||
|
||||
ProjectPartHeaderPaths headerPaths();
|
||||
ProjectExplorer::HeaderPaths headerPaths();
|
||||
|
||||
// Use this *only* for auto tests
|
||||
void setHeaderPaths(const ProjectPartHeaderPaths &headerPaths);
|
||||
void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths);
|
||||
|
||||
ProjectExplorer::Macros definedMacros();
|
||||
|
||||
@@ -274,7 +274,7 @@ private:
|
||||
|
||||
void ensureUpdated();
|
||||
QStringList internalProjectFiles() const;
|
||||
ProjectPartHeaderPaths internalHeaderPaths() const;
|
||||
ProjectExplorer::HeaderPaths internalHeaderPaths() const;
|
||||
ProjectExplorer::Macros internalDefinedMacros() const;
|
||||
|
||||
void dumpModelManagerConfiguration(const QString &logFileId);
|
||||
|
||||
@@ -183,22 +183,19 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
|
||||
Project *project = helper.createProject(_("test_modelmanager_paths_are_clean"));
|
||||
ProjectInfo pi = ProjectInfo(project);
|
||||
|
||||
typedef ProjectPartHeaderPath HeaderPath;
|
||||
|
||||
ProjectPart::Ptr part(new ProjectPart);
|
||||
part->qtVersion = ProjectPart::Qt5;
|
||||
part->projectMacros = {ProjectExplorer::Macro("OH_BEHAVE", "-1")};
|
||||
part->headerPaths = {HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath),
|
||||
HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath)};
|
||||
part->headerPaths = {{testDataDir.includeDir(false), IncludePathType::User},
|
||||
{testDataDir.frameworksDir(false), IncludePathType::Framework}};
|
||||
pi.appendProjectPart(part);
|
||||
|
||||
mm->updateProjectInfo(pi);
|
||||
|
||||
ProjectPartHeaderPaths headerPaths = mm->headerPaths();
|
||||
ProjectExplorer::HeaderPaths headerPaths = mm->headerPaths();
|
||||
QCOMPARE(headerPaths.size(), 2);
|
||||
QVERIFY(headerPaths.contains(HeaderPath(testDataDir.includeDir(), HeaderPath::IncludePath)));
|
||||
QVERIFY(headerPaths.contains(HeaderPath(testDataDir.frameworksDir(),
|
||||
HeaderPath::FrameworkPath)));
|
||||
QVERIFY(headerPaths.contains({testDataDir.includeDir(), IncludePathType::User}));
|
||||
QVERIFY(headerPaths.contains({testDataDir.frameworksDir(), IncludePathType::Framework}));
|
||||
}
|
||||
|
||||
/// Check: Frameworks headers are resolved.
|
||||
@@ -215,13 +212,11 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
|
||||
Project *project = helper.createProject(_("test_modelmanager_framework_headers"));
|
||||
ProjectInfo pi = ProjectInfo(project);
|
||||
|
||||
typedef ProjectPartHeaderPath HeaderPath;
|
||||
|
||||
ProjectPart::Ptr part(new ProjectPart);
|
||||
part->qtVersion = ProjectPart::Qt5;
|
||||
part->projectMacros = {{"OH_BEHAVE", "-1"}};
|
||||
part->headerPaths = {HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath),
|
||||
HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath)};
|
||||
part->headerPaths = {{testDataDir.includeDir(false), IncludePathType::User},
|
||||
{testDataDir.frameworksDir(false), IncludePathType::Framework}};
|
||||
const QString &source = testDataDir.fileFromSourcesDir(
|
||||
_("test_modelmanager_framework_headers.cpp"));
|
||||
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"));
|
||||
ProjectInfo pi = ProjectInfo(project);
|
||||
|
||||
typedef ProjectPartHeaderPath HeaderPath;
|
||||
|
||||
ProjectPart::Ptr part(new ProjectPart);
|
||||
part->qtVersion = ProjectPart::Qt5;
|
||||
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));
|
||||
pi.appendProjectPart(part);
|
||||
|
||||
@@ -755,15 +748,13 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
|
||||
|
||||
Project *project = helper.createProject(_("test_modelmanager_defines_per_project"));
|
||||
|
||||
typedef ProjectPartHeaderPath HeaderPath;
|
||||
|
||||
ProjectPart::Ptr part1(new ProjectPart);
|
||||
part1->projectFile = QLatin1String("project1.projectfile");
|
||||
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
|
||||
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
|
||||
part1->qtVersion = ProjectPart::NoQt;
|
||||
part1->projectMacros = {{"SUB1"}};
|
||||
part1->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)};
|
||||
part1->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
|
||||
|
||||
ProjectPart::Ptr part2(new ProjectPart);
|
||||
part2->projectFile = QLatin1String("project1.projectfile");
|
||||
@@ -771,7 +762,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
|
||||
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
|
||||
part2->qtVersion = ProjectPart::NoQt;
|
||||
part2->projectMacros = {{"SUB2"}};
|
||||
part2->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)};
|
||||
part2->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
|
||||
|
||||
ProjectInfo pi = ProjectInfo(project);
|
||||
pi.appendProjectPart(part1);
|
||||
@@ -821,15 +812,13 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
|
||||
|
||||
Project *project = helper.createProject(_("test_modelmanager_defines_per_project_pch"));
|
||||
|
||||
typedef ProjectPartHeaderPath HeaderPath;
|
||||
|
||||
ProjectPart::Ptr part1(new ProjectPart);
|
||||
part1->projectFile = QLatin1String("project1.projectfile");
|
||||
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
|
||||
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
|
||||
part1->qtVersion = ProjectPart::NoQt;
|
||||
part1->precompiledHeaders.append(pch1File);
|
||||
part1->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)};
|
||||
part1->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
|
||||
part1->updateLanguageFeatures();
|
||||
|
||||
ProjectPart::Ptr part2(new ProjectPart);
|
||||
@@ -838,7 +827,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
|
||||
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
|
||||
part2->qtVersion = ProjectPart::NoQt;
|
||||
part2->precompiledHeaders.append(pch2File);
|
||||
part2->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)};
|
||||
part2->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
|
||||
part2->updateLanguageFeatures();
|
||||
|
||||
ProjectInfo pi = ProjectInfo(project);
|
||||
@@ -906,19 +895,17 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
|
||||
|
||||
Project *project = helper.createProject(_("test_modelmanager_defines_per_editor"));
|
||||
|
||||
typedef ProjectPartHeaderPath HeaderPath;
|
||||
|
||||
ProjectPart::Ptr part1(new ProjectPart);
|
||||
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
|
||||
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
|
||||
part1->qtVersion = ProjectPart::NoQt;
|
||||
part1->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)};
|
||||
part1->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
|
||||
|
||||
ProjectPart::Ptr part2(new ProjectPart);
|
||||
part2->files.append(ProjectFile(main2File, ProjectFile::CXXSource));
|
||||
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
|
||||
part2->qtVersion = ProjectPart::NoQt;
|
||||
part2->headerPaths = {HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath)};
|
||||
part2->headerPaths = {{testDataDirectory.includeDir(false), IncludePathType::User}};
|
||||
|
||||
ProjectInfo pi = ProjectInfo(project);
|
||||
pi.appendProjectPart(part1);
|
||||
|
||||
@@ -111,17 +111,6 @@ private:
|
||||
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()
|
||||
{
|
||||
if (!m_tcInfo.headerPathsRunner)
|
||||
@@ -131,9 +120,9 @@ private:
|
||||
= m_tcInfo.headerPathsRunner(m_flags.commandLineFlags,
|
||||
m_tcInfo.sysRootPath);
|
||||
|
||||
ProjectPartHeaderPaths &headerPaths = m_projectPart.headerPaths;
|
||||
ProjectExplorer::HeaderPaths &headerPaths = m_projectPart.headerPaths;
|
||||
for (const ProjectExplorer::HeaderPath &header : systemHeaderPaths) {
|
||||
const ProjectPartHeaderPath headerPath = toProjectPartHeaderPath(header);
|
||||
const ProjectExplorer::HeaderPath headerPath{header.path, header.type};
|
||||
if (!headerPaths.contains(headerPath))
|
||||
headerPaths.push_back(headerPath);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ void RawProjectPart::setMacros(const ProjectExplorer::Macros ¯os)
|
||||
this->projectMacros = macros;
|
||||
}
|
||||
|
||||
void RawProjectPart::setHeaderPaths(const ProjectPartHeaderPaths &headerPaths)
|
||||
void RawProjectPart::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths)
|
||||
{
|
||||
this->headerPaths = headerPaths;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ void RawProjectPart::setIncludePaths(const QStringList &includePaths)
|
||||
headerPaths.clear();
|
||||
|
||||
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
|
||||
// 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"))) {
|
||||
const int slashIdx = includeFile.lastIndexOf(QLatin1Char('/'));
|
||||
if (slashIdx != -1) {
|
||||
hp = ProjectPartHeaderPath(includeFile.left(slashIdx),
|
||||
ProjectPartHeaderPath::FrameworkPath);
|
||||
hp = {includeFile.left(slashIdx), ProjectExplorer::IncludePathType::Framework};
|
||||
}
|
||||
}
|
||||
|
||||
headerPaths += hp;
|
||||
headerPaths.push_back(std::move(hp));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
void setQtVersion(ProjectPart::QtVersion qtVersion);
|
||||
|
||||
void setMacros(const ProjectExplorer::Macros ¯os);
|
||||
void setHeaderPaths(const ProjectPartHeaderPaths &headerPaths);
|
||||
void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths);
|
||||
void setIncludePaths(const QStringList &includePaths);
|
||||
|
||||
void setPreCompiledHeaders(const QStringList &preCompiledHeaders);
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
QString callGroupId;
|
||||
QString buildSystemTarget;
|
||||
QStringList precompiledHeaders;
|
||||
ProjectPartHeaderPaths headerPaths;
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
ProjectExplorer::Macros projectMacros;
|
||||
ProjectPart::QtVersion qtVersion = ProjectPart::UnknownQt;
|
||||
bool selectedForBuilding = true;
|
||||
|
||||
@@ -130,15 +130,16 @@ void CppSourceProcessor::setCancelChecker(const CppSourceProcessor::CancelChecke
|
||||
void CppSourceProcessor::setWorkingCopy(const WorkingCopy &workingCopy)
|
||||
{ m_workingCopy = workingCopy; }
|
||||
|
||||
void CppSourceProcessor::setHeaderPaths(const ProjectPartHeaderPaths &headerPaths)
|
||||
void CppSourceProcessor::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths)
|
||||
{
|
||||
using ProjectExplorer::IncludePathType;
|
||||
m_headerPaths.clear();
|
||||
|
||||
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)
|
||||
m_headerPaths.append(ProjectPartHeaderPath(cleanPath(path.path), path.type));
|
||||
if (path.type == IncludePathType::User || path.type == IncludePathType::System)
|
||||
m_headerPaths.append({cleanPath(path.path), path.type});
|
||||
else
|
||||
addFrameworkPath(path);
|
||||
}
|
||||
@@ -156,15 +157,15 @@ void CppSourceProcessor::setLanguageFeatures(const LanguageFeatures languageFeat
|
||||
// has private frameworks in:
|
||||
// <framework-path>/ApplicationServices.framework/Frameworks
|
||||
// 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);
|
||||
|
||||
// The algorithm below is a bit too eager, but that's because we're not getting
|
||||
// in the frameworks we're linking against. If we would have that, then we could
|
||||
// add only those private frameworks.
|
||||
const ProjectPartHeaderPath cleanFrameworkPath(cleanPath(frameworkPath.path),
|
||||
frameworkPath.type);
|
||||
const ProjectExplorer::HeaderPath cleanFrameworkPath(cleanPath(frameworkPath.path),
|
||||
ProjectExplorer::IncludePathType::Framework);
|
||||
if (!m_headerPaths.contains(cleanFrameworkPath))
|
||||
m_headerPaths.append(cleanFrameworkPath);
|
||||
|
||||
@@ -176,8 +177,8 @@ void CppSourceProcessor::addFrameworkPath(const ProjectPartHeaderPath &framework
|
||||
const QFileInfo privateFrameworks(framework.absoluteFilePath(),
|
||||
QLatin1String("Frameworks"));
|
||||
if (privateFrameworks.exists() && privateFrameworks.isDir())
|
||||
addFrameworkPath(ProjectPartHeaderPath(privateFrameworks.absoluteFilePath(),
|
||||
frameworkPath.type));
|
||||
addFrameworkPath({privateFrameworks.absoluteFilePath(),
|
||||
ProjectExplorer::IncludePathType::Framework});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +296,7 @@ QString CppSourceProcessor::resolveFile(const QString &fileName, IncludeType typ
|
||||
}
|
||||
|
||||
QString CppSourceProcessor::resolveFile_helper(const QString &fileName,
|
||||
ProjectPartHeaderPaths::Iterator headerPathsIt)
|
||||
ProjectExplorer::HeaderPaths::Iterator headerPathsIt)
|
||||
{
|
||||
auto headerPathsEnd = m_headerPaths.end();
|
||||
const int index = fileName.indexOf(QLatin1Char('/'));
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
void setCancelChecker(const CancelChecker &cancelChecker);
|
||||
|
||||
void setWorkingCopy(const CppTools::WorkingCopy &workingCopy);
|
||||
void setHeaderPaths(const ProjectPartHeaderPaths &headerPaths);
|
||||
void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths);
|
||||
void setLanguageFeatures(CPlusPlus::LanguageFeatures languageFeatures);
|
||||
void setFileSizeLimitInMb(int fileSizeLimitInMb);
|
||||
void setTodo(const QSet<QString> &files);
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
void setGlobalSnapshot(const CPlusPlus::Snapshot &snapshot) { m_globalSnapshot = snapshot; }
|
||||
|
||||
private:
|
||||
void addFrameworkPath(const ProjectPartHeaderPath &frameworkPath);
|
||||
void addFrameworkPath(const ProjectExplorer::HeaderPath &frameworkPath);
|
||||
|
||||
CPlusPlus::Document::Ptr switchCurrentDocument(CPlusPlus::Document::Ptr doc);
|
||||
|
||||
@@ -87,7 +87,7 @@ private:
|
||||
bool checkFile(const QString &absoluteFilePath) const;
|
||||
QString resolveFile(const QString &fileName, IncludeType type);
|
||||
QString resolveFile_helper(const QString &fileName,
|
||||
ProjectPartHeaderPaths::Iterator headerPathsIt);
|
||||
ProjectExplorer::HeaderPaths::Iterator headerPathsIt);
|
||||
|
||||
void mergeEnvironment(CPlusPlus::Document::Ptr doc);
|
||||
|
||||
@@ -115,7 +115,7 @@ private:
|
||||
DocumentCallback m_documentFinished;
|
||||
CPlusPlus::Environment m_env;
|
||||
CPlusPlus::Preprocessor m_preprocess;
|
||||
ProjectPartHeaderPaths m_headerPaths;
|
||||
ProjectExplorer::HeaderPaths m_headerPaths;
|
||||
CPlusPlus::LanguageFeatures m_languageFeatures;
|
||||
CppTools::WorkingCopy m_workingCopy;
|
||||
QSet<QString> m_included;
|
||||
|
||||
@@ -47,6 +47,7 @@ using namespace CPlusPlus;
|
||||
using namespace CppTools;
|
||||
using namespace CppTools::Tests;
|
||||
using namespace CppTools::Internal;
|
||||
using ProjectExplorer::IncludePathType;
|
||||
|
||||
typedef Document::Include Include;
|
||||
|
||||
@@ -63,9 +64,9 @@ public:
|
||||
{
|
||||
QScopedPointer<CppSourceProcessor> sourceProcessor(
|
||||
CppModelManager::createSourceProcessor());
|
||||
const ProjectPartHeaderPath hp(TestIncludePaths::directoryOfTestFile(),
|
||||
ProjectPartHeaderPath::IncludePath);
|
||||
sourceProcessor->setHeaderPaths(ProjectPartHeaderPaths() << hp);
|
||||
const ProjectExplorer::HeaderPath hp(TestIncludePaths::directoryOfTestFile(),
|
||||
IncludePathType::User);
|
||||
sourceProcessor->setHeaderPaths({hp});
|
||||
sourceProcessor->run(filePath);
|
||||
|
||||
Document::Ptr document = m_cmm->document(filePath);
|
||||
@@ -207,9 +208,8 @@ void CppToolsPlugin::test_cppsourceprocessor_includeNext()
|
||||
|
||||
CppSourceProcessor::DocumentCallback documentCallback = [](const Document::Ptr &){};
|
||||
CppSourceProcessor sourceProcessor(Snapshot(), documentCallback);
|
||||
ProjectPartHeaderPaths headerPaths = ProjectPartHeaderPaths()
|
||||
<< ProjectPartHeaderPath(customHeaderPath, ProjectPartHeaderPath::IncludePath)
|
||||
<< ProjectPartHeaderPath(systemHeaderPath, ProjectPartHeaderPath::IncludePath);
|
||||
ProjectExplorer::HeaderPaths headerPaths = {{customHeaderPath, IncludePathType::User},
|
||||
{systemHeaderPath, IncludePathType::User}};
|
||||
sourceProcessor.setHeaderPaths(headerPaths);
|
||||
|
||||
sourceProcessor.run(mainFilePath);
|
||||
|
||||
@@ -90,7 +90,6 @@ HEADERS += \
|
||||
cpptoolsbridgeinterface.h \
|
||||
cpptoolsbridgeqtcreatorimplementation.h \
|
||||
projectpart.h \
|
||||
projectpartheaderpath.h \
|
||||
projectinfo.h \
|
||||
cppprojectinfogenerator.h \
|
||||
compileroptionsbuilder.h \
|
||||
|
||||
@@ -200,7 +200,6 @@ Project {
|
||||
"projectinfo.h",
|
||||
"projectpart.cpp",
|
||||
"projectpart.h",
|
||||
"projectpartheaderpath.h",
|
||||
"searchsymbols.cpp",
|
||||
"searchsymbols.h",
|
||||
"semantichighlighter.cpp",
|
||||
|
||||
@@ -534,10 +534,8 @@ static QList<Include> includesForSource(const QString &filePath)
|
||||
CppModelManager *cmm = CppModelManager::instance();
|
||||
cmm->GC();
|
||||
QScopedPointer<CppSourceProcessor> sourceProcessor(CppModelManager::createSourceProcessor());
|
||||
sourceProcessor->setHeaderPaths(ProjectPartHeaderPaths()
|
||||
<< ProjectPartHeaderPath(
|
||||
TestIncludePaths::globalIncludePath(),
|
||||
ProjectPartHeaderPath::IncludePath));
|
||||
sourceProcessor->setHeaderPaths({{TestIncludePaths::globalIncludePath(),
|
||||
ProjectExplorer::IncludePathType::User}});
|
||||
sourceProcessor->run(filePath);
|
||||
|
||||
Document::Ptr document = cmm->document(filePath);
|
||||
|
||||
@@ -128,11 +128,11 @@ void ProjectInfo::appendProjectPart(const ProjectPart::Ptr &projectPart)
|
||||
|
||||
void ProjectInfo::finish()
|
||||
{
|
||||
QSet<ProjectPartHeaderPath> uniqueHeaderPaths;
|
||||
QSet<ProjectExplorer::HeaderPath> uniqueHeaderPaths;
|
||||
|
||||
foreach (const ProjectPart::Ptr &part, m_projectParts) {
|
||||
// Update header paths
|
||||
foreach (const ProjectPartHeaderPath &headerPath, part->headerPaths) {
|
||||
foreach (const ProjectExplorer::HeaderPath &headerPath, part->headerPaths) {
|
||||
const int count = uniqueHeaderPaths.count();
|
||||
uniqueHeaderPaths.insert(headerPath);
|
||||
if (count < uniqueHeaderPaths.count())
|
||||
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
QVector<ProjectPart::Ptr> m_projectParts;
|
||||
|
||||
// The members below are (re)calculated from the project parts with finish()
|
||||
ProjectPartHeaderPaths m_headerPaths;
|
||||
ProjectExplorer::HeaderPaths m_headerPaths;
|
||||
QSet<QString> m_sourceFiles;
|
||||
ProjectExplorer::Macros m_defines;
|
||||
};
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include "cppprojectfile.h"
|
||||
#include "projectpartheaderpath.h"
|
||||
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/projectexplorer_global.h>
|
||||
#include <projectexplorer/projectmacro.h>
|
||||
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
ProjectFiles files;
|
||||
|
||||
QStringList precompiledHeaders;
|
||||
ProjectPartHeaderPaths headerPaths;
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
|
||||
ProjectExplorer::Macros projectMacros;
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -219,7 +219,7 @@ ToolChain::SystemHeaderPathsRunner AbstractMsvcToolChain::createSystemHeaderPath
|
||||
QMutexLocker locker(m_headerPathsMutex);
|
||||
if (m_headerPaths.isEmpty()) {
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -174,8 +174,9 @@ ToolChain::SystemHeaderPathsRunner CustomToolChain::createSystemHeaderPathsRunne
|
||||
return [systemHeaderPaths](const QStringList &cxxFlags, const QString &) {
|
||||
QList<HeaderPath> flagHeaderPaths;
|
||||
for (const QString &cxxFlag : cxxFlags) {
|
||||
if (cxxFlag.startsWith(QLatin1String("-I")))
|
||||
flagHeaderPaths << HeaderPath(cxxFlag.mid(2).trimmed(), HeaderPath::GlobalHeaderPath);
|
||||
if (cxxFlag.startsWith(QLatin1String("-I"))) {
|
||||
flagHeaderPaths.push_back({cxxFlag.mid(2).trimmed(), IncludePathType::System});
|
||||
}
|
||||
}
|
||||
|
||||
return systemHeaderPaths + flagHeaderPaths;
|
||||
@@ -227,7 +228,7 @@ QStringList CustomToolChain::headerPathsList() const
|
||||
void CustomToolChain::setHeaderPaths(const QStringList &list)
|
||||
{
|
||||
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)
|
||||
|
||||
@@ -151,24 +151,24 @@ QList<HeaderPath> GccToolChain::gccHeaderPaths(const FileName &gcc, const QStrin
|
||||
}
|
||||
|
||||
if (!line.isEmpty() && line.startsWith("#include")) {
|
||||
HeaderPath::Kind kind = HeaderPath::UserHeaderPath;
|
||||
auto kind = IncludePathType::User;
|
||||
while (cpp.canReadLine()) {
|
||||
line = cpp.readLine();
|
||||
if (line.startsWith("#include")) {
|
||||
kind = HeaderPath::GlobalHeaderPath;
|
||||
kind = IncludePathType::System;
|
||||
} else if (! line.isEmpty() && QChar(line.at(0)).isSpace()) {
|
||||
HeaderPath::Kind thisHeaderKind = kind;
|
||||
IncludePathType thisHeaderKind = kind;
|
||||
|
||||
line = line.trimmed();
|
||||
|
||||
const int index = line.indexOf(" (framework directory)");
|
||||
if (index != -1) {
|
||||
line.truncate(index);
|
||||
thisHeaderKind = HeaderPath::FrameworkHeaderPath;
|
||||
thisHeaderKind = IncludePathType::Framework;
|
||||
}
|
||||
|
||||
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.")) {
|
||||
break;
|
||||
} else {
|
||||
@@ -657,7 +657,7 @@ ToolChain::SystemHeaderPathsRunner GccToolChain::createSystemHeaderPathsRunner()
|
||||
qCDebug(gccLog) << compilerCommand.toUserOutput()
|
||||
<< (languageId == Constants::CXX_LANGUAGE_ID ? ": C++ [" : ": C [")
|
||||
<< arguments.join(", ") << "]"
|
||||
<< hp.path();
|
||||
<< hp.path;
|
||||
}
|
||||
|
||||
return paths;
|
||||
|
||||
@@ -24,36 +24,55 @@
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include <QString>
|
||||
|
||||
#include "projectexplorer_export.h"
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
||||
class PROJECTEXPLORER_EXPORT HeaderPath
|
||||
enum class IncludePathType {
|
||||
Invalid,
|
||||
User,
|
||||
System,
|
||||
Framework
|
||||
};
|
||||
|
||||
class HeaderPath
|
||||
{
|
||||
public:
|
||||
enum Kind {
|
||||
GlobalHeaderPath,
|
||||
UserHeaderPath,
|
||||
FrameworkHeaderPath
|
||||
};
|
||||
|
||||
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; }
|
||||
Kind kind() const { return m_kind; }
|
||||
bool isValid() const
|
||||
{
|
||||
return type != IncludePathType::Invalid;
|
||||
}
|
||||
|
||||
bool isFrameworkPath() const
|
||||
{
|
||||
return type == IncludePathType::Framework;
|
||||
}
|
||||
|
||||
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:
|
||||
QString m_path;
|
||||
Kind m_kind = GlobalHeaderPath;
|
||||
bool operator!=(const HeaderPath &other) const
|
||||
{
|
||||
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
|
||||
|
||||
@@ -981,11 +981,9 @@ void QbsProject::updateCppCodeModel()
|
||||
list.append(props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
|
||||
QLatin1String(CONFIG_SYSTEM_INCLUDEPATHS)));
|
||||
list.removeDuplicates();
|
||||
CppTools::ProjectPartHeaderPaths grpHeaderPaths;
|
||||
ProjectExplorer::HeaderPaths grpHeaderPaths;
|
||||
foreach (const QString &p, list)
|
||||
grpHeaderPaths += CppTools::ProjectPartHeaderPath(
|
||||
FileName::fromUserInput(p).toString(),
|
||||
CppTools::ProjectPartHeaderPath::IncludePath);
|
||||
grpHeaderPaths += {FileName::fromUserInput(p).toString(), IncludePathType::User};
|
||||
|
||||
list = props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
|
||||
QLatin1String(CONFIG_FRAMEWORKPATHS));
|
||||
@@ -993,9 +991,7 @@ void QbsProject::updateCppCodeModel()
|
||||
QLatin1String(CONFIG_SYSTEM_FRAMEWORKPATHS)));
|
||||
list.removeDuplicates();
|
||||
foreach (const QString &p, list)
|
||||
grpHeaderPaths += CppTools::ProjectPartHeaderPath(
|
||||
FileName::fromUserInput(p).toString(),
|
||||
CppTools::ProjectPartHeaderPath::FrameworkPath);
|
||||
grpHeaderPaths += {FileName::fromUserInput(p).toString(), IncludePathType::Framework};
|
||||
|
||||
rpp.setHeaderPaths(grpHeaderPaths);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <cpptools/cpprawprojectpart.h>
|
||||
#include <cpptools/projectinfo.h>
|
||||
#include <cpptools/projectpartheaderpath.h>
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <cpptools/cppprojectupdater.h>
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
@@ -313,17 +313,15 @@ void QmakeProject::updateCppCodeModel()
|
||||
rpp.setQtVersion(ProjectPart::NoQt);
|
||||
|
||||
// Header paths
|
||||
CppTools::ProjectPartHeaderPaths headerPaths;
|
||||
using CppToolsHeaderPath = CppTools::ProjectPartHeaderPath;
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
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))
|
||||
headerPaths += headerPath;
|
||||
}
|
||||
|
||||
if (qtVersion && !qtVersion->frameworkInstallPath().isEmpty()) {
|
||||
headerPaths += CppToolsHeaderPath(qtVersion->frameworkInstallPath(),
|
||||
CppToolsHeaderPath::FrameworkPath);
|
||||
headerPaths += {qtVersion->frameworkInstallPath(), IncludePathType::Framework};
|
||||
}
|
||||
rpp.setHeaderPaths(headerPaths);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ using ClangBackEnd::CompilerMacro;
|
||||
using ClangBackEnd::V2::FileContainer;
|
||||
using ClangBackEnd::V2::ProjectPartContainer;
|
||||
using CppTools::CompilerOptionsBuilder;
|
||||
using CppTools::ProjectPartHeaderPath;
|
||||
using ProjectExplorer::HeaderPath;
|
||||
|
||||
class ProjectUpdater : public testing::Test
|
||||
{
|
||||
@@ -250,10 +250,10 @@ TEST_F(ProjectUpdater, CreateSortedCompilerMacros)
|
||||
|
||||
TEST_F(ProjectUpdater, CreateSortedIncludeSearchPaths)
|
||||
{
|
||||
ProjectPartHeaderPath includePath{"/to/path1", ProjectPartHeaderPath::IncludePath};
|
||||
ProjectPartHeaderPath includePath2{"/to/path2", ProjectPartHeaderPath::IncludePath};
|
||||
ProjectPartHeaderPath invalidPath;
|
||||
ProjectPartHeaderPath frameworkPath{"/framework/path", ProjectPartHeaderPath::FrameworkPath};
|
||||
ProjectExplorer::HeaderPath includePath{"/to/path1", ProjectExplorer::IncludePathType::User};
|
||||
ProjectExplorer::HeaderPath includePath2{"/to/path2", ProjectExplorer::IncludePathType::User};
|
||||
ProjectExplorer::HeaderPath invalidPath;
|
||||
ProjectExplorer::HeaderPath frameworkPath{"/framework/path", ProjectExplorer::IncludePathType::Framework};
|
||||
|
||||
auto paths = updater.createIncludeSearchPaths({frameworkPath, includePath2, includePath, invalidPath});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user