summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@theqtcompany.com>2016-01-13 14:12:15 +0100
committerMarco Bubke <marco.bubke@theqtcompany.com>2016-01-13 14:46:56 +0000
commit2b4cadf1fe138bfa23ca42ffe63c9da5d4d8827c (patch)
tree71cd2a79e861052b619aaf13b3f4f9a6c28f51a9 /src
parent42d570a3fe89da30ebbc280c79f5565471786db6 (diff)
downloadqt-creator-2b4cadf1fe138bfa23ca42ffe63c9da5d4d8827c.tar.gz
CppTools: Move ProjectPart in its own header file
Also extracting inline HeaderPath class and change projects list in vector because the size is larger than a pointer. Change-Id: I885fdff3fe9bccc877634d1615249755f5b674fd Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/clangcodemodel/clangcompletionassistinterface.cpp6
-rw-r--r--src/plugins/clangcodemodel/clangcompletionassistinterface.h8
-rw-r--r--src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp8
-rw-r--r--src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp6
-rw-r--r--src/plugins/cppeditor/cppquickfix_test.cpp36
-rw-r--r--src/plugins/cppeditor/cppquickfix_test.h14
-rw-r--r--src/plugins/cppeditor/cppquickfixes.cpp14
-rw-r--r--src/plugins/cpptools/builtineditordocumentparser.cpp4
-rw-r--r--src/plugins/cpptools/builtineditordocumentparser.h4
-rw-r--r--src/plugins/cpptools/builtinindexingsupport.cpp6
-rw-r--r--src/plugins/cpptools/cppcodemodelinspectordumper.cpp14
-rw-r--r--src/plugins/cpptools/cppcodemodelinspectordumper.h6
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp2
-rw-r--r--src/plugins/cpptools/cppcompletionassist.cpp8
-rw-r--r--src/plugins/cpptools/cppcompletionassist.h6
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp14
-rw-r--r--src/plugins/cpptools/cppmodelmanager.h6
-rw-r--r--src/plugins/cpptools/cppmodelmanager_test.cpp47
-rw-r--r--src/plugins/cpptools/cppprojectfile.cpp2
-rw-r--r--src/plugins/cpptools/cppprojectfile.h4
-rw-r--r--src/plugins/cpptools/cppprojects.cpp138
-rw-r--r--src/plugins/cpptools/cppprojects.h100
-rw-r--r--src/plugins/cpptools/cppsourceprocessor.cpp20
-rw-r--r--src/plugins/cpptools/cppsourceprocessor.h6
-rw-r--r--src/plugins/cpptools/cppsourceprocessor_test.cpp12
-rw-r--r--src/plugins/cpptools/cpptools.pro7
-rw-r--r--src/plugins/cpptools/cpptools.qbs2
-rw-r--r--src/plugins/cpptools/includeutils.cpp6
-rw-r--r--src/plugins/cpptools/projectpart.cpp165
-rw-r--r--src/plugins/cpptools/projectpart.h127
-rw-r--r--src/plugins/cpptools/projectpartheaderpath.h87
-rw-r--r--src/plugins/genericprojectmanager/genericprojectplugin_test.cpp2
-rw-r--r--src/plugins/qbsprojectmanager/qbsproject.cpp10
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeproject.cpp7
34 files changed, 532 insertions, 372 deletions
diff --git a/src/plugins/clangcodemodel/clangcompletionassistinterface.cpp b/src/plugins/clangcodemodel/clangcompletionassistinterface.cpp
index f549cd8e4d..761cf4cd35 100644
--- a/src/plugins/clangcodemodel/clangcompletionassistinterface.cpp
+++ b/src/plugins/clangcodemodel/clangcompletionassistinterface.cpp
@@ -41,7 +41,7 @@ ClangCompletionAssistInterface::ClangCompletionAssistInterface(
int position,
const QString &fileName,
TextEditor::AssistReason reason,
- const CppTools::ProjectPart::HeaderPaths &headerPaths,
+ const CppTools::ProjectPartHeaderPaths &headerPaths,
const CPlusPlus::LanguageFeatures &features)
: AssistInterface(textEditorWidget->document(), position, fileName, reason)
, m_ipcCommunicator(ipcCommunicator)
@@ -56,7 +56,7 @@ bool ClangCompletionAssistInterface::objcEnabled() const
return true; // TODO:
}
-const CppTools::ProjectPart::HeaderPaths &ClangCompletionAssistInterface::headerPaths() const
+const CppTools::ProjectPartHeaderPaths &ClangCompletionAssistInterface::headerPaths() const
{
return m_headerPaths;
}
@@ -66,7 +66,7 @@ CPlusPlus::LanguageFeatures ClangCompletionAssistInterface::languageFeatures() c
return m_languageFeatures;
}
-void ClangCompletionAssistInterface::setHeaderPaths(const CppTools::ProjectPart::HeaderPaths &headerPaths)
+void ClangCompletionAssistInterface::setHeaderPaths(const CppTools::ProjectPartHeaderPaths &headerPaths)
{
m_headerPaths = headerPaths;
}
diff --git a/src/plugins/clangcodemodel/clangcompletionassistinterface.h b/src/plugins/clangcodemodel/clangcompletionassistinterface.h
index 7be7f1431a..4bac467417 100644
--- a/src/plugins/clangcodemodel/clangcompletionassistinterface.h
+++ b/src/plugins/clangcodemodel/clangcompletionassistinterface.h
@@ -47,21 +47,21 @@ public:
int position,
const QString &fileName,
TextEditor::AssistReason reason,
- const CppTools::ProjectPart::HeaderPaths &headerPaths,
+ const CppTools::ProjectPartHeaderPaths &headerPaths,
const CPlusPlus::LanguageFeatures &features);
IpcCommunicator &ipcCommunicator() const;
bool objcEnabled() const;
- const CppTools::ProjectPart::HeaderPaths &headerPaths() const;
+ const CppTools::ProjectPartHeaderPaths &headerPaths() const;
CPlusPlus::LanguageFeatures languageFeatures() const;
const TextEditor::TextEditorWidget *textEditorWidget() const;
- void setHeaderPaths(const CppTools::ProjectPart::HeaderPaths &headerPaths); // For tests
+ void setHeaderPaths(const CppTools::ProjectPartHeaderPaths &headerPaths); // For tests
private:
IpcCommunicator &m_ipcCommunicator;
QStringList m_options;
- CppTools::ProjectPart::HeaderPaths m_headerPaths;
+ CppTools::ProjectPartHeaderPaths m_headerPaths;
CPlusPlus::LanguageFeatures m_languageFeatures;
const TextEditor::TextEditorWidget *m_textEditorWidget;
};
diff --git a/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp b/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp
index ded48db494..284e9fe3d7 100644
--- a/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp
+++ b/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp
@@ -565,9 +565,9 @@ bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
}
// Make completion for all relevant includes
- CppTools::ProjectPart::HeaderPaths headerPaths = m_interface->headerPaths();
- const CppTools::ProjectPart::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
- CppTools::ProjectPart::HeaderPath::IncludePath);
+ CppTools::ProjectPartHeaderPaths headerPaths = m_interface->headerPaths();
+ const CppTools::ProjectPartHeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
+ CppTools::ProjectPartHeaderPath::IncludePath);
if (!headerPaths.contains(currentFilePath))
headerPaths.append(currentFilePath);
@@ -575,7 +575,7 @@ bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
const ::Utils::MimeType mimeType = mdb.mimeTypeForName(QLatin1String("text/x-c++hdr"));
const QStringList suffixes = mimeType.suffixes();
- foreach (const CppTools::ProjectPart::HeaderPath &headerPath, headerPaths) {
+ foreach (const CppTools::ProjectPartHeaderPath &headerPath, headerPaths) {
QString realPath = headerPath.path;
if (!directoryPrefix.isEmpty()) {
realPath += QLatin1Char('/');
diff --git a/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp b/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp
index 0f003c2e1e..7301607cad 100644
--- a/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp
+++ b/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp
@@ -432,13 +432,13 @@ public:
QString senderLog;
};
-const CppTools::ProjectPart::HeaderPaths toHeaderPaths(const QStringList &paths)
+const CppTools::ProjectPartHeaderPaths toHeaderPaths(const QStringList &paths)
{
using namespace CppTools;
- ProjectPart::HeaderPaths result;
+ ProjectPartHeaderPaths result;
foreach (const QString &path, paths)
- result << ProjectPart::HeaderPath(path, ProjectPart::HeaderPath::IncludePath);
+ result << ProjectPartHeaderPath(path, ProjectPartHeaderPath::IncludePath);
return result;
}
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp
index c914f2a48b..d9d524e460 100644
--- a/src/plugins/cppeditor/cppquickfix_test.cpp
+++ b/src/plugins/cppeditor/cppquickfix_test.cpp
@@ -109,7 +109,7 @@ QList<QuickFixTestDocument::Ptr> singleDocument(const QByteArray &original,
}
BaseQuickFixTestCase::BaseQuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &testDocuments,
- const ProjectPart::HeaderPaths &headerPaths)
+ const ProjectPartHeaderPaths &headerPaths)
: m_testDocuments(testDocuments)
, m_cppCodeStylePreferences(0)
, m_restoreHeaderPaths(false)
@@ -229,7 +229,7 @@ static QString &removeTrailingWhitespace(QString &input)
QuickFixOperationTest::QuickFixOperationTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
CppQuickFixFactory *factory,
- const ProjectPart::HeaderPaths &headerPaths,
+ const ProjectPartHeaderPaths &headerPaths,
int operationIndex,
const QByteArray &expectedFailMessage)
: BaseQuickFixTestCase(testDocuments, headerPaths)
@@ -272,15 +272,15 @@ void QuickFixOperationTest::run(const QList<QuickFixTestDocument::Ptr> &testDocu
const QString &headerPath,
int operationIndex)
{
- ProjectPart::HeaderPaths headerPaths;
- headerPaths += ProjectPart::HeaderPath(headerPath, ProjectPart::HeaderPath::IncludePath);
+ ProjectPartHeaderPaths headerPaths;
+ headerPaths += ProjectPartHeaderPath(headerPath, ProjectPartHeaderPath::IncludePath);
QuickFixOperationTest(testDocuments, factory, headerPaths, operationIndex);
}
QuickFixOfferedOperationsTest::QuickFixOfferedOperationsTest(
const QList<QuickFixTestDocument::Ptr> &testDocuments,
CppQuickFixFactory *factory,
- const ProjectPart::HeaderPaths &headerPaths,
+ const ProjectPartHeaderPaths &headerPaths,
const QStringList &expectedOperations)
: BaseQuickFixTestCase(testDocuments, headerPaths)
{
@@ -1857,7 +1857,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_onlyGetter()
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
GenerateGetterSetter factory;
- QuickFixOperationTest(testDocuments, &factory, ProjectPart::HeaderPaths(), 1);
+ QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1);
}
/// Checks: Only generate setter
@@ -1894,7 +1894,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_onlySetter()
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
GenerateGetterSetter factory;
- QuickFixOperationTest(testDocuments, &factory, ProjectPart::HeaderPaths(), 2);
+ QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 2);
}
/// Checks: Offer a "generate getter" quick fix if there is a setter
@@ -2015,7 +2015,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- QuickFixOperationTest(testDocuments, &factory, ProjectPart::HeaderPaths(), 1);
+ QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1);
}
/// Check from header file: If there is a source file, insert the definition in the source file.
@@ -2201,7 +2201,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_insideClass()
"};";
InsertDefFromDecl factory;
- QuickFixOperationTest(singleDocument(original, expected), &factory, ProjectPart::HeaderPaths(),
+ QuickFixOperationTest(singleDocument(original, expected), &factory, ProjectPartHeaderPaths(),
1);
}
@@ -2215,7 +2215,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio
"void Foo::bar() {}\n";
InsertDefFromDecl factory;
- QuickFixOperationTest(singleDocument(original, ""), &factory, ProjectPart::HeaderPaths(), 1);
+ QuickFixOperationTest(singleDocument(original, ""), &factory, ProjectPartHeaderPaths(), 1);
}
/// Find right implementation file.
@@ -2629,7 +2629,7 @@ void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex)
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
InsertDeclFromDef factory;
- QuickFixOperationTest(testDocuments, &factory, ProjectPart::HeaderPaths(), sectionIndex);
+ QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), sectionIndex);
}
/// Check from source file: Insert in header file.
@@ -3391,9 +3391,9 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_noDoubleQtH
original = expected = "@QDir dir;\n";
testDocuments << QuickFixTestDocument::create(base + "/fileWantsToUseQDir.cpp", original, expected);
- ProjectPart::HeaderPaths headerPaths;
- headerPaths += ProjectPart::HeaderPath(TestIncludePaths::globalQtCoreIncludePath(),
- ProjectPart::HeaderPath::IncludePath);
+ ProjectPartHeaderPaths headerPaths;
+ headerPaths += ProjectPartHeaderPath(TestIncludePaths::globalQtCoreIncludePath(),
+ ProjectPartHeaderPath::IncludePath);
AddIncludeForUndefinedIdentifier factory;
const QStringList expectedOperations = QStringList() << QLatin1String("Add #include <QDir>");
@@ -3561,7 +3561,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside2()
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- QuickFixOperationTest(testDocuments, &factory, ProjectPart::HeaderPaths(), 1);
+ QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1);
}
/// Check: Move definition from header to cpp (with namespace).
@@ -3868,7 +3868,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_afterClass()
testDocuments << QuickFixTestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- QuickFixOperationTest(testDocuments, &factory, ProjectPart::HeaderPaths(), 1);
+ QuickFixOperationTest(testDocuments, &factory, ProjectPartHeaderPaths(), 1);
}
/// Check if whitespace is respected for operator functions
@@ -3943,7 +3943,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_macroUses()
MoveFuncDefOutside factory;
QuickFixOperationTest(singleDocument(original, expected), &factory,
- ProjectPart::HeaderPaths(), 0, "QTCREATORBUG-12314");
+ ProjectPartHeaderPaths(), 0, "QTCREATORBUG-12314");
}
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
@@ -4277,7 +4277,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_macroUses()
MoveFuncDefToDecl factory;
QuickFixOperationTest(singleDocument(original, expected), &factory,
- ProjectPart::HeaderPaths(), 0, "QTCREATORBUG-12314");
+ ProjectPartHeaderPaths(), 0, "QTCREATORBUG-12314");
}
void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_override()
diff --git a/src/plugins/cppeditor/cppquickfix_test.h b/src/plugins/cppeditor/cppquickfix_test.h
index 14c3d415d0..24bf540836 100644
--- a/src/plugins/cppeditor/cppquickfix_test.h
+++ b/src/plugins/cppeditor/cppquickfix_test.h
@@ -81,8 +81,8 @@ public:
/// Exactly one QuickFixTestDocument must contain the cursor position marker '@'
/// or "@{start}" and "@{end}"
BaseQuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &testDocuments,
- const CppTools::ProjectPart::HeaderPaths &headerPaths
- = CppTools::ProjectPart::HeaderPaths());
+ const CppTools::ProjectPartHeaderPaths &headerPaths
+ = CppTools::ProjectPartHeaderPaths());
~BaseQuickFixTestCase();
@@ -96,7 +96,7 @@ private:
CppTools::CppCodeStylePreferences *m_cppCodeStylePreferences;
QByteArray m_cppCodeStylePreferencesOriginalDelegateId;
- CppTools::ProjectPart::HeaderPaths m_headerPathsToRestore;
+ CppTools::ProjectPartHeaderPaths m_headerPathsToRestore;
bool m_restoreHeaderPaths;
};
@@ -106,8 +106,8 @@ class QuickFixOperationTest : public BaseQuickFixTestCase
public:
QuickFixOperationTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
CppQuickFixFactory *factory,
- const CppTools::ProjectPart::HeaderPaths &headerPaths
- = CppTools::ProjectPart::HeaderPaths(),
+ const CppTools::ProjectPartHeaderPaths &headerPaths
+ = CppTools::ProjectPartHeaderPaths(),
int operationIndex = 0,
const QByteArray &expectedFailMessage = QByteArray());
@@ -123,8 +123,8 @@ class QuickFixOfferedOperationsTest : public BaseQuickFixTestCase
public:
QuickFixOfferedOperationsTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
CppQuickFixFactory *factory,
- const CppTools::ProjectPart::HeaderPaths &headerPaths
- = CppTools::ProjectPart::HeaderPaths(),
+ const CppTools::ProjectPartHeaderPaths &headerPaths
+ = CppTools::ProjectPartHeaderPaths(),
const QStringList &expectedOperations = QStringList());
};
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index 7e23cddadf..6d85729613 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -1751,7 +1751,7 @@ namespace {
QString findShortestInclude(const QString currentDocumentFilePath,
const QString candidateFilePath,
- const ProjectPart::HeaderPaths &headerPaths)
+ const ProjectPartHeaderPaths &headerPaths)
{
QString result;
@@ -1760,7 +1760,7 @@ QString findShortestInclude(const QString currentDocumentFilePath,
if (fileInfo.path() == QFileInfo(currentDocumentFilePath).path()) {
result = QLatin1Char('"') + fileInfo.fileName() + QLatin1Char('"');
} else {
- foreach (const ProjectPart::HeaderPath &headerPath, headerPaths) {
+ foreach (const ProjectPartHeaderPath &headerPath, headerPaths) {
if (!candidateFilePath.startsWith(headerPath.path))
continue;
QString relativePath = candidateFilePath.mid(headerPath.path.size());
@@ -1775,12 +1775,12 @@ QString findShortestInclude(const QString currentDocumentFilePath,
}
QString findQtIncludeWithSameName(const QString &className,
- const ProjectPart::HeaderPaths &headerPaths)
+ const ProjectPartHeaderPaths &headerPaths)
{
QString result;
// Check for a header file with the same name in the Qt include paths
- foreach (const ProjectPart::HeaderPath &headerPath, headerPaths) {
+ foreach (const ProjectPartHeaderPath &headerPath, headerPaths) {
if (!headerPath.path.contains(QLatin1String("/Qt"))) // "QtCore", "QtGui" etc...
continue;
@@ -1795,9 +1795,9 @@ QString findQtIncludeWithSameName(const QString &className,
return result;
}
-ProjectPart::HeaderPaths relevantHeaderPaths(const QString &filePath)
+ProjectPartHeaderPaths relevantHeaderPaths(const QString &filePath)
{
- ProjectPart::HeaderPaths headerPaths;
+ ProjectPartHeaderPaths headerPaths;
CppModelManager *modelManager = CppModelManager::instance();
const QList<ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
@@ -1924,7 +1924,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
return;
const QString currentDocumentFilePath = interface.semanticInfo().doc->fileName();
- const ProjectPart::HeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath);
+ const ProjectPartHeaderPaths headerPaths = relevantHeaderPaths(currentDocumentFilePath);
bool qtHeaderFileIncludeOffered = false;
// Find an include file through the locator
diff --git a/src/plugins/cpptools/builtineditordocumentparser.cpp b/src/plugins/cpptools/builtineditordocumentparser.cpp
index 8d02d7c01f..46ffec38c3 100644
--- a/src/plugins/cpptools/builtineditordocumentparser.cpp
+++ b/src/plugins/cpptools/builtineditordocumentparser.cpp
@@ -76,7 +76,7 @@ void BuiltinEditorDocumentParser::updateHelper(const WorkingCopy &theWorkingCopy
CppModelManager *modelManager = CppModelManager::instance();
QByteArray configFile = modelManager->codeModelConfiguration();
- ProjectPart::HeaderPaths headerPaths;
+ ProjectPartHeaderPaths headerPaths;
QStringList precompiledHeaders;
QString projectConfigFile;
LanguageFeatures features = LanguageFeatures::defaultFeatures();
@@ -238,7 +238,7 @@ Snapshot BuiltinEditorDocumentParser::snapshot() const
return extraState().snapshot;
}
-ProjectPart::HeaderPaths BuiltinEditorDocumentParser::headerPaths() const
+ProjectPartHeaderPaths BuiltinEditorDocumentParser::headerPaths() const
{
return extraState().headerPaths;
}
diff --git a/src/plugins/cpptools/builtineditordocumentparser.h b/src/plugins/cpptools/builtineditordocumentparser.h
index 93f3c2bad6..15eaef5407 100644
--- a/src/plugins/cpptools/builtineditordocumentparser.h
+++ b/src/plugins/cpptools/builtineditordocumentparser.h
@@ -52,7 +52,7 @@ public:
CPlusPlus::Document::Ptr document() const;
CPlusPlus::Snapshot snapshot() const;
- ProjectPart::HeaderPaths headerPaths() const;
+ ProjectPartHeaderPaths headerPaths() const;
void releaseResources();
@@ -72,7 +72,7 @@ private:
struct ExtraState {
QByteArray configFile;
- ProjectPart::HeaderPaths headerPaths;
+ ProjectPartHeaderPaths headerPaths;
QString projectConfigFile;
QStringList precompiledHeaders;
diff --git a/src/plugins/cpptools/builtinindexingsupport.cpp b/src/plugins/cpptools/builtinindexingsupport.cpp
index a5713b6da8..78946f94d4 100644
--- a/src/plugins/cpptools/builtinindexingsupport.cpp
+++ b/src/plugins/cpptools/builtinindexingsupport.cpp
@@ -61,7 +61,7 @@ namespace {
class ParseParams
{
public:
- ProjectPart::HeaderPaths headerPaths;
+ ProjectPartHeaderPaths headerPaths;
WorkingCopy workingCopy;
QSet<QString> sourceFiles;
};
@@ -203,7 +203,7 @@ void index(QFutureInterface<void> &future, const ParseParams params)
bool processingHeaders = false;
CppModelManager *cmm = CppModelManager::instance();
- const ProjectPart::HeaderPaths fallbackHeaderPaths = cmm->headerPaths();
+ const ProjectPartHeaderPaths fallbackHeaderPaths = cmm->headerPaths();
const CPlusPlus::LanguageFeatures defaultFeatures =
CPlusPlus::LanguageFeatures::defaultFeatures();
for (int i = 0; i < files.size(); ++i) {
@@ -229,7 +229,7 @@ void index(QFutureInterface<void> &future, const ParseParams params)
processingHeaders = true;
}
- ProjectPart::HeaderPaths headerPaths = parts.isEmpty()
+ ProjectPartHeaderPaths headerPaths = parts.isEmpty()
? fallbackHeaderPaths
: parts.first()->headerPaths;
sourceProcessor->setHeaderPaths(headerPaths);
diff --git a/src/plugins/cpptools/cppcodemodelinspectordumper.cpp b/src/plugins/cpptools/cppcodemodelinspectordumper.cpp
index 1285c40da3..2282907120 100644
--- a/src/plugins/cpptools/cppcodemodelinspectordumper.cpp
+++ b/src/plugins/cpptools/cppcodemodelinspectordumper.cpp
@@ -143,7 +143,7 @@ QString Utils::toString(ProjectPart::QtVersion qtVersion)
return QString();
}
-QString Utils::toString(const QList<ProjectFile> &projectFiles)
+QString Utils::toString(const QVector<ProjectFile> &projectFiles)
{
QStringList filesList;
foreach (const ProjectFile &projectFile, projectFiles)
@@ -411,10 +411,10 @@ QString Utils::pathListToString(const QStringList &pathList)
return result.join(QLatin1Char('\n'));
}
-QString Utils::pathListToString(const ProjectPart::HeaderPaths &pathList)
+QString Utils::pathListToString(const ProjectPartHeaderPaths &pathList)
{
QStringList result;
- foreach (const ProjectPart::HeaderPath &path, pathList) {
+ foreach (const ProjectPartHeaderPath &path, pathList) {
result << QString(QLatin1String("%1 (%2 path)")).arg(
QDir::toNativeSeparators(path.path),
path.isFrameworkPath() ? QLatin1String("framework") : QLatin1String("include")
@@ -523,9 +523,9 @@ void Dumper::dumpProjectInfos( const QList<ProjectInfo> &projectInfos)
if (!part->headerPaths.isEmpty()) {
m_out << i3 << "Header Paths:{{{4\n";
- foreach (const ProjectPart::HeaderPath &headerPath, part->headerPaths)
+ foreach (const ProjectPartHeaderPath &headerPath, part->headerPaths)
m_out << i4 << headerPath.path
- << (headerPath.type == ProjectPart::HeaderPath::IncludePath
+ << (headerPath.type == ProjectPartHeaderPath::IncludePath
? "(include path)"
: "(framework path)")
<< "\n";
@@ -590,7 +590,7 @@ void Dumper::dumpWorkingCopy(const WorkingCopy &workingCopy)
}
}
-void Dumper::dumpMergedEntities(const ProjectPart::HeaderPaths &mergedHeaderPaths,
+void Dumper::dumpMergedEntities(const ProjectPartHeaderPaths &mergedHeaderPaths,
const QByteArray &mergedMacros)
{
m_out << "Merged Entities{{{1\n";
@@ -598,7 +598,7 @@ void Dumper::dumpMergedEntities(const ProjectPart::HeaderPaths &mergedHeaderPath
const QByteArray i3 = indent(3);
m_out << i2 << "Merged Header Paths{{{2\n";
- foreach (const ProjectPart::HeaderPath &hp, mergedHeaderPaths)
+ foreach (const ProjectPartHeaderPath &hp, mergedHeaderPaths)
m_out << i3 << hp.path
<< (hp.isFrameworkPath() ? " (framework path)" : " (include path)")
<< "\n";
diff --git a/src/plugins/cpptools/cppcodemodelinspectordumper.h b/src/plugins/cpptools/cppcodemodelinspectordumper.h
index 5257a404a9..79b342a512 100644
--- a/src/plugins/cpptools/cppcodemodelinspectordumper.h
+++ b/src/plugins/cpptools/cppcodemodelinspectordumper.h
@@ -54,13 +54,13 @@ struct CPPTOOLS_EXPORT Utils
static QString toString(CppTools::ProjectPart::LanguageVersion languageVersion);
static QString toString(CppTools::ProjectPart::LanguageExtensions languageExtension);
static QString toString(CppTools::ProjectPart::QtVersion qtVersion);
- static QString toString(const QList<CppTools::ProjectFile> &projectFiles);
+ static QString toString(const QVector<CppTools::ProjectFile> &projectFiles);
static QString toString(CppTools::ProjectFile::Kind kind);
static QString toString(CPlusPlus::Kind kind);
static QString partsForFile(const QString &fileName);
static QString unresolvedFileNameWithDelimiters(const CPlusPlus::Document::Include &include);
static QString pathListToString(const QStringList &pathList);
- static QString pathListToString(const ProjectPart::HeaderPaths &pathList);
+ static QString pathListToString(const ProjectPartHeaderPaths &pathList);
static QList<CPlusPlus::Document::Ptr> snapshotToList(const CPlusPlus::Snapshot &snapshot);
};
@@ -76,7 +76,7 @@ public:
const QString &title,
bool isGlobalSnapshot = false);
void dumpWorkingCopy(const CppTools::WorkingCopy &workingCopy);
- void dumpMergedEntities(const ProjectPart::HeaderPaths &mergedHeaderPaths,
+ void dumpMergedEntities(const ProjectPartHeaderPaths &mergedHeaderPaths,
const QByteArray &mergedMacros);
private:
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index 7deb309f58..4ffc55b4f3 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -113,7 +113,7 @@ public:
= new CppCompletionAssistInterface(m_editorWidget->textDocument()->filePath().toString(),
m_textDocument, m_position,
ExplicitlyInvoked, m_snapshot,
- ProjectPart::HeaderPaths(),
+ ProjectPartHeaderPaths(),
languageFeatures);
InternalCppCompletionAssistProcessor processor;
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index 21f9f8f4fd..8570e0c356 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -1339,16 +1339,16 @@ bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cu
}
// Make completion for all relevant includes
- ProjectPart::HeaderPaths headerPaths = m_interface->headerPaths();
- const ProjectPart::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
- ProjectPart::HeaderPath::IncludePath);
+ ProjectPartHeaderPaths headerPaths = m_interface->headerPaths();
+ const ProjectPartHeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
+ ProjectPartHeaderPath::IncludePath);
if (!headerPaths.contains(currentFilePath))
headerPaths.append(currentFilePath);
Utils::MimeDatabase mdb;
const QStringList suffixes = mdb.mimeTypeForName(QLatin1String("text/x-c++hdr")).suffixes();
- foreach (const ProjectPart::HeaderPath &headerPath, headerPaths) {
+ foreach (const ProjectPartHeaderPath &headerPath, headerPaths) {
QString realPath = headerPath.path;
if (!directoryPrefix.isEmpty()) {
realPath += QLatin1Char('/');
diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h
index 30f8809081..a88ce4d42a 100644
--- a/src/plugins/cpptools/cppcompletionassist.h
+++ b/src/plugins/cpptools/cppcompletionassist.h
@@ -189,7 +189,7 @@ public:
int position,
TextEditor::AssistReason reason,
const CPlusPlus::Snapshot &snapshot,
- const ProjectPart::HeaderPaths &headerPaths,
+ const ProjectPartHeaderPaths &headerPaths,
const CPlusPlus::LanguageFeatures &features)
: TextEditor::AssistInterface(textDocument, position, filePath, reason)
, m_gotCppSpecifics(true)
@@ -199,7 +199,7 @@ public:
{}
const CPlusPlus::Snapshot &snapshot() const { getCppSpecifics(); return m_snapshot; }
- const ProjectPart::HeaderPaths &headerPaths() const
+ const ProjectPartHeaderPaths &headerPaths() const
{ getCppSpecifics(); return m_headerPaths; }
CPlusPlus::LanguageFeatures languageFeatures() const
{ getCppSpecifics(); return m_languageFeatures; }
@@ -211,7 +211,7 @@ private:
mutable bool m_gotCppSpecifics;
WorkingCopy m_workingCopy;
mutable CPlusPlus::Snapshot m_snapshot;
- mutable ProjectPart::HeaderPaths m_headerPaths;
+ mutable ProjectPartHeaderPaths m_headerPaths;
mutable CPlusPlus::LanguageFeatures m_languageFeatures;
};
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index c6c92719de..127437cb2f 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -142,7 +142,7 @@ public:
// The members below are cached/(re)calculated from the projects and/or their project parts
bool m_dirty;
QStringList m_projectFiles;
- ProjectPart::HeaderPaths m_headerPaths;
+ ProjectPartHeaderPaths m_headerPaths;
QByteArray m_definedMacros;
// Editor integration
@@ -412,16 +412,16 @@ QStringList CppModelManager::internalProjectFiles() const
return files;
}
-ProjectPart::HeaderPaths CppModelManager::internalHeaderPaths() const
+ProjectPartHeaderPaths CppModelManager::internalHeaderPaths() const
{
- ProjectPart::HeaderPaths headerPaths;
+ ProjectPartHeaderPaths 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 ProjectPart::HeaderPath &path, part->headerPaths) {
- const ProjectPart::HeaderPath hp(QDir::cleanPath(path.path), path.type);
+ foreach (const ProjectPartHeaderPath &path, part->headerPaths) {
+ const ProjectPartHeaderPath hp(QDir::cleanPath(path.path), path.type);
if (!headerPaths.contains(hp))
headerPaths += hp;
}
@@ -1168,7 +1168,7 @@ QStringList CppModelManager::projectFiles()
return d->m_projectFiles;
}
-ProjectPart::HeaderPaths CppModelManager::headerPaths()
+ProjectPartHeaderPaths CppModelManager::headerPaths()
{
QMutexLocker locker(&d->m_projectMutex);
ensureUpdated();
@@ -1176,7 +1176,7 @@ ProjectPart::HeaderPaths CppModelManager::headerPaths()
return d->m_headerPaths;
}
-void CppModelManager::setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths)
+void CppModelManager::setHeaderPaths(const ProjectPartHeaderPaths &headerPaths)
{
QMutexLocker locker(&d->m_projectMutex);
d->m_headerPaths = headerPaths;
diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h
index 2fbab066b2..84bf1c869f 100644
--- a/src/plugins/cpptools/cppmodelmanager.h
+++ b/src/plugins/cpptools/cppmodelmanager.h
@@ -154,10 +154,10 @@ public:
QStringList projectFiles();
- ProjectPart::HeaderPaths headerPaths();
+ ProjectPartHeaderPaths headerPaths();
// Use this *only* for auto tests
- void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
+ void setHeaderPaths(const ProjectPartHeaderPaths &headerPaths);
QByteArray definedMacros();
@@ -217,7 +217,7 @@ private:
void ensureUpdated();
QStringList internalProjectFiles() const;
- ProjectPart::HeaderPaths internalHeaderPaths() const;
+ ProjectPartHeaderPaths internalHeaderPaths() const;
QByteArray internalDefinedMacros() const;
void dumpModelManagerConfiguration(const QString &logFileId);
diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp
index acbfb0ba90..e07b7b8c84 100644
--- a/src/plugins/cpptools/cppmodelmanager_test.cpp
+++ b/src/plugins/cpptools/cppmodelmanager_test.cpp
@@ -61,7 +61,7 @@ using namespace ProjectExplorer;
typedef CPlusPlus::Document Document;
-Q_DECLARE_METATYPE(QList<ProjectFile>)
+Q_DECLARE_METATYPE(QVector<ProjectFile>)
namespace {
@@ -189,21 +189,20 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
Project *project = helper.createProject(_("test_modelmanager_paths_are_clean"));
ProjectInfo pi = ProjectInfo(project);
- typedef ProjectPart::HeaderPath HeaderPath;
+ typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
- part->headerPaths = QList<HeaderPath>()
- << HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath)
- << HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath);
+ part->headerPaths = { HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath),
+ HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath) };
pi.appendProjectPart(part);
pi.finish();
mm->updateProjectInfo(pi);
- QList<HeaderPath> headerPaths = mm->headerPaths();
+ ProjectPartHeaderPaths headerPaths = mm->headerPaths();
QCOMPARE(headerPaths.size(), 2);
QVERIFY(headerPaths.contains(HeaderPath(testDataDir.includeDir(), HeaderPath::IncludePath)));
QVERIFY(headerPaths.contains(HeaderPath(testDataDir.frameworksDir(),
@@ -224,15 +223,14 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
Project *project = helper.createProject(_("test_modelmanager_framework_headers"));
ProjectInfo pi = ProjectInfo(project);
- typedef ProjectPart::HeaderPath HeaderPath;
+ typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
- part->headerPaths = QList<HeaderPath>()
- << HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath)
- << HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath);
+ part->headerPaths = { HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath),
+ HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath) };
const QString &source = testDataDir.fileFromSourcesDir(
_("test_modelmanager_framework_headers.cpp"));
part->files << ProjectFile(source, ProjectFile::CXXSource);
@@ -276,14 +274,13 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
_("test_modelmanager_refresh_also_includes_of_project_files"));
ProjectInfo pi = ProjectInfo(project);
- typedef ProjectPart::HeaderPath HeaderPath;
+ typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part(new ProjectPart);
part->languageVersion = ProjectPart::CXX14;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
- part->headerPaths = QList<HeaderPath>()
- << HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath);
+ part->headerPaths = { HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath) };
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
pi.finish();
@@ -788,7 +785,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
Project *project = helper.createProject(_("test_modelmanager_defines_per_project"));
- typedef ProjectPart::HeaderPath HeaderPath;
+ typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part1(new ProjectPart);
part1->projectFile = QLatin1String("project1.projectfile");
@@ -797,8 +794,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
part1->languageVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
part1->projectDefines = QByteArray("#define SUB1\n");
- part1->headerPaths = QList<HeaderPath>()
- << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
+ part1->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
ProjectPart::Ptr part2(new ProjectPart);
part2->projectFile = QLatin1String("project1.projectfile");
@@ -807,8 +803,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
part2->languageVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
part2->projectDefines = QByteArray("#define SUB2\n");
- part2->headerPaths = QList<HeaderPath>()
- << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
+ part2->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
ProjectInfo pi = ProjectInfo(project);
pi.appendProjectPart(part1);
@@ -859,7 +854,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
Project *project = helper.createProject(_("test_modelmanager_defines_per_project_pch"));
- typedef ProjectPart::HeaderPath HeaderPath;
+ typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part1(new ProjectPart);
part1->projectFile = QLatin1String("project1.projectfile");
@@ -868,8 +863,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
part1->languageVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
part1->precompiledHeaders.append(pch1File);
- part1->headerPaths = QList<HeaderPath>()
- << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
+ part1->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
ProjectPart::Ptr part2(new ProjectPart);
part2->projectFile = QLatin1String("project2.projectfile");
@@ -878,8 +872,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
part2->languageVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
part2->precompiledHeaders.append(pch2File);
- part2->headerPaths = QList<HeaderPath>()
- << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
+ part2->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
ProjectInfo pi = ProjectInfo(project);
pi.appendProjectPart(part1);
@@ -947,23 +940,21 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
Project *project = helper.createProject(_("test_modelmanager_defines_per_editor"));
- typedef ProjectPart::HeaderPath HeaderPath;
+ typedef ProjectPartHeaderPath HeaderPath;
ProjectPart::Ptr part1(new ProjectPart);
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part1->languageVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
- part1->headerPaths = QList<HeaderPath>()
- << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
+ part1->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
ProjectPart::Ptr part2(new ProjectPart);
part2->files.append(ProjectFile(main2File, ProjectFile::CXXSource));
part2->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part2->languageVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
- part2->headerPaths = QList<HeaderPath>()
- << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
+ part2->headerPaths = { HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath) };
ProjectInfo pi = ProjectInfo(project);
pi.appendProjectPart(part1);
diff --git a/src/plugins/cpptools/cppprojectfile.cpp b/src/plugins/cpptools/cppprojectfile.cpp
index eceea5f350..bc49892784 100644
--- a/src/plugins/cpptools/cppprojectfile.cpp
+++ b/src/plugins/cpptools/cppprojectfile.cpp
@@ -125,7 +125,7 @@ QDebug operator<<(QDebug stream, const CppTools::ProjectFile &cxxFile)
namespace Internal {
-ProjectFileAdder::ProjectFileAdder(QList<ProjectFile> &files)
+ProjectFileAdder::ProjectFileAdder(QVector<ProjectFile> &files)
: m_files(files)
{
addMapping(CppTools::Constants::C_SOURCE_MIMETYPE, ProjectFile::CSource);
diff --git a/src/plugins/cpptools/cppprojectfile.h b/src/plugins/cpptools/cppprojectfile.h
index bfc7d87b70..2ba48b710f 100644
--- a/src/plugins/cpptools/cppprojectfile.h
+++ b/src/plugins/cpptools/cppprojectfile.h
@@ -75,7 +75,7 @@ namespace Internal {
class ProjectFileAdder
{
public:
- ProjectFileAdder(QList<ProjectFile> &files);
+ ProjectFileAdder(QVector<ProjectFile> &files);
~ProjectFileAdder();
bool maybeAdd(const QString &path);
@@ -84,7 +84,7 @@ private:
void addMapping(const char *mimeName, ProjectFile::Kind kind);
- QList<ProjectFile> &m_files;
+ QVector<ProjectFile> &m_files;
QHash<QString, ProjectFile::Kind> m_mimeNameMapping;
};
diff --git a/src/plugins/cpptools/cppprojects.cpp b/src/plugins/cpptools/cppprojects.cpp
index ba2b14ba0f..317baa6d68 100644
--- a/src/plugins/cpptools/cppprojects.cpp
+++ b/src/plugins/cpptools/cppprojects.cpp
@@ -49,131 +49,7 @@ using namespace CppTools;
using namespace CppTools::Internal;
using namespace ProjectExplorer;
-ProjectPart::ProjectPart()
- : project(0)
- , languageVersion(CXX14)
- , languageExtensions(NoExtensions)
- , qtVersion(UnknownQt)
- , warningFlags(ToolChain::WarningsDefault)
- , selectedForBuilding(true)
-{
-}
-
-static ProjectPart::HeaderPath toProjectPartHeaderPath(const ProjectExplorer::HeaderPath &headerPath)
-{
- const ProjectPart::HeaderPath::Type headerPathType =
- headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath
- ? ProjectPart::HeaderPath::FrameworkPath
- : ProjectPart::HeaderPath::IncludePath;
-
- return ProjectPart::HeaderPath(headerPath.path(), headerPathType);
-}
-
-/*!
- \brief Retrieves info from concrete compiler using it's flags.
-
- \param tc Either nullptr or toolchain for project's active target.
- \param cxxflags C++ or Objective-C++ flags.
- \param cflags C or ObjectiveC flags if possible, \a cxxflags otherwise.
-*/
-void ProjectPart::evaluateToolchain(const ToolChain *tc,
- const QStringList &commandLineFlags,
- const Utils::FileName &sysRoot)
-{
- if (!tc)
- return;
-
- using namespace ProjectExplorer;
- ToolChain::CompilerFlags flags = tc->compilerFlags(commandLineFlags);
-
- if (flags & ToolChain::StandardC11)
- languageVersion = C11;
- else if (flags & ToolChain::StandardC99)
- languageVersion = C99;
- else if (flags & ToolChain::StandardCxx17)
- languageVersion = CXX17;
- else if (flags & ToolChain::StandardCxx14)
- languageVersion = CXX14;
- else if (flags & ToolChain::StandardCxx11)
- languageVersion = CXX11;
- else if (flags & ToolChain::StandardCxx98)
- languageVersion = CXX98;
- else
- languageVersion = CXX11;
-
- if (flags & ToolChain::BorlandExtensions)
- languageExtensions |= BorlandExtensions;
- if (flags & ToolChain::GnuExtensions)
- languageExtensions |= GnuExtensions;
- if (flags & ToolChain::MicrosoftExtensions)
- languageExtensions |= MicrosoftExtensions;
- if (flags & ToolChain::OpenMP)
- languageExtensions |= OpenMPExtensions;
- if (flags & ToolChain::ObjectiveC)
- languageExtensions |= ObjectiveCExtensions;
-
- warningFlags = tc->warningFlags(commandLineFlags);
-
- const QList<ProjectExplorer::HeaderPath> headers = tc->systemHeaderPaths(commandLineFlags, sysRoot);
- foreach (const ProjectExplorer::HeaderPath &header, headers) {
- const HeaderPath headerPath = toProjectPartHeaderPath(header);
- if (!headerPaths.contains(headerPath))
- headerPaths << headerPath;
- }
-
- toolchainDefines = tc->predefinedMacros(commandLineFlags);
- toolchainType = tc->typeId();
- updateLanguageFeatures();
-}
-
-void ProjectPart::updateLanguageFeatures()
-{
- const bool hasQt = qtVersion != NoQt;
- languageFeatures.cxx11Enabled = languageVersion >= CXX11;
- languageFeatures.qtEnabled = hasQt;
- languageFeatures.qtMocRunEnabled = hasQt;
- if (!hasQt) {
- languageFeatures.qtKeywordsEnabled = false;
- } else {
- const QByteArray noKeywordsMacro = "#define QT_NO_KEYWORDS";
- const int noKeywordsIndex = projectDefines.indexOf(noKeywordsMacro);
- if (noKeywordsIndex == -1) {
- languageFeatures.qtKeywordsEnabled = true;
- } else {
- const char nextChar = projectDefines.at(noKeywordsIndex + noKeywordsMacro.length());
- // Detect "#define QT_NO_KEYWORDS" and "#define QT_NO_KEYWORDS 1", but exclude
- // "#define QT_NO_KEYWORDS_FOO"
- languageFeatures.qtKeywordsEnabled = nextChar != '\n' && nextChar != ' ';
- }
- }
-}
-
-ProjectPart::Ptr ProjectPart::copy() const
-{
- return Ptr(new ProjectPart(*this));
-}
-QString ProjectPart::id() const
-{
- QString projectPartId = QDir::fromNativeSeparators(projectFile);
- if (!displayName.isEmpty())
- projectPartId.append(QLatin1Char(' ') + displayName);
- return projectPartId;
-}
-
-QByteArray ProjectPart::readProjectConfigFile(const ProjectPart::Ptr &part)
-{
- QByteArray result;
-
- QFile f(part->projectConfigFile);
- if (f.open(QIODevice::ReadOnly)) {
- QTextStream is(&f);
- result = is.readAll().toUtf8();
- f.close();
- }
-
- return result;
-}
ProjectInfo::ProjectInfo()
{}
@@ -235,7 +111,7 @@ void ProjectInfo::appendProjectPart(const ProjectPart::Ptr &part)
void ProjectInfo::finish()
{
- typedef ProjectPart::HeaderPath HeaderPath;
+ typedef ProjectPartHeaderPath HeaderPath;
QSet<HeaderPath> incs;
foreach (const ProjectPart::Ptr &part, m_projectParts) {
@@ -263,7 +139,7 @@ void ProjectInfo::finish()
}
}
-const ProjectPart::HeaderPaths ProjectInfo::headerPaths() const
+const ProjectPartHeaderPaths ProjectInfo::headerPaths() const
{
return m_headerPaths;
}
@@ -392,7 +268,7 @@ void ProjectPartBuilder::setDefines(const QByteArray &defines)
m_templatePart->projectDefines = defines;
}
-void ProjectPartBuilder::setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths)
+void ProjectPartBuilder::setHeaderPaths(const ProjectPartHeaderPaths &headerPaths)
{
m_templatePart->headerPaths = headerPaths;
}
@@ -402,7 +278,7 @@ void ProjectPartBuilder::setIncludePaths(const QStringList &includePaths)
m_templatePart->headerPaths.clear();
foreach (const QString &includeFile, includePaths) {
- ProjectPart::HeaderPath hp(includeFile, ProjectPart::HeaderPath::IncludePath);
+ ProjectPartHeaderPath hp(includeFile, ProjectPartHeaderPath::IncludePath);
// The simple project managers are utterly ignorant of frameworks on OSX, and won't report
// framework paths. The work-around is to check if the include path ends in ".framework",
@@ -410,8 +286,8 @@ void ProjectPartBuilder::setIncludePaths(const QStringList &includePaths)
if (includeFile.endsWith(QLatin1String(".framework"))) {
const int slashIdx = includeFile.lastIndexOf(QLatin1Char('/'));
if (slashIdx != -1) {
- hp = ProjectPart::HeaderPath(includeFile.left(slashIdx),
- ProjectPart::HeaderPath::FrameworkPath);
+ hp = ProjectPartHeaderPath(includeFile.left(slashIdx),
+ ProjectPartHeaderPath::FrameworkPath);
}
}
@@ -548,7 +424,7 @@ void CompilerOptionsBuilder::addDefine(const QByteArray &defineLine)
void CompilerOptionsBuilder::addHeaderPathOptions()
{
- typedef ProjectPart::HeaderPath HeaderPath;
+ typedef ProjectPartHeaderPath HeaderPath;
const QString defaultPrefix = includeOption();
QStringList result;
diff --git a/src/plugins/cpptools/cppprojects.h b/src/plugins/cpptools/cppprojects.h
index 3d8ddba0be..d6257abb3f 100644
--- a/src/plugins/cpptools/cppprojects.h
+++ b/src/plugins/cpptools/cppprojects.h
@@ -34,6 +34,7 @@
#include "cpptools_global.h"
#include "cppprojectfile.h"
+#include "projectpart.h"
#include <projectexplorer/toolchain.h>
@@ -51,99 +52,6 @@ namespace Utils { class FileName; }
namespace CppTools {
class ProjectFile;
-class CPPTOOLS_EXPORT ProjectPart
-{
-public: // Types
- enum LanguageVersion {
- C89,
- C99,
- C11,
- CXX98,
- CXX03,
- CXX11,
- CXX14,
- CXX17
- };
-
- enum LanguageExtension {
- NoExtensions = 0,
- GnuExtensions = 1 << 0,
- MicrosoftExtensions = 1 << 1,
- BorlandExtensions = 1 << 2,
- OpenMPExtensions = 1 << 3,
- ObjectiveCExtensions = 1 << 4,
-
- AllExtensions = GnuExtensions | MicrosoftExtensions | BorlandExtensions | OpenMPExtensions
- | ObjectiveCExtensions
- };
- Q_DECLARE_FLAGS(LanguageExtensions, LanguageExtension)
-
- enum QtVersion {
- UnknownQt = -1,
- NoQt = 0,
- Qt4 = 1,
- Qt5 = 2
- };
-
- typedef QSharedPointer<ProjectPart> Ptr;
-
- struct HeaderPath {
- enum Type { InvalidPath, IncludePath, FrameworkPath };
-
- public:
- QString path;
- Type type;
-
- HeaderPath(): type(InvalidPath) {}
- HeaderPath(const QString &path, Type type): path(path), type(type) {}
-
- bool isValid() const { return type != InvalidPath; }
- bool isFrameworkPath() const { return type == FrameworkPath; }
-
- bool operator==(const HeaderPath &other) const
- { return path == other.path && type == other.type; }
-
- bool operator!=(const HeaderPath &other) const
- { return !(*this == other); }
- };
- typedef QList<HeaderPath> HeaderPaths;
-
-public: // methods
- ProjectPart();
-
- void evaluateToolchain(const ProjectExplorer::ToolChain *tc,
- const QStringList &commandLineFlags,
- const Utils::FileName &sysRoot);
-
- void updateLanguageFeatures();
- Ptr copy() const;
-
- QString id() const;
-
- static QByteArray readProjectConfigFile(const ProjectPart::Ptr &part);
-
-public: // fields
- QString displayName;
- QString projectFile;
- ProjectExplorer::Project *project;
- QList<ProjectFile> files;
- QString projectConfigFile; // currently only used by the Generic Project Manager
- QByteArray projectDefines;
- QByteArray toolchainDefines;
- Core::Id toolchainType;
- QList<HeaderPath> headerPaths;
- QStringList precompiledHeaders;
- LanguageVersion languageVersion;
- LanguageExtensions languageExtensions;
- CPlusPlus::LanguageFeatures languageFeatures;
- QtVersion qtVersion;
- ProjectExplorer::ToolChain::WarningFlags warningFlags;
- bool selectedForBuilding;
-};
-
-inline uint qHash(const ProjectPart::HeaderPath &key, uint seed = 0)
-{ return ((qHash(key.path) << 2) | key.type) ^ seed; }
-
class CPPTOOLS_EXPORT ProjectInfo
{
public:
@@ -164,7 +72,7 @@ public:
void appendProjectPart(const ProjectPart::Ptr &part);
void finish();
- const ProjectPart::HeaderPaths headerPaths() const;
+ const ProjectPartHeaderPaths headerPaths() const;
const QSet<QString> sourceFiles() const;
const QByteArray defines() const;
@@ -178,7 +86,7 @@ private:
QList<ProjectPart::Ptr> m_projectParts;
CompilerCallData m_compilerCallData;
// The members below are (re)calculated from the project parts with finish()
- ProjectPart::HeaderPaths m_headerPaths;
+ ProjectPartHeaderPaths m_headerPaths;
QSet<QString> m_sourceFiles;
QByteArray m_defines;
};
@@ -192,7 +100,7 @@ public:
void setCFlags(const QStringList &flags);
void setCxxFlags(const QStringList &flags);
void setDefines(const QByteArray &defines);
- void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
+ void setHeaderPaths(const ProjectPartHeaderPaths &headerPaths);
void setIncludePaths(const QStringList &includePaths);
void setPreCompiledHeaders(const QStringList &pchs);
void setProjectFile(const QString &projectFile);
diff --git a/src/plugins/cpptools/cppsourceprocessor.cpp b/src/plugins/cpptools/cppsourceprocessor.cpp
index 036435d692..df9d03d80b 100644
--- a/src/plugins/cpptools/cppsourceprocessor.cpp
+++ b/src/plugins/cpptools/cppsourceprocessor.cpp
@@ -129,15 +129,15 @@ CppSourceProcessor::~CppSourceProcessor()
void CppSourceProcessor::setWorkingCopy(const WorkingCopy &workingCopy)
{ m_workingCopy = workingCopy; }
-void CppSourceProcessor::setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths)
+void CppSourceProcessor::setHeaderPaths(const ProjectPartHeaderPaths &headerPaths)
{
m_headerPaths.clear();
for (int i = 0, ei = headerPaths.size(); i < ei; ++i) {
- const ProjectPart::HeaderPath &path = headerPaths.at(i);
+ const ProjectPartHeaderPath &path = headerPaths.at(i);
- if (path.type == ProjectPart::HeaderPath::IncludePath)
- m_headerPaths.append(ProjectPart::HeaderPath(cleanPath(path.path), path.type));
+ if (path.type == ProjectPartHeaderPath::IncludePath)
+ m_headerPaths.append(ProjectPartHeaderPath(cleanPath(path.path), path.type));
else
addFrameworkPath(path);
}
@@ -155,15 +155,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 ProjectPart::HeaderPath &frameworkPath)
+void CppSourceProcessor::addFrameworkPath(const ProjectPartHeaderPath &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 ProjectPart::HeaderPath cleanFrameworkPath(cleanPath(frameworkPath.path),
- frameworkPath.type);
+ const ProjectPartHeaderPath cleanFrameworkPath(cleanPath(frameworkPath.path),
+ frameworkPath.type);
if (!m_headerPaths.contains(cleanFrameworkPath))
m_headerPaths.append(cleanFrameworkPath);
@@ -175,8 +175,8 @@ void CppSourceProcessor::addFrameworkPath(const ProjectPart::HeaderPath &framewo
const QFileInfo privateFrameworks(framework.absoluteFilePath(),
QLatin1String("Frameworks"));
if (privateFrameworks.exists() && privateFrameworks.isDir())
- addFrameworkPath(ProjectPart::HeaderPath(privateFrameworks.absoluteFilePath(),
- frameworkPath.type));
+ addFrameworkPath(ProjectPartHeaderPath(privateFrameworks.absoluteFilePath(),
+ frameworkPath.type));
}
}
@@ -312,7 +312,7 @@ QString CppSourceProcessor::resolveFile_helper(const QString &fileName, IncludeT
const QString name = frameworkName + QLatin1String(".framework/Headers/")
+ fileName.mid(index + 1);
- foreach (const ProjectPart::HeaderPath &headerPath, m_headerPaths) {
+ foreach (const ProjectPartHeaderPath &headerPath, m_headerPaths) {
if (!headerPath.isFrameworkPath())
continue;
const QString path = headerPath.path + name;
diff --git a/src/plugins/cpptools/cppsourceprocessor.h b/src/plugins/cpptools/cppsourceprocessor.h
index 2b4d805a54..e72ae45062 100644
--- a/src/plugins/cpptools/cppsourceprocessor.h
+++ b/src/plugins/cpptools/cppsourceprocessor.h
@@ -66,7 +66,7 @@ public:
~CppSourceProcessor();
void setWorkingCopy(const CppTools::WorkingCopy &workingCopy);
- void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
+ void setHeaderPaths(const ProjectPartHeaderPaths &headerPaths);
void setLanguageFeatures(CPlusPlus::LanguageFeatures languageFeatures);
void setTodo(const QSet<QString> &files);
@@ -80,7 +80,7 @@ public:
void setGlobalSnapshot(const CPlusPlus::Snapshot &snapshot) { m_globalSnapshot = snapshot; }
private:
- void addFrameworkPath(const ProjectPart::HeaderPath &frameworkPath);
+ void addFrameworkPath(const ProjectPartHeaderPath &frameworkPath);
CPlusPlus::Document::Ptr switchCurrentDocument(CPlusPlus::Document::Ptr doc);
@@ -116,7 +116,7 @@ private:
DocumentCallback m_documentFinished;
CPlusPlus::Environment m_env;
CPlusPlus::Preprocessor m_preprocess;
- ProjectPart::HeaderPaths m_headerPaths;
+ ProjectPartHeaderPaths m_headerPaths;
CPlusPlus::LanguageFeatures m_languageFeatures;
CppTools::WorkingCopy m_workingCopy;
QSet<QString> m_included;
diff --git a/src/plugins/cpptools/cppsourceprocessor_test.cpp b/src/plugins/cpptools/cppsourceprocessor_test.cpp
index bdc2cf2a38..487003f8c8 100644
--- a/src/plugins/cpptools/cppsourceprocessor_test.cpp
+++ b/src/plugins/cpptools/cppsourceprocessor_test.cpp
@@ -68,9 +68,9 @@ public:
{
QScopedPointer<CppSourceProcessor> sourceProcessor(
CppModelManager::createSourceProcessor());
- const ProjectPart::HeaderPath hp(TestIncludePaths::directoryOfTestFile(),
- ProjectPart::HeaderPath::IncludePath);
- sourceProcessor->setHeaderPaths(ProjectPart::HeaderPaths() << hp);
+ const ProjectPartHeaderPath hp(TestIncludePaths::directoryOfTestFile(),
+ ProjectPartHeaderPath::IncludePath);
+ sourceProcessor->setHeaderPaths(ProjectPartHeaderPaths() << hp);
sourceProcessor->run(filePath);
Document::Ptr document = m_cmm->document(filePath);
@@ -212,9 +212,9 @@ void CppToolsPlugin::test_cppsourceprocessor_includeNext()
CppSourceProcessor::DocumentCallback documentCallback = [](const Document::Ptr &){};
CppSourceProcessor sourceProcessor(Snapshot(), documentCallback);
- ProjectPart::HeaderPaths headerPaths = ProjectPart::HeaderPaths()
- << ProjectPart::HeaderPath(customHeaderPath, ProjectPart::HeaderPath::IncludePath)
- << ProjectPart::HeaderPath(systemHeaderPath, ProjectPart::HeaderPath::IncludePath);
+ ProjectPartHeaderPaths headerPaths = ProjectPartHeaderPaths()
+ << ProjectPartHeaderPath(customHeaderPath, ProjectPartHeaderPath::IncludePath)
+ << ProjectPartHeaderPath(systemHeaderPath, ProjectPartHeaderPath::IncludePath);
sourceProcessor.setHeaderPaths(headerPaths);
sourceProcessor.run(mainFilePath);
diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro
index 9004507bd8..c2bd7d89e2 100644
--- a/src/plugins/cpptools/cpptools.pro
+++ b/src/plugins/cpptools/cpptools.pro
@@ -69,7 +69,9 @@ HEADERS += \
senddocumenttracker.h \
cpptoolsbridge.h \
cpptoolsbridgeinterface.h \
- cpptoolsbridgeqtcreatorimplementation.h
+ cpptoolsbridgeqtcreatorimplementation.h \
+ projectpart.h \
+ projectpartheaderpath.h
SOURCES += \
abstracteditorsupport.cpp \
@@ -135,7 +137,8 @@ SOURCES += \
typehierarchybuilder.cpp \
senddocumenttracker.cpp \
cpptoolsbridge.cpp \
- cpptoolsbridgeqtcreatorimplementation.cpp
+ cpptoolsbridgeqtcreatorimplementation.cpp \
+ projectpart.cpp
FORMS += \
completionsettingspage.ui \
diff --git a/src/plugins/cpptools/cpptools.qbs b/src/plugins/cpptools/cpptools.qbs
index dd4a7ce1d1..f7ec8e0d14 100644
--- a/src/plugins/cpptools/cpptools.qbs
+++ b/src/plugins/cpptools/cpptools.qbs
@@ -86,6 +86,8 @@ QtcPlugin {
"includeutils.cpp", "includeutils.h",
"indexitem.cpp", "indexitem.h",
"insertionpointlocator.cpp", "insertionpointlocator.h",
+ "projectpart.cpp", "projectpart.h",
+ "projectpartheaderpath.h",
"searchsymbols.cpp", "searchsymbols.h",
"semantichighlighter.cpp", "semantichighlighter.h",
"senddocumenttracker.cpp", "senddocumenttracker.h",
diff --git a/src/plugins/cpptools/includeutils.cpp b/src/plugins/cpptools/includeutils.cpp
index fa4beb6786..114efb80fd 100644
--- a/src/plugins/cpptools/includeutils.cpp
+++ b/src/plugins/cpptools/includeutils.cpp
@@ -542,10 +542,10 @@ static QList<Include> includesForSource(const QString &filePath)
CppModelManager *cmm = CppModelManager::instance();
cmm->GC();
QScopedPointer<CppSourceProcessor> sourceProcessor(CppModelManager::createSourceProcessor());
- sourceProcessor->setHeaderPaths(ProjectPart::HeaderPaths()
- << ProjectPart::HeaderPath(
+ sourceProcessor->setHeaderPaths(ProjectPartHeaderPaths()
+ << ProjectPartHeaderPath(
TestIncludePaths::globalIncludePath(),
- ProjectPart::HeaderPath::IncludePath));
+ ProjectPartHeaderPath::IncludePath));
sourceProcessor->run(filePath);
Document::Ptr document = cmm->document(filePath);
diff --git a/src/plugins/cpptools/projectpart.cpp b/src/plugins/cpptools/projectpart.cpp
new file mode 100644
index 0000000000..bd7a1138b7
--- /dev/null
+++ b/src/plugins/cpptools/projectpart.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+#include "projectpart.h"
+
+#include <projectexplorer/headerpath.h>
+
+#include <QDir>
+#include <QTextStream>
+
+namespace CppTools {
+
+ProjectPart::ProjectPart()
+ : project(0)
+ , languageVersion(CXX14)
+ , languageExtensions(NoExtensions)
+ , qtVersion(UnknownQt)
+ , warningFlags(ProjectExplorer::ToolChain::WarningsDefault)
+ , selectedForBuilding(true)
+{
+}
+
+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);
+}
+
+/*!
+ \brief Retrieves info from concrete compiler using it's flags.
+
+ \param tc Either nullptr or toolchain for project's active target.
+ \param cxxflags C++ or Objective-C++ flags.
+ \param cflags C or ObjectiveC flags if possible, \a cxxflags otherwise.
+*/
+void ProjectPart::evaluateToolchain(const ProjectExplorer::ToolChain *tc,
+ const QStringList &commandLineFlags,
+ const Utils::FileName &sysRoot)
+{
+ if (!tc)
+ return;
+
+ using namespace ProjectExplorer;
+ ToolChain::CompilerFlags flags = tc->compilerFlags(commandLineFlags);
+
+ if (flags & ToolChain::StandardC11)
+ languageVersion = C11;
+ else if (flags & ToolChain::StandardC99)
+ languageVersion = C99;
+ else if (flags & ToolChain::StandardCxx17)
+ languageVersion = CXX17;
+ else if (flags & ToolChain::StandardCxx14)
+ languageVersion = CXX14;
+ else if (flags & ToolChain::StandardCxx11)
+ languageVersion = CXX11;
+ else if (flags & ToolChain::StandardCxx98)
+ languageVersion = CXX98;
+ else
+ languageVersion = CXX11;
+
+ if (flags & ToolChain::BorlandExtensions)
+ languageExtensions |= BorlandExtensions;
+ if (flags & ToolChain::GnuExtensions)
+ languageExtensions |= GnuExtensions;
+ if (flags & ToolChain::MicrosoftExtensions)
+ languageExtensions |= MicrosoftExtensions;
+ if (flags & ToolChain::OpenMP)
+ languageExtensions |= OpenMPExtensions;
+ if (flags & ToolChain::ObjectiveC)
+ languageExtensions |= ObjectiveCExtensions;
+
+ warningFlags = tc->warningFlags(commandLineFlags);
+
+ const QList<ProjectExplorer::HeaderPath> headers = tc->systemHeaderPaths(commandLineFlags, sysRoot);
+ foreach (const ProjectExplorer::HeaderPath &header, headers) {
+ const ProjectPartHeaderPath headerPath = toProjectPartHeaderPath(header);
+ if (!headerPaths.contains(headerPath))
+ headerPaths << headerPath;
+ }
+
+ toolchainDefines = tc->predefinedMacros(commandLineFlags);
+ toolchainType = tc->typeId();
+ updateLanguageFeatures();
+}
+
+void ProjectPart::updateLanguageFeatures()
+{
+ const bool hasQt = qtVersion != NoQt;
+ languageFeatures.cxx11Enabled = languageVersion >= CXX11;
+ languageFeatures.qtEnabled = hasQt;
+ languageFeatures.qtMocRunEnabled = hasQt;
+ if (!hasQt) {
+ languageFeatures.qtKeywordsEnabled = false;
+ } else {
+ const QByteArray noKeywordsMacro = "#define QT_NO_KEYWORDS";
+ const int noKeywordsIndex = projectDefines.indexOf(noKeywordsMacro);
+ if (noKeywordsIndex == -1) {
+ languageFeatures.qtKeywordsEnabled = true;
+ } else {
+ const char nextChar = projectDefines.at(noKeywordsIndex + noKeywordsMacro.length());
+ // Detect "#define QT_NO_KEYWORDS" and "#define QT_NO_KEYWORDS 1", but exclude
+ // "#define QT_NO_KEYWORDS_FOO"
+ languageFeatures.qtKeywordsEnabled = nextChar != '\n' && nextChar != ' ';
+ }
+ }
+}
+
+ProjectPart::Ptr ProjectPart::copy() const
+{
+ return Ptr(new ProjectPart(*this));
+}
+
+QString ProjectPart::id() const
+{
+ QString projectPartId = QDir::fromNativeSeparators(projectFile);
+ if (!displayName.isEmpty())
+ projectPartId.append(QLatin1Char(' ') + displayName);
+ return projectPartId;
+}
+
+QByteArray ProjectPart::readProjectConfigFile(const ProjectPart::Ptr &part)
+{
+ QByteArray result;
+
+ QFile f(part->projectConfigFile);
+ if (f.open(QIODevice::ReadOnly)) {
+ QTextStream is(&f);
+ result = is.readAll().toUtf8();
+ f.close();
+ }
+
+ return result;
+}
+
+} // namespace CppTools
diff --git a/src/plugins/cpptools/projectpart.h b/src/plugins/cpptools/projectpart.h
new file mode 100644
index 0000000000..a04299cb0b
--- /dev/null
+++ b/src/plugins/cpptools/projectpart.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+#ifndef CPPTOOLS_PROJECTPART_H
+#define CPPTOOLS_PROJECTPART_H
+
+#include "cpptools_global.h"
+
+#include "cppprojectfile.h"
+#include "projectpartheaderpath.h"
+
+#include <projectexplorer/toolchain.h>
+
+#include <coreplugin/id.h>
+
+#include <utils/fileutils.h>
+
+#include <cplusplus/Token.h>
+
+#include <QString>
+#include <QSharedPointer>
+
+namespace ProjectExplorer {
+class Project;
+}
+
+namespace CppTools {
+
+class CPPTOOLS_EXPORT ProjectPart
+{
+public: // Types
+ enum LanguageVersion {
+ C89,
+ C99,
+ C11,
+ CXX98,
+ CXX03,
+ CXX11,
+ CXX14,
+ CXX17
+ };
+
+ enum LanguageExtension {
+ NoExtensions = 0,
+ GnuExtensions = 1 << 0,
+ MicrosoftExtensions = 1 << 1,
+ BorlandExtensions = 1 << 2,
+ OpenMPExtensions = 1 << 3,
+ ObjectiveCExtensions = 1 << 4,
+
+ AllExtensions = GnuExtensions | MicrosoftExtensions | BorlandExtensions | OpenMPExtensions
+ | ObjectiveCExtensions
+ };
+ Q_DECLARE_FLAGS(LanguageExtensions, LanguageExtension)
+
+ enum QtVersion {
+ UnknownQt = -1,
+ NoQt = 0,
+ Qt4 = 1,
+ Qt5 = 2
+ };
+
+ using Ptr = QSharedPointer<ProjectPart>;
+
+
+public: // methods
+ ProjectPart();
+
+ void evaluateToolchain(const ProjectExplorer::ToolChain *tc,
+ const QStringList &commandLineFlags,
+ const Utils::FileName &sysRoot);
+
+ void updateLanguageFeatures();
+ Ptr copy() const;
+
+ QString id() const;
+
+ static QByteArray readProjectConfigFile(const ProjectPart::Ptr &part);
+
+public: // fields
+ QString displayName;
+ QString projectFile;
+ ProjectExplorer::Project *project;
+ QVector<ProjectFile> files;
+ QString projectConfigFile; // currently only used by the Generic Project Manager
+ QByteArray projectDefines;
+ QByteArray toolchainDefines;
+ Core::Id toolchainType;
+ ProjectPartHeaderPaths headerPaths;
+ QStringList precompiledHeaders;
+ LanguageVersion languageVersion;
+ LanguageExtensions languageExtensions;
+ CPlusPlus::LanguageFeatures languageFeatures;
+ QtVersion qtVersion;
+ ProjectExplorer::ToolChain::WarningFlags warningFlags;
+ bool selectedForBuilding;
+};
+
+} // namespace CppTools
+
+#endif // CPPTOOLS_PROJECTPART_H
diff --git a/src/plugins/cpptools/projectpartheaderpath.h b/src/plugins/cpptools/projectpartheaderpath.h
new file mode 100644
index 0000000000..7ba86ae132
--- /dev/null
+++ b/src/plugins/cpptools/projectpartheaderpath.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#ifndef PROJECTPARTHEADERPATH_H
+#define PROJECTPARTHEADERPATH_H
+
+#include <QVector>
+
+namespace CppTools {
+
+struct ProjectPartHeaderPath {
+ enum Type {
+ InvalidPath,
+ IncludePath,
+ FrameworkPath
+ };
+
+public:
+ 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
+#endif // PROJECTPARTHEADERPATH_H
diff --git a/src/plugins/genericprojectmanager/genericprojectplugin_test.cpp b/src/plugins/genericprojectmanager/genericprojectplugin_test.cpp
index 2be04fd3d7..f6694fef78 100644
--- a/src/plugins/genericprojectmanager/genericprojectplugin_test.cpp
+++ b/src/plugins/genericprojectmanager/genericprojectplugin_test.cpp
@@ -78,7 +78,7 @@ void GenericProjectPlugin::test_simple()
QCOMPARE(pPart->files.first().kind, ProjectFile::CXXSource);
}
-static QStringList simplify(const QList<ProjectFile> &files, const QString &prefix)
+static QStringList simplify(const QVector<ProjectFile> &files, const QString &prefix)
{
QStringList result;
diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp
index 065cfa3109..e5ed08847f 100644
--- a/src/plugins/qbsprojectmanager/qbsproject.cpp
+++ b/src/plugins/qbsprojectmanager/qbsproject.cpp
@@ -728,20 +728,20 @@ void QbsProject::updateCppCodeModel()
QLatin1String(CONFIG_INCLUDEPATHS));
list.append(props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_SYSTEM_INCLUDEPATHS)));
- CppTools::ProjectPart::HeaderPaths grpHeaderPaths;
+ CppTools::ProjectPartHeaderPaths grpHeaderPaths;
foreach (const QString &p, list)
- grpHeaderPaths += CppTools::ProjectPart::HeaderPath(
+ grpHeaderPaths += CppTools::ProjectPartHeaderPath(
FileName::fromUserInput(p).toString(),
- CppTools::ProjectPart::HeaderPath::IncludePath);
+ CppTools::ProjectPartHeaderPath::IncludePath);
list = props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_FRAMEWORKPATHS));
list.append(props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_SYSTEM_FRAMEWORKPATHS)));
foreach (const QString &p, list)
- grpHeaderPaths += CppTools::ProjectPart::HeaderPath(
+ grpHeaderPaths += CppTools::ProjectPartHeaderPath(
FileName::fromUserInput(p).toString(),
- CppTools::ProjectPart::HeaderPath::FrameworkPath);
+ CppTools::ProjectPartHeaderPath::FrameworkPath);
ppBuilder.setHeaderPaths(grpHeaderPaths);
diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
index a6a31990b8..539e06794f 100644
--- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
@@ -44,6 +44,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <cpptools/cppmodelmanager.h>
+#include <cpptools/projectpartheaderpath.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/buildtargetinfo.h>
@@ -469,16 +470,16 @@ void QmakeProject::updateCppCodeModel()
foreach (const QString &inc, pro->variableValue(IncludePathVar)) {
const auto headerPath
- = ProjectPart::HeaderPath(inc, ProjectPart::HeaderPath::IncludePath);
+ = CppTools::ProjectPartHeaderPath(inc, CppTools::ProjectPartHeaderPath::IncludePath);
if (!templatePart->headerPaths.contains(headerPath))
templatePart->headerPaths += headerPath;
}
if (qtVersion) {
if (!qtVersion->frameworkInstallPath().isEmpty()) {
- templatePart->headerPaths += ProjectPart::HeaderPath(
+ templatePart->headerPaths += CppTools::ProjectPartHeaderPath(
qtVersion->frameworkInstallPath(),
- ProjectPart::HeaderPath::FrameworkPath);
+ CppTools::ProjectPartHeaderPath::FrameworkPath);
}
}