summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsproject.cpp5
-rw-r--r--src/plugins/clangcodemodel/clangcompletion.cpp39
-rw-r--r--src/plugins/clangcodemodel/clangcompletion.h14
-rw-r--r--src/plugins/clangcodemodel/clangutils.cpp19
-rw-r--r--src/plugins/clangcodemodel/pchmanager.cpp17
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.cpp13
-rw-r--r--src/plugins/cppeditor/cppcodemodelinspectordialog.cpp31
-rw-r--r--src/plugins/cppeditor/cppcodemodelinspectordialog.ui18
-rw-r--r--src/plugins/cppeditor/cppquickfix_test.cpp79
-rw-r--r--src/plugins/cppeditor/cppquickfix_test.h9
-rw-r--r--src/plugins/cppeditor/cppquickfixes.cpp18
-rw-r--r--src/plugins/cpptools/builtinindexingsupport.cpp13
-rw-r--r--src/plugins/cpptools/cppcodemodelinspectordumper.cpp42
-rw-r--r--src/plugins/cpptools/cppcodemodelinspectordumper.h4
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp2
-rw-r--r--src/plugins/cpptools/cppcompletionassist.cpp28
-rw-r--r--src/plugins/cpptools/cppcompletionassist.h13
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp44
-rw-r--r--src/plugins/cpptools/cppmodelmanager.h20
-rw-r--r--src/plugins/cpptools/cppmodelmanager_test.cpp55
-rw-r--r--src/plugins/cpptools/cppmodelmanagerinterface.cpp36
-rw-r--r--src/plugins/cpptools/cppmodelmanagerinterface.h42
-rw-r--r--src/plugins/cpptools/cppsnapshotupdater.cpp28
-rw-r--r--src/plugins/cpptools/cppsnapshotupdater.h6
-rw-r--r--src/plugins/cpptools/cppsourceprocessor.cpp67
-rw-r--r--src/plugins/cpptools/cppsourceprocessor.h8
-rw-r--r--src/plugins/cpptools/cppsourceprocessor_test.cpp4
-rw-r--r--src/plugins/cpptools/includeutils.cpp5
-rw-r--r--src/plugins/cpptools/modelmanagertesthelper.cpp3
-rw-r--r--src/plugins/genericprojectmanager/genericproject.cpp4
-rw-r--r--src/plugins/qbsprojectmanager/qbsproject.cpp22
-rw-r--r--src/plugins/qmakeprojectmanager/qmakeproject.cpp21
32 files changed, 356 insertions, 373 deletions
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
index 4c0573a38a..e9c5642868 100644
--- a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
+++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp
@@ -427,7 +427,10 @@ void AutotoolsProject::updateCppCodeModel()
foreach (const QString &file, m_files)
part->files << CppTools::ProjectFile(file, CppTools::ProjectFile::CXXSource);
- part->includePaths += m_makefileParserThread->includePaths();
+ foreach (const QString &inc, m_makefileParserThread->includePaths()) {
+ part->headerPaths += CppTools::ProjectPart::HeaderPath(
+ inc, CppTools::ProjectPart::HeaderPath::IncludePath);
+ }
part->projectDefines += m_makefileParserThread->defines();
pinfo.appendProjectPart(part);
diff --git a/src/plugins/clangcodemodel/clangcompletion.cpp b/src/plugins/clangcodemodel/clangcompletion.cpp
index 3e49295749..90ed1d7794 100644
--- a/src/plugins/clangcodemodel/clangcompletion.cpp
+++ b/src/plugins/clangcodemodel/clangcompletion.cpp
@@ -213,7 +213,8 @@ IAssistInterface *ClangCompletionAssistProvider::createAssistInterface(
QList<ProjectPart::Ptr> parts = modelManager->projectPart(fileName);
if (parts.isEmpty())
parts += modelManager->fallbackProjectPart();
- QStringList includePaths, frameworkPaths, options;
+ ProjectPart::HeaderPaths headerPaths;
+ QStringList options;
PchInfo::Ptr pchInfo;
foreach (ProjectPart::Ptr part, parts) {
if (part.isNull())
@@ -222,15 +223,14 @@ IAssistInterface *ClangCompletionAssistProvider::createAssistInterface(
pchInfo = PchManager::instance()->pchInfo(part);
if (!pchInfo.isNull())
options.append(ClangCodeModel::Utils::createPCHInclusionOptions(pchInfo->fileName()));
- includePaths = part->includePaths;
- frameworkPaths = part->frameworkPaths;
+ headerPaths = part->headerPaths;
break;
}
return new ClangCodeModel::ClangCompletionAssistInterface(
m_clangCompletionWrapper,
document, position, fileName, reason,
- options, includePaths, frameworkPaths, pchInfo);
+ options, headerPaths, pchInfo);
}
// ------------------------
@@ -550,14 +550,12 @@ ClangCompletionAssistInterface::ClangCompletionAssistInterface(ClangCompleter::P
const QString &fileName,
AssistReason reason,
const QStringList &options,
- const QStringList &includePaths,
- const QStringList &frameworkPaths,
+ const QList<CppTools::ProjectPart::HeaderPath> &headerPaths,
const PchInfo::Ptr &pchInfo)
: DefaultAssistInterface(document, position, fileName, reason)
, m_clangWrapper(clangWrapper)
, m_options(options)
- , m_includePaths(includePaths)
- , m_frameworkPaths(frameworkPaths)
+ , m_headerPaths(headerPaths)
, m_savedPchPointer(pchInfo)
{
Q_ASSERT(!clangWrapper.isNull());
@@ -1138,29 +1136,22 @@ bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
}
// Make completion for all relevant includes
- QStringList includePaths = m_interface->includePaths();
- const QString &currentFilePath = QFileInfo(m_interface->fileName()).path();
- if (!includePaths.contains(currentFilePath))
- includePaths.append(currentFilePath);
+ ProjectPart::HeaderPaths headerPaths = m_interface->headerPaths();
+ const ProjectPart::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
+ ProjectPart::HeaderPath::IncludePath);
+ if (!headerPaths.contains(currentFilePath))
+ headerPaths.append(currentFilePath);
const Core::MimeType mimeType = Core::MimeDatabase::findByType(QLatin1String("text/x-c++hdr"));
const QStringList suffixes = mimeType.suffixes();
- foreach (const QString &includePath, includePaths) {
- QString realPath = includePath;
+ foreach (const ProjectPart::HeaderPath &headerPath, headerPaths) {
+ QString realPath = headerPath.path;
if (!directoryPrefix.isEmpty()) {
realPath += QLatin1Char('/');
realPath += directoryPrefix;
- }
- completeIncludePath(realPath, suffixes);
- }
-
- foreach (const QString &frameworkPath, m_interface->frameworkPaths()) {
- QString realPath = frameworkPath;
- if (!directoryPrefix.isEmpty()) {
- realPath += QLatin1Char('/');
- realPath += directoryPrefix;
- realPath += QLatin1String(".framework/Headers");
+ if (headerPath.isFrameworkPath())
+ realPath += QLatin1String(".framework/Headers");
}
completeIncludePath(realPath, suffixes);
}
diff --git a/src/plugins/clangcodemodel/clangcompletion.h b/src/plugins/clangcodemodel/clangcompletion.h
index 2e07b034c3..180d7ec763 100644
--- a/src/plugins/clangcodemodel/clangcompletion.h
+++ b/src/plugins/clangcodemodel/clangcompletion.h
@@ -35,6 +35,7 @@
#include <cplusplus/Icons.h>
#include <cpptools/cppcompletionassistprovider.h>
+#include <cpptools/cppmodelmanagerinterface.h>
#include <texteditor/codeassist/basicproposalitem.h>
#include <texteditor/codeassist/completionassistprovider.h>
@@ -76,8 +77,7 @@ public:
const QString &fileName,
TextEditor::AssistReason reason,
const QStringList &options,
- const QStringList &includePaths,
- const QStringList &frameworkPaths,
+ const QList<CppTools::ProjectPart::HeaderPath> &headerPaths,
const Internal::PchInfo::Ptr &pchInfo);
ClangCodeModel::ClangCompleter::Ptr clangWrapper() const
@@ -91,16 +91,14 @@ public:
const QStringList &options() const
{ return m_options; }
- const QStringList &includePaths() const
- { return m_includePaths; }
-
- const QStringList &frameworkPaths() const
- { return m_frameworkPaths; }
+ const QList<CppTools::ProjectPart::HeaderPath> &headerPaths() const
+ { return m_headerPaths; }
private:
ClangCodeModel::ClangCompleter::Ptr m_clangWrapper;
ClangCodeModel::Internal::UnsavedFiles m_unsavedFiles;
- QStringList m_options, m_includePaths, m_frameworkPaths;
+ QStringList m_options;
+ QList<CppTools::ProjectPart::HeaderPath> m_headerPaths;
Internal::PchInfo::Ptr m_savedPchPointer;
};
diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp
index 9a8dede302..db72ada454 100644
--- a/src/plugins/clangcodemodel/clangutils.cpp
+++ b/src/plugins/clangcodemodel/clangutils.cpp
@@ -209,11 +209,20 @@ QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind
result << buildDefines(pPart->toolchainDefines, false);
result << buildDefines(pPart->projectDefines, false);
- foreach (const QString &frameworkPath, pPart->frameworkPaths)
- result.append(QLatin1String("-F") + frameworkPath);
- foreach (const QString &inc, pPart->includePaths)
- if (!inc.isEmpty() && !isBlacklisted(inc))
- result << (QLatin1String("-I") + inc);
+ typedef ProjectPart::HeaderPath HeaderPath;
+ foreach (const HeaderPath &headerPath , pPart->headerPaths) {
+ if (headerPath.path.isEmpty() || isBlacklisted(headerPath.path))
+ continue;
+
+ QString prefix;
+ switch (headerPath.type) {
+ case HeaderPath::IncludePath: prefix = QLatin1String("-I"); break;
+ case HeaderPath::FrameworkPath: prefix = QLatin1String("-F"); break;
+ default: Q_UNREACHABLE(); break;
+ }
+
+ result.append(prefix + headerPath.path);
+ }
#if 0
qDebug() << "--- m_args:";
diff --git a/src/plugins/clangcodemodel/pchmanager.cpp b/src/plugins/clangcodemodel/pchmanager.cpp
index 6733cd83c2..55a23f6a40 100644
--- a/src/plugins/clangcodemodel/pchmanager.cpp
+++ b/src/plugins/clangcodemodel/pchmanager.cpp
@@ -249,7 +249,8 @@ void PchManager::doPchInfoUpdateNone(QFutureInterface<void> &future,
void PchManager::doPchInfoUpdateFuzzy(QFutureInterface<void> &future,
const PchManager::UpdateParams params)
{
- QHash<QString, QSet<QString> > includes, frameworks;
+ typedef ProjectPart::HeaderPath HeaderPath;
+ QHash<QString, QSet<HeaderPath>> headers;
QHash<QString, QSet<QByteArray> > definesPerPCH;
QHash<QString, bool> objc;
QHash<QString, bool> cplusplus;
@@ -266,8 +267,7 @@ void PchManager::doPchInfoUpdateFuzzy(QFutureInterface<void> &future,
continue;
inputToParts[pch].append(projectPart);
- includes[pch].unite(QSet<QString>::fromList(projectPart->includePaths));
- frameworks[pch].unite(QSet<QString>::fromList(projectPart->frameworkPaths));
+ headers[pch].unite(QSet<HeaderPath>::fromList(projectPart->headerPaths));
cVersions[pch] = std::max(cVersions.value(pch, ProjectPart::C89), projectPart->cVersion);
cxxVersions[pch] = std::max(cxxVersions.value(pch, ProjectPart::CXX98), projectPart->cxxVersion);
cxxExtensionsMap[pch] = cxxExtensionsMap[pch] | projectPart->cxxExtensions;
@@ -306,8 +306,7 @@ void PchManager::doPchInfoUpdateFuzzy(QFutureInterface<void> &future,
projectPart->cVersion = cVersions[pch];
projectPart->cxxVersion = cxxVersions[pch];
projectPart->cxxExtensions = cxxExtensionsMap[pch];
- projectPart->includePaths = includes[pch].toList();
- projectPart->frameworkPaths = frameworks[pch].toList();
+ projectPart->headerPaths = headers[pch].toList();
QList<QByteArray> defines = definesPerPCH[pch].toList();
if (!defines.isEmpty()) {
@@ -378,22 +377,20 @@ void PchManager::doPchInfoUpdateCustom(QFutureInterface<void> &future,
future.setProgressRange(0, 1);
future.setProgressValue(0);
- QSet<QString> includes, frameworks;
+ ProjectPart::HeaderPaths headers;
bool objc = false;
bool cplusplus = false;
ProjectPart::Ptr united(new ProjectPart());
united->cxxVersion = ProjectPart::CXX98;
foreach (const ProjectPart::Ptr &projectPart, params.projectParts) {
- includes.unite(QSet<QString>::fromList(projectPart->includePaths));
- frameworks.unite(QSet<QString>::fromList(projectPart->frameworkPaths));
+ headers += projectPart->headerPaths;
united->cVersion = std::max(united->cVersion, projectPart->cVersion);
united->cxxVersion = std::max(united->cxxVersion, projectPart->cxxVersion);
united->qtVersion = std::max(united->qtVersion, projectPart->qtVersion);
objc |= hasObjCFiles(projectPart);
cplusplus |= hasCppFiles(projectPart);
}
- united->frameworkPaths = frameworks.toList();
- united->includePaths = includes.toList();
+ united->headerPaths = headers;
QStringList opts = Utils::createClangOptions(
united, getPrefixFileKind(objc, cplusplus));
united.clear();
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 41c849734d..f6227b4659 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -338,27 +338,32 @@ bool CMakeProject::parseCMakeLists()
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
pinfo.clearProjectParts();
- CppTools::ProjectPart::Ptr part(new CppTools::ProjectPart);
+ typedef CppTools::ProjectPart ProjectPart;
+ ProjectPart::Ptr part(new ProjectPart);
part->project = this;
part->displayName = displayName();
part->projectFile = projectFilePath().toString();
// This explicitly adds -I. to the include paths
- part->includePaths += projectDirectory().toString();
+ part->headerPaths += ProjectPart::HeaderPath(projectDirectory().toString(),
+ ProjectPart::HeaderPath::IncludePath);
foreach (const QString &includeFile, cbpparser.includeFiles()) {
+ ProjectPart::HeaderPath hp(includeFile, ProjectPart::HeaderPath::IncludePath);
+
// CodeBlocks is utterly ignorant of frameworks on Mac, and won't report framework
// paths. The work-around is to check if the include path ends in ".framework", and
// if so, add the parent directory as framework path.
if (includeFile.endsWith(QLatin1String(".framework"))) {
const int slashIdx = includeFile.lastIndexOf(QLatin1Char('/'));
if (slashIdx != -1) {
- part->frameworkPaths += includeFile.left(slashIdx);
+ hp = ProjectPart::HeaderPath(includeFile.left(slashIdx),
+ ProjectPart::HeaderPath::FrameworkPath);
continue;
}
}
- part->includePaths += includeFile;
+ part->headerPaths += hp;
}
part->projectDefines += cbpparser.defines();
diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
index 311afa5914..b150788c40 100644
--- a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
+++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp
@@ -1446,7 +1446,7 @@ void CppCodeModelInspectorDialog::refresh()
}
// Merged entities
- dumper.dumpMergedEntities(cmmi->includePaths(), cmmi->frameworkPaths(), cmmi->definedMacros());
+ dumper.dumpMergedEntities(cmmi->headerPaths(), cmmi->definedMacros());
}
enum DocumentTabs {
@@ -1559,8 +1559,7 @@ enum ProjectPartTabs {
ProjectPartGeneralTab,
ProjectPartFilesTab,
ProjectPartDefinesTab,
- ProjectPartIncludePathsTab,
- ProjectPartFrameworkPathsTab,
+ ProjectPartHeaderPathsTab,
ProjectPartPrecompiledHeadersTab
};
@@ -1570,8 +1569,7 @@ static QString partTabName(int tabIndex, int numberOfEntries = -1)
"&General",
"Project &Files",
"&Defines",
- "&Include Paths",
- "F&ramework Paths",
+ "&Header Paths",
"Pre&compiled Headers"
};
QString result = QLatin1String(names[tabIndex]);
@@ -1591,13 +1589,9 @@ void CppCodeModelInspectorDialog::clearProjectPartData()
m_ui->partProjectDefinesEdit->setPlainText(QString());
m_ui->projectPartTab->setTabText(ProjectPartDefinesTab, partTabName(ProjectPartDefinesTab));
- m_ui->partIncludePathsEdit->setPlainText(QString());
- m_ui->projectPartTab->setTabText(ProjectPartIncludePathsTab,
- partTabName(ProjectPartIncludePathsTab));
-
- m_ui->partFrameworkPathsEdit->setPlainText(QString());
- m_ui->projectPartTab->setTabText(ProjectPartFrameworkPathsTab,
- partTabName(ProjectPartFrameworkPathsTab));
+ m_ui->partHeaderPathsEdit->setPlainText(QString());
+ m_ui->projectPartTab->setTabText(ProjectPartHeaderPathsTab,
+ partTabName(ProjectPartHeaderPathsTab));
m_ui->partPrecompiledHeadersEdit->setPlainText(QString());
m_ui->projectPartTab->setTabText(ProjectPartPrecompiledHeadersTab,
@@ -1654,15 +1648,10 @@ void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Ptr &
m_ui->projectPartTab->setTabText(ProjectPartDefinesTab,
partTabName(ProjectPartDefinesTab, numberOfDefines));
- // Include Paths
- m_ui->partIncludePathsEdit->setPlainText(CMI::Utils::pathListToString(part->includePaths));
- m_ui->projectPartTab->setTabText(ProjectPartIncludePathsTab,
- partTabName(ProjectPartIncludePathsTab, part->includePaths.size()));
-
- // Framework Paths
- m_ui->partFrameworkPathsEdit->setPlainText(CMI::Utils::pathListToString(part->frameworkPaths));
- m_ui->projectPartTab->setTabText(ProjectPartFrameworkPathsTab,
- partTabName(ProjectPartFrameworkPathsTab, part->frameworkPaths.size()));
+ // Header Paths
+ m_ui->partHeaderPathsEdit->setPlainText(CMI::Utils::pathListToString(part->headerPaths));
+ m_ui->projectPartTab->setTabText(ProjectPartHeaderPathsTab,
+ partTabName(ProjectPartHeaderPathsTab, part->headerPaths.size()));
// Precompiled Headers
m_ui->partPrecompiledHeadersEdit->setPlainText(
diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.ui b/src/plugins/cppeditor/cppcodemodelinspectordialog.ui
index fbe95c08a7..3ef29c1f10 100644
--- a/src/plugins/cppeditor/cppcodemodelinspectordialog.ui
+++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.ui
@@ -261,25 +261,11 @@
</widget>
<widget class="QWidget" name="tab_15">
<attribute name="title">
- <string notr="true">&amp;Include Paths</string>
+ <string notr="true">&amp;Header Paths</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
- <widget class="QPlainTextEdit" name="partIncludePathsEdit">
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="definesTab_2">
- <attribute name="title">
- <string notr="true">F&amp;ramework Paths</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout_17">
- <item>
- <widget class="QPlainTextEdit" name="partFrameworkPathsEdit">
+ <widget class="QPlainTextEdit" name="partHeaderPathsEdit">
<property name="readOnly">
<bool>true</bool>
</property>
diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp
index 7e142f5bde..745362f4fe 100644
--- a/src/plugins/cppeditor/cppquickfix_test.cpp
+++ b/src/plugins/cppeditor/cppquickfix_test.cpp
@@ -123,11 +123,11 @@ static QString &removeTrailingWhitespace(QString &input)
/// Exactly one TestFile must contain the cursor position marker '@' in the originalSource.
QuickFixTestCase::QuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &theTestFiles,
CppQuickFixFactory *factory,
- const QStringList &includePaths,
+ const ProjectPart::HeaderPaths &headerPaths,
int resultIndex)
: m_testFiles(theTestFiles)
, m_cppCodeStylePreferences(0)
- , m_restoreIncludePaths(false)
+ , m_restoreHeaderPaths(false)
{
QVERIFY(succeededSoFar());
@@ -144,10 +144,10 @@ QuickFixTestCase::QuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &theTe
testFile->writeToDisk();
// Set appropriate include paths
- if (!includePaths.isEmpty()) {
- m_restoreIncludePaths = true;
- m_includePathsToRestore = m_modelManager->includePaths();
- m_modelManager->setIncludePaths(includePaths);
+ if (!headerPaths.isEmpty()) {
+ m_restoreHeaderPaths = true;
+ m_headerPathsToRestore = m_modelManager->headerPaths();
+ m_modelManager->setHeaderPaths(headerPaths);
}
// Update Code Model
@@ -213,14 +213,22 @@ QuickFixTestCase::~QuickFixTestCase()
m_cppCodeStylePreferences->setCurrentDelegate(m_cppCodeStylePreferencesOriginalDelegateId);
// Restore include paths
- if (m_restoreIncludePaths)
- m_modelManager->setIncludePaths(m_includePathsToRestore);
+ if (m_restoreHeaderPaths)
+ m_modelManager->setHeaderPaths(m_headerPathsToRestore);
// Remove created files from file system
foreach (const QuickFixTestDocument::Ptr &testDocument, m_testFiles)
QVERIFY(QFile::remove(testDocument->filePath()));
}
+void QuickFixTestCase::run(const QList<QuickFixTestDocument::Ptr> &theTestFiles,
+ CppQuickFixFactory *factory, const QString &incPath)
+{
+ ProjectPart::HeaderPaths hps;
+ hps += ProjectPart::HeaderPath(incPath, ProjectPart::HeaderPath::IncludePath);
+ QuickFixTestCase(theTestFiles, factory, hps);
+}
+
/// Delegates directly to AddIncludeForUndefinedIdentifierOp for easier testing.
class AddIncludeForUndefinedIdentifierTestFactory : public CppQuickFixFactory
{
@@ -1289,7 +1297,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
- QuickFixTestCase(testFiles, &factory, QStringList(), 1);
+ QuickFixTestCase(testFiles, &factory, ProjectPart::HeaderPaths(), 1);
}
/// Check from header file: If there is a source file, insert the definition in the source file.
@@ -1478,7 +1486,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_insideClass()
"};";
InsertDefFromDecl factory;
- QuickFixTestCase(singleDocument(original, expected), &factory, QStringList(), 1);
+ QuickFixTestCase(singleDocument(original, expected), &factory, ProjectPart::HeaderPaths(), 1);
}
/// Check not triggering when definition exists
@@ -1492,7 +1500,8 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio
const QByteArray expected = original;
InsertDefFromDecl factory;
- QuickFixTestCase test(singleDocument(original, expected), &factory, QStringList(), 1);
+ QuickFixTestCase test(singleDocument(original, expected), &factory, ProjectPart::HeaderPaths(),
+ 1);
}
/// Find right implementation file.
@@ -1910,7 +1919,7 @@ void insertToSectionDeclFromDef(const QByteArray &section, int sectionIndex)
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
InsertDeclFromDef factory;
- QuickFixTestCase(testFiles, &factory, QStringList(), sectionIndex);
+ QuickFixTestCase(testFiles, &factory, ProjectPart::HeaderPaths(), sectionIndex);
}
/// Check from source file: Insert in header file.
@@ -1961,7 +1970,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_normal()
// Do not use the test factory, at least once we want to go through the "full stack".
AddIncludeForUndefinedIdentifier factory;
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Ignore *.moc includes
@@ -1986,7 +1995,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_ignoremoc()
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert include at top for a sorted group
@@ -2012,7 +2021,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_sortingTop(
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert include in the middle for a sorted group
@@ -2038,7 +2047,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_sortingMidd
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert include at bottom for a sorted group
@@ -2064,7 +2073,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_sortingBott
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: For an unsorted group the new include is appended
@@ -2090,7 +2099,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_appendToUns
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert a local include at front if there are only global includes
@@ -2117,7 +2126,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_firstLocalI
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert a global include at back if there are only local includes
@@ -2146,7 +2155,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_firstGlobal
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<file.h>"));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Prefer group with longest matching prefix
@@ -2176,7 +2185,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_preferGroup
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"prefixc.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Create a new include group if there are only include groups with a different include dir
@@ -2203,7 +2212,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_newGroupIfO
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Include group with mixed include dirs, sorted --> insert properly
@@ -2231,7 +2240,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedDirsSo
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<firstlib/file.h>"));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Include group with mixed include dirs, unsorted --> append
@@ -2259,7 +2268,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedDirsUn
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lastlib/file.h>"));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Include group with mixed include types
@@ -2285,7 +2294,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"z.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Include group with mixed include types
@@ -2311,7 +2320,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"a.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Include group with mixed include types
@@ -2337,7 +2346,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"lib/file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Include group with mixed include types
@@ -2363,7 +2372,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lib/file.h>"));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert very first include
@@ -2386,7 +2395,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_noinclude()
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert very first include if there is a c++ style comment on top
@@ -2415,7 +2424,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_veryFirstIn
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert very first include if there is a c style comment on top
@@ -2448,7 +2457,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_veryFirstIn
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
- QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: If a "Qt Class" was not found by the locator, check the header files in the Qt
@@ -2472,8 +2481,8 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_checkQSomet
+ "/file.cpp", original, expected);
AddIncludeForUndefinedIdentifier factory;
- QuickFixTestCase(testFiles,&factory,
- QStringList(CppTools::Tests::TestIncludePaths::globalQtCoreIncludePath()));
+ QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalQtCoreIncludePath());
+
}
/// Check: Move definition from header to cpp.
@@ -2638,7 +2647,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside2()
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- QuickFixTestCase(testFiles, &factory, QStringList(), 1);
+ QuickFixTestCase(testFiles, &factory, ProjectPart::HeaderPaths(), 1);
}
/// Check: Move definition from header to cpp (with namespace).
@@ -2951,7 +2960,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_afterClass()
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
MoveFuncDefOutside factory;
- QuickFixTestCase(testFiles, &factory, QStringList(), 1);
+ QuickFixTestCase(testFiles, &factory, ProjectPart::HeaderPaths(), 1);
}
/// Check if whitespace is respected for operator functions
diff --git a/src/plugins/cppeditor/cppquickfix_test.h b/src/plugins/cppeditor/cppquickfix_test.h
index 615e814104..f15335cf0b 100644
--- a/src/plugins/cppeditor/cppquickfix_test.h
+++ b/src/plugins/cppeditor/cppquickfix_test.h
@@ -74,10 +74,13 @@ class QuickFixTestCase : public TestCase
public:
QuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &theTestFiles,
CppQuickFixFactory *factory,
- const QStringList &includePaths = QStringList(),
+ const CppTools::ProjectPart::HeaderPaths &includePaths =
+ CppTools::ProjectPart::HeaderPaths(),
int resultIndex = 0);
~QuickFixTestCase();
+ static void run(const QList<QuickFixTestDocument::Ptr> &theTestFiles,
+ CppQuickFixFactory *factory, const QString &incPath);
private:
QSharedPointer<TextEditor::QuickFixOperation> getFix(CppQuickFixFactory *factory,
CPPEditorWidget *editorWidget,
@@ -89,8 +92,8 @@ private:
CppTools::CppCodeStylePreferences *m_cppCodeStylePreferences;
QByteArray m_cppCodeStylePreferencesOriginalDelegateId;
- QStringList m_includePathsToRestore;
- bool m_restoreIncludePaths;
+ CppTools::ProjectPart::HeaderPaths m_headerPathsToRestore;
+ bool m_restoreHeaderPaths;
};
QList<QuickFixTestDocument::Ptr> singleDocument(const QByteArray &original,
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index 109a63f565..5b7e48a007 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -1896,7 +1896,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
return;
// find the include paths
- QStringList includePaths;
+ ProjectPart::HeaderPaths headerPaths;
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
QList<CppModelManagerInterface::ProjectInfo> projectInfos = modelManager->projectInfos();
bool inProject = false;
@@ -1905,14 +1905,14 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
foreach (const ProjectFile &file, part->files) {
if (file.path == doc->fileName()) {
inProject = true;
- includePaths += part->includePaths;
+ headerPaths += part->headerPaths;
}
}
}
}
if (!inProject) {
// better use all include paths than none
- includePaths = modelManager->includePaths();
+ headerPaths = modelManager->headerPaths();
}
// find a include file through the locator
@@ -1933,10 +1933,10 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
if (fileInfo.path() == QFileInfo(doc->fileName()).path()) {
shortestInclude = QLatin1Char('"') + fileInfo.fileName() + QLatin1Char('"');
} else {
- foreach (const QString &includePath, includePaths) {
- if (!fileName.startsWith(includePath))
+ foreach (const ProjectPart::HeaderPath &headerPath, headerPaths) {
+ if (!fileName.startsWith(headerPath.path))
continue;
- QString relativePath = fileName.mid(includePath.size());
+ QString relativePath = fileName.mid(headerPath.path.size());
if (!relativePath.isEmpty() && relativePath.at(0) == QLatin1Char('/'))
relativePath = relativePath.mid(1);
if (shortestInclude.isEmpty() || relativePath.size() + 2 < shortestInclude.size())
@@ -1965,11 +1965,11 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
// otherwise, check for a header file with the same name in the Qt include paths
} else {
- foreach (const QString &includePath, includePaths) {
- if (!includePath.contains(QLatin1String("/Qt"))) // "QtCore", "QtGui" etc...
+ foreach (const ProjectPart::HeaderPath &headerPath, headerPaths) {
+ if (!headerPath.path.contains(QLatin1String("/Qt"))) // "QtCore", "QtGui" etc...
continue;
- const QString headerPathCandidate = includePath + QLatin1Char('/') + className;
+ const QString headerPathCandidate = headerPath.path + QLatin1Char('/') + className;
const QFileInfo fileInfo(headerPathCandidate);
if (fileInfo.exists() && fileInfo.isFile()) {
const QString include = QLatin1Char('<') + className + QLatin1Char('>');
diff --git a/src/plugins/cpptools/builtinindexingsupport.cpp b/src/plugins/cpptools/builtinindexingsupport.cpp
index fc51ad12f9..20eac41a03 100644
--- a/src/plugins/cpptools/builtinindexingsupport.cpp
+++ b/src/plugins/cpptools/builtinindexingsupport.cpp
@@ -51,7 +51,7 @@ static void parse(QFutureInterface<void> &future,
bool processingHeaders = false;
CppModelManager *cmm = CppModelManager::instance();
- const QStringList fallbackIncludePaths = cmm->includePaths();
+ const ProjectPart::HeaderPaths fallbackHeaderPaths = cmm->headerPaths();
for (int i = 0; i < files.size(); ++i) {
if (future.isPaused())
future.waitForResume();
@@ -71,10 +71,10 @@ static void parse(QFutureInterface<void> &future,
}
QList<ProjectPart::Ptr> parts = cmm->projectPart(fileName);
- QStringList includePaths = parts.isEmpty()
- ? fallbackIncludePaths
- : parts.first()->includePaths;
- sourceProcessor->setIncludePaths(includePaths);
+ ProjectPart::HeaderPaths headerPaths = parts.isEmpty()
+ ? fallbackHeaderPaths
+ : parts.first()->headerPaths;
+ sourceProcessor->setHeaderPaths(headerPaths);
sourceProcessor->run(fileName);
future.setProgressValue(files.size() - sourceProcessor->todo().size());
@@ -190,8 +190,7 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(const QStringList &sour
CppSourceProcessor *preproc = CppModelManager::createSourceProcessor();
preproc->setDumpFileNameWhileParsing(m_dumpFileNameWhileParsing);
preproc->setRevision(++m_revision);
- preproc->setIncludePaths(mgr->includePaths());
- preproc->setFrameworkPaths(mgr->frameworkPaths());
+ preproc->setHeaderPaths(mgr->headerPaths());
preproc->setWorkingCopy(workingCopy);
QFuture<void> result = QtConcurrent::run(&parse, preproc, sourceFiles);
diff --git a/src/plugins/cpptools/cppcodemodelinspectordumper.cpp b/src/plugins/cpptools/cppcodemodelinspectordumper.cpp
index cdad0fdddf..6d6b748737 100644
--- a/src/plugins/cpptools/cppcodemodelinspectordumper.cpp
+++ b/src/plugins/cpptools/cppcodemodelinspectordumper.cpp
@@ -413,6 +413,18 @@ QString Utils::pathListToString(const QStringList &pathList)
return result.join(QLatin1String("\n"));
}
+QString Utils::pathListToString(const ProjectPart::HeaderPaths &pathList)
+{
+ QStringList result;
+ foreach (const ProjectPart::HeaderPath &path, pathList) {
+ result << QString(QLatin1String("%1 (%2 path)")).arg(
+ QDir::toNativeSeparators(path.path),
+ path.isFrameworkPath() ? QLatin1String("framework") : QLatin1String("include")
+ );
+ }
+ return result.join(QLatin1String("\n"));
+}
+
QList<CPlusPlus::Document::Ptr> Utils::snapshotToList(const CPlusPlus::Snapshot &snapshot)
{
QList<CPlusPlus::Document::Ptr> documents;
@@ -511,16 +523,14 @@ void Dumper::dumpProjectInfos( const QList<CppModelManagerInterface::ProjectInfo
m_out << i4 << defineLine << "\n";
}
- if (!part->includePaths.isEmpty()) {
- m_out << i3 << "Include Paths:{{{4\n";
- foreach (const QString &includePath, part->includePaths)
- m_out << i4 << includePath << "\n";
- }
-
- if (!part->frameworkPaths.isEmpty()) {
- m_out << i3 << "Framework Paths:{{{4\n";
- foreach (const QString &frameworkPath, part->frameworkPaths)
- m_out << i4 << frameworkPath << "\n";
+ if (!part->headerPaths.isEmpty()) {
+ m_out << i3 << "Header Paths:{{{4\n";
+ foreach (const ProjectPart::HeaderPath &headerPath, part->headerPaths)
+ m_out << i4 << headerPath.path
+ << (headerPath.type == ProjectPart::HeaderPath::IncludePath
+ ? "(include path)"
+ : "(framework path)")
+ << "\n";
}
if (!part->precompiledHeaders.isEmpty()) {
@@ -582,18 +592,18 @@ void Dumper::dumpWorkingCopy(const CppModelManagerInterface::WorkingCopy &workin
}
}
-void Dumper::dumpMergedEntities(const QStringList &mergedIncludePaths,
- const QStringList &mergedFrameworkPaths,
+void Dumper::dumpMergedEntities(const ProjectPart::HeaderPaths &mergedHeaderPaths,
const QByteArray &mergedMacros)
{
m_out << "Merged Entities{{{1\n";
const QByteArray i2 = indent(2);
const QByteArray i3 = indent(3);
- m_out << i2 << "Merged Include Paths{{{2\n";
- dumpStringList(mergedIncludePaths, i3);
- m_out << i2 << "Merged Framework Paths{{{2\n";
- dumpStringList(mergedFrameworkPaths, i3);
+ m_out << i2 << "Merged Header Paths{{{2\n";
+ foreach (const ProjectPart::HeaderPath &hp, mergedHeaderPaths)
+ m_out << i3 << hp.path
+ << (hp.isFrameworkPath() ? " (framework path)" : " (include path)")
+ << "\n";
m_out << i2 << "Merged Defines{{{2\n";
m_out << mergedMacros;
}
diff --git a/src/plugins/cpptools/cppcodemodelinspectordumper.h b/src/plugins/cpptools/cppcodemodelinspectordumper.h
index 2fe43d40a4..b7ada3084d 100644
--- a/src/plugins/cpptools/cppcodemodelinspectordumper.h
+++ b/src/plugins/cpptools/cppcodemodelinspectordumper.h
@@ -58,6 +58,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 ProjectPart::HeaderPaths &pathList);
static QList<CPlusPlus::Document::Ptr> snapshotToList(const CPlusPlus::Snapshot &snapshot);
};
@@ -73,8 +74,7 @@ public:
const QString &title,
bool isGlobalSnapshot = false);
void dumpWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy);
- void dumpMergedEntities(const QStringList &mergedIncludePaths,
- const QStringList &mergedFrameworkPaths,
+ void dumpMergedEntities(const ProjectPart::HeaderPaths &mergedHeaderPaths,
const QByteArray &mergedMacros);
private:
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index 560c918530..b2978ea3b8 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -105,7 +105,7 @@ public:
= new CppCompletionAssistInterface(m_editorWidget->document(), m_position,
m_editorWidget->baseTextDocument()->filePath(),
ExplicitlyInvoked, m_snapshot,
- QStringList(), QStringList());
+ ProjectPart::HeaderPaths());
CppCompletionAssistProcessor processor;
IAssistProposal *proposal = processor.perform(ai);
if (!proposal)
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index 10a3412c1b..d1f1322223 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -1139,30 +1139,23 @@ bool CppCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
}
// Make completion for all relevant includes
- QStringList includePaths = m_interface->includePaths();
- const QString &currentFilePath = QFileInfo(m_interface->fileName()).path();
- if (!includePaths.contains(currentFilePath))
- includePaths.append(currentFilePath);
+ ProjectPart::HeaderPaths headerPaths = m_interface->headerPaths();
+ const ProjectPart::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
+ ProjectPart::HeaderPath::IncludePath);
+ if (!headerPaths.contains(currentFilePath))
+ headerPaths.append(currentFilePath);
const Core::MimeType mimeType =
Core::MimeDatabase::findByType(QLatin1String("text/x-c++hdr"));
const QStringList suffixes = mimeType.suffixes();
- foreach (const QString &includePath, includePaths) {
- QString realPath = includePath;
+ foreach (const ProjectPart::HeaderPath &headerPath, headerPaths) {
+ QString realPath = headerPath.path;
if (!directoryPrefix.isEmpty()) {
realPath += QLatin1Char('/');
realPath += directoryPrefix;
- }
- completeInclude(realPath, suffixes);
- }
-
- foreach (const QString &frameworkPath, m_interface->frameworkPaths()) {
- QString realPath = frameworkPath;
- if (!directoryPrefix.isEmpty()) {
- realPath += QLatin1Char('/');
- realPath += directoryPrefix;
- realPath += QLatin1String(".framework/Headers");
+ if (headerPath.isFrameworkPath())
+ realPath += QLatin1String(".framework/Headers");
}
completeInclude(realPath, suffixes);
}
@@ -1969,8 +1962,7 @@ void CppCompletionAssistInterface::getCppSpecifics() const
if (QSharedPointer<SnapshotUpdater> updater = supp->snapshotUpdater()) {
updater->update(m_workingCopy);
m_snapshot = updater->snapshot();
- m_includePaths = updater->includePaths();
- m_frameworkPaths = updater->frameworkPaths();
+ m_headerPaths = updater->headerPaths();
}
}
}
diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h
index ed56a780c8..4ecabc9811 100644
--- a/src/plugins/cpptools/cppcompletionassist.h
+++ b/src/plugins/cpptools/cppcompletionassist.h
@@ -191,22 +191,20 @@ public:
const QString &fileName,
TextEditor::AssistReason reason,
const CPlusPlus::Snapshot &snapshot,
- const QStringList &includePaths,
- const QStringList &frameworkPaths)
+ const ProjectPart::HeaderPaths &headerPaths)
: TextEditor::DefaultAssistInterface(textDocument, position, fileName, reason)
, m_editor(0)
, m_isObjCEnabled(false)
, m_gotCppSpecifics(true)
, m_snapshot(snapshot)
- , m_includePaths(includePaths)
- , m_frameworkPaths(frameworkPaths)
+ , m_headerPaths(headerPaths)
{}
bool isObjCEnabled() const { return m_isObjCEnabled; }
const CPlusPlus::Snapshot &snapshot() const { getCppSpecifics(); return m_snapshot; }
- const QStringList &includePaths() const { getCppSpecifics(); return m_includePaths; }
- const QStringList &frameworkPaths() const { getCppSpecifics(); return m_frameworkPaths; }
+ const ProjectPart::HeaderPaths &headerPaths() const
+ { getCppSpecifics(); return m_headerPaths; }
private:
void getCppSpecifics() const;
@@ -216,8 +214,7 @@ private:
mutable bool m_gotCppSpecifics;
CppModelManagerInterface::WorkingCopy m_workingCopy;
mutable CPlusPlus::Snapshot m_snapshot;
- mutable QStringList m_includePaths;
- mutable QStringList m_frameworkPaths;
+ mutable ProjectPart::HeaderPaths m_headerPaths;
};
} // Internal
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index 25300b1d1d..8924f64cd8 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -298,8 +298,7 @@ void CppModelManager::ensureUpdated()
return;
m_projectFiles = internalProjectFiles();
- m_includePaths = internalIncludePaths();
- m_frameworkPaths = internalFrameworkPaths();
+ m_headerPaths = internalHeaderPaths();
m_definedMacros = internalDefinedMacros();
m_dirty = false;
}
@@ -320,34 +319,23 @@ QStringList CppModelManager::internalProjectFiles() const
return files;
}
-QStringList CppModelManager::internalIncludePaths() const
+ProjectPart::HeaderPaths CppModelManager::internalHeaderPaths() const
{
- QStringList includePaths;
+ ProjectPart::HeaderPaths headerPaths;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projectToProjectsInfo);
while (it.hasNext()) {
it.next();
const ProjectInfo pinfo = it.value();
- foreach (const ProjectPart::Ptr &part, pinfo.projectParts())
- foreach (const QString &path, part->includePaths)
- includePaths.append(CppSourceProcessor::cleanPath(path));
- }
- includePaths.removeDuplicates();
- return includePaths;
-}
-
-QStringList CppModelManager::internalFrameworkPaths() const
-{
- QStringList frameworkPaths;
- QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projectToProjectsInfo);
- while (it.hasNext()) {
- it.next();
- const ProjectInfo pinfo = it.value();
- foreach (const ProjectPart::Ptr &part, pinfo.projectParts())
- foreach (const QString &path, part->frameworkPaths)
- frameworkPaths.append(CppSourceProcessor::cleanPath(path));
+ foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
+ foreach (const ProjectPart::HeaderPath &path, part->headerPaths) {
+ const ProjectPart::HeaderPath hp(CppSourceProcessor::cleanPath(path.path),
+ path.type);
+ if (!headerPaths.contains(hp))
+ headerPaths += hp;
+ }
+ }
}
- frameworkPaths.removeDuplicates();
- return frameworkPaths;
+ return headerPaths;
}
static void addUnique(const QList<QByteArray> &defs, QByteArray *macros, QSet<QByteArray> *alreadyIn)
@@ -396,7 +384,7 @@ void CppModelManager::dumpModelManagerConfiguration(const QString &logFileId)
dumper.dumpSnapshot(globalSnapshot, globalSnapshotTitle, /*isGlobalSnapshot=*/ true);
dumper.dumpWorkingCopy(workingCopy());
ensureUpdated();
- dumper.dumpMergedEntities(m_includePaths, m_frameworkPaths, m_definedMacros);
+ dumper.dumpMergedEntities(m_headerPaths, m_definedMacros);
}
void CppModelManager::addExtraEditorSupport(AbstractEditorSupport *editorSupport)
@@ -595,8 +583,7 @@ public:
bool configurationChanged() const
{
return definesChanged()
- || m_new.includePaths() != m_old.includePaths()
- || m_new.frameworkPaths() != m_old.frameworkPaths();
+ || m_new.headerPaths() != m_old.headerPaths();
}
bool nothingChanged() const
@@ -761,8 +748,7 @@ ProjectPart::Ptr CppModelManager::fallbackProjectPart() const
ProjectPart::Ptr part(new ProjectPart);
part->projectDefines = m_definedMacros;
- part->includePaths = m_includePaths;
- part->frameworkPaths = m_frameworkPaths;
+ part->headerPaths = m_headerPaths;
part->cVersion = ProjectPart::C11;
part->cxxVersion = ProjectPart::CXX11;
part->cxxExtensions = ProjectPart::AllExtensions;
diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h
index bbdb2d6e79..7936019a14 100644
--- a/src/plugins/cpptools/cppmodelmanager.h
+++ b/src/plugins/cpptools/cppmodelmanager.h
@@ -128,22 +128,16 @@ public:
return m_projectFiles;
}
- QStringList includePaths()
+ ProjectPart::HeaderPaths headerPaths()
{
ensureUpdated();
- return m_includePaths;
+ return m_headerPaths;
}
// Use this *only* for auto tests
- void setIncludePaths(const QStringList &includePaths)
+ void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths)
{
- m_includePaths = includePaths;
- }
-
- QStringList frameworkPaths()
- {
- ensureUpdated();
- return m_frameworkPaths;
+ m_headerPaths = headerPaths;
}
QByteArray definedMacros()
@@ -187,8 +181,7 @@ private:
void ensureUpdated();
QStringList internalProjectFiles() const;
- QStringList internalIncludePaths() const;
- QStringList internalFrameworkPaths() const;
+ ProjectPart::HeaderPaths internalHeaderPaths() const;
QByteArray internalDefinedMacros() const;
void dumpModelManagerConfiguration(const QString &logFileId);
@@ -210,8 +203,7 @@ private:
// The members below are cached/(re)calculated from the projects and/or their project parts
bool m_dirty;
QStringList m_projectFiles;
- QStringList m_includePaths;
- QStringList m_frameworkPaths;
+ ProjectPart::HeaderPaths m_headerPaths;
QByteArray m_definedMacros;
// Editor integration
diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp
index 4aef1c892b..3ca3e3d49d 100644
--- a/src/plugins/cpptools/cppmodelmanager_test.cpp
+++ b/src/plugins/cpptools/cppmodelmanager_test.cpp
@@ -220,23 +220,24 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
ProjectInfo pi = mm->projectInfo(project);
QCOMPARE(pi.project().data(), project);
+ typedef ProjectPart::HeaderPath HeaderPath;
+
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
- part->includePaths = QStringList() << testDataDir.includeDir(false);
- part->frameworkPaths = QStringList() << testDataDir.frameworksDir(false);
+ part->headerPaths = QList<HeaderPath>()
+ << HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath)
+ << HeaderPath(testDataDir.frameworksDir(false), HeaderPath::FrameworkPath);
pi.appendProjectPart(part);
mm->updateProjectInfo(pi);
- QStringList includePaths = mm->includePaths();
- QCOMPARE(includePaths.size(), 1);
- QVERIFY(includePaths.contains(testDataDir.includeDir()));
-
- QStringList frameworkPaths = mm->frameworkPaths();
- QCOMPARE(frameworkPaths.size(), 1);
- QVERIFY(frameworkPaths.contains(testDataDir.frameworksDir()));
+ QList<HeaderPath> headerPaths = mm->headerPaths();
+ QCOMPARE(headerPaths.size(), 2);
+ QVERIFY(headerPaths.contains(HeaderPath(testDataDir.includeDir(), HeaderPath::IncludePath)));
+ QVERIFY(headerPaths.contains(HeaderPath(testDataDir.frameworksDir(),
+ HeaderPath::FrameworkPath)));
}
/// Check: Frameworks headers are resolved.
@@ -254,12 +255,15 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
ProjectInfo pi = mm->projectInfo(project);
QCOMPARE(pi.project().data(), project);
+ typedef ProjectPart::HeaderPath HeaderPath;
+
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
- part->includePaths << testDataDir.includeDir();
- part->frameworkPaths << testDataDir.frameworksDir();
+ part->headerPaths = QList<HeaderPath>()
+ << 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);
@@ -303,11 +307,14 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
ProjectInfo pi = mm->projectInfo(project);
QCOMPARE(pi.project().data(), project);
+ typedef ProjectPart::HeaderPath HeaderPath;
+
ProjectPart::Ptr part(new ProjectPart);
part->cxxVersion = ProjectPart::CXX98;
part->qtVersion = ProjectPart::Qt5;
part->projectDefines = QByteArray("#define OH_BEHAVE -1\n");
- part->includePaths = QStringList() << testDataDir.includeDir(false);
+ part->headerPaths = QList<HeaderPath>()
+ << HeaderPath(testDataDir.includeDir(false), HeaderPath::IncludePath);
part->files.append(ProjectFile(testCpp, ProjectFile::CXXSource));
pi.appendProjectPart(part);
@@ -806,6 +813,8 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
Project *project = helper.createProject(_("test_modelmanager_defines_per_project"));
+ typedef ProjectPart::HeaderPath HeaderPath;
+
ProjectPart::Ptr part1(new ProjectPart);
part1->projectFile = QLatin1String("project1.projectfile");
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
@@ -813,7 +822,8 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
part1->cxxVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
part1->projectDefines = QByteArray("#define SUB1\n");
- part1->includePaths = QStringList() << testDataDirectory.includeDir(false);
+ part1->headerPaths = QList<HeaderPath>()
+ << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
ProjectPart::Ptr part2(new ProjectPart);
part2->projectFile = QLatin1String("project1.projectfile");
@@ -822,7 +832,8 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
part2->cxxVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
part2->projectDefines = QByteArray("#define SUB2\n");
- part2->includePaths = QStringList() << testDataDirectory.includeDir(false);
+ part2->headerPaths = QList<HeaderPath>()
+ << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
ProjectInfo pi = mm->projectInfo(project);
pi.appendProjectPart(part1);
@@ -877,6 +888,8 @@ void CppToolsPlugin::test_modelmanager_defines_per_project_pch()
Project *project = helper.createProject(_("test_modelmanager_defines_per_project_pch"));
+ typedef ProjectPart::HeaderPath HeaderPath;
+
ProjectPart::Ptr part1(new ProjectPart);
part1->projectFile = QLatin1String("project1.projectfile");
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
@@ -884,7 +897,8 @@ void CppToolsPlugin::test_modelmanager_defines_per_project_pch()
part1->cxxVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
part1->precompiledHeaders.append(pch1File);
- part1->includePaths = QStringList() << testDataDirectory.includeDir(false);
+ part1->headerPaths = QList<HeaderPath>()
+ << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
ProjectPart::Ptr part2(new ProjectPart);
part2->projectFile = QLatin1String("project2.projectfile");
@@ -893,7 +907,8 @@ void CppToolsPlugin::test_modelmanager_defines_per_project_pch()
part2->cxxVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
part2->precompiledHeaders.append(pch2File);
- part2->includePaths = QStringList() << testDataDirectory.includeDir(false);
+ part2->headerPaths = QList<HeaderPath>()
+ << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
ProjectInfo pi = mm->projectInfo(project);
pi.appendProjectPart(part1);
@@ -949,19 +964,23 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
Project *project = helper.createProject(_("test_modelmanager_defines_per_editor"));
+ typedef ProjectPart::HeaderPath HeaderPath;
+
ProjectPart::Ptr part1(new ProjectPart);
part1->files.append(ProjectFile(main1File, ProjectFile::CXXSource));
part1->files.append(ProjectFile(header, ProjectFile::CXXHeader));
part1->cxxVersion = ProjectPart::CXX11;
part1->qtVersion = ProjectPart::NoQt;
- part1->includePaths = QStringList() << testDataDirectory.includeDir(false);
+ part1->headerPaths = QList<HeaderPath>()
+ << 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->cxxVersion = ProjectPart::CXX11;
part2->qtVersion = ProjectPart::NoQt;
- part2->includePaths = QStringList() << testDataDirectory.includeDir(false);
+ part2->headerPaths = QList<HeaderPath>()
+ << HeaderPath(testDataDirectory.includeDir(false), HeaderPath::IncludePath);
ProjectInfo pi = mm->projectInfo(project);
pi.appendProjectPart(part1);
diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.cpp b/src/plugins/cpptools/cppmodelmanagerinterface.cpp
index 5b31d4a2a2..8c79e3d0da 100644
--- a/src/plugins/cpptools/cppmodelmanagerinterface.cpp
+++ b/src/plugins/cpptools/cppmodelmanagerinterface.cpp
@@ -154,12 +154,12 @@ void ProjectPart::evaluateToolchain(const ToolChain *tc,
cWarningFlags = tc->warningFlags(cflags);
cxxWarningFlags = tc->warningFlags(cxxflags);
- const QList<HeaderPath> headers = tc->systemHeaderPaths(cxxflags, sysRoot);
- foreach (const HeaderPath &header, headers)
- if (header.kind() == HeaderPath::FrameworkHeaderPath)
- frameworkPaths << header.path();
- else
- includePaths << header.path();
+ const QList<ProjectExplorer::HeaderPath> headers = tc->systemHeaderPaths(cxxflags, sysRoot);
+ foreach (const ProjectExplorer::HeaderPath &header, headers) {
+ headerPaths << HeaderPath(header.path(),
+ header.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath
+ ? HeaderPath::FrameworkPath : HeaderPath::IncludePath);
+ }
toolchainDefines = tc->predefinedMacros(cxxflags);
}
@@ -187,8 +187,7 @@ CppModelManagerInterface *CppModelManagerInterface::instance()
void CppModelManagerInterface::ProjectInfo::clearProjectParts()
{
m_projectParts.clear();
- m_includePaths.clear();
- m_frameworkPaths.clear();
+ m_headerPaths.clear();
m_sourceFiles.clear();
m_defines.clear();
}
@@ -200,17 +199,16 @@ void CppModelManagerInterface::ProjectInfo::appendProjectPart(const ProjectPart:
m_projectParts.append(part);
- // Update include paths
- QSet<QString> incs = QSet<QString>::fromList(m_includePaths);
- foreach (const QString &ins, part->includePaths)
- incs.insert(ins);
- m_includePaths = incs.toList();
-
- // Update framework paths
- QSet<QString> frms = QSet<QString>::fromList(m_frameworkPaths);
- foreach (const QString &frm, part->frameworkPaths)
- frms.insert(frm);
- m_frameworkPaths = frms.toList();
+ typedef ProjectPart::HeaderPath HeaderPath;
+
+ // Update header paths
+ QSet<HeaderPath> incs = QSet<HeaderPath>::fromList(m_headerPaths);
+ foreach (const HeaderPath &hp, part->headerPaths) {
+ if (!incs.contains(hp)) {
+ incs.insert(hp);
+ m_headerPaths += hp;
+ }
+ }
// Update source files
QSet<QString> srcs = QSet<QString>::fromList(m_sourceFiles);
diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h
index 608f199f3c..bd40a9de01 100644
--- a/src/plugins/cpptools/cppmodelmanagerinterface.h
+++ b/src/plugins/cpptools/cppmodelmanagerinterface.h
@@ -101,6 +101,27 @@ public:
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:
QString displayName;
QString projectFile;
@@ -109,8 +130,7 @@ public:
QString projectConfigFile; // currently only used by the Generic Project Manager
QByteArray projectDefines;
QByteArray toolchainDefines;
- QStringList includePaths;
- QStringList frameworkPaths;
+ QList<HeaderPath> headerPaths;
QStringList precompiledHeaders;
CVersion cVersion;
CXXVersion cxxVersion;
@@ -120,6 +140,9 @@ public:
ProjectExplorer::ToolChain::WarningFlags cxxWarningFlags;
};
+inline uint qHash(const ProjectPart::HeaderPath &key, uint seed = 0)
+{ return ((qHash(key.path) << 2) | key.type) ^ seed; }
+
class CPPTOOLS_EXPORT CppModelManagerInterface : public CPlusPlus::CppModelManagerBase
{
Q_OBJECT
@@ -159,11 +182,8 @@ public:
void clearProjectParts();
void appendProjectPart(const ProjectPart::Ptr &part);
- const QStringList includePaths() const
- { return m_includePaths; }
-
- const QStringList frameworkPaths() const
- { return m_frameworkPaths; }
+ const ProjectPart::HeaderPaths headerPaths() const
+ { return m_headerPaths; }
const QStringList sourceFiles() const
{ return m_sourceFiles; }
@@ -175,8 +195,7 @@ public:
QPointer<ProjectExplorer::Project> m_project;
QList<ProjectPart::Ptr> m_projectParts;
// The members below are (re)calculated from the project parts once a part is appended.
- QStringList m_includePaths;
- QStringList m_frameworkPaths;
+ ProjectPart::HeaderPaths m_headerPaths;
QStringList m_sourceFiles;
QByteArray m_defines;
};
@@ -266,11 +285,10 @@ public:
virtual void setIndexingSupport(CppTools::CppIndexingSupport *indexingSupport) = 0;
virtual CppIndexingSupport *indexingSupport() = 0;
- virtual void setIncludePaths(const QStringList &includePaths) = 0;
+ virtual void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths) = 0;
virtual void enableGarbageCollector(bool enable) = 0;
- virtual QStringList includePaths() = 0;
- virtual QStringList frameworkPaths() = 0;
+ virtual ProjectPart::HeaderPaths headerPaths() = 0;
virtual QByteArray definedMacros() = 0;
signals:
diff --git a/src/plugins/cpptools/cppsnapshotupdater.cpp b/src/plugins/cpptools/cppsnapshotupdater.cpp
index 63dc943d96..60c8d3e414 100644
--- a/src/plugins/cpptools/cppsnapshotupdater.cpp
+++ b/src/plugins/cpptools/cppsnapshotupdater.cpp
@@ -57,8 +57,7 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
CppModelManager *modelManager
= dynamic_cast<CppModelManager *>(CppModelManagerInterface::instance());
QByteArray configFile = modelManager->codeModelConfiguration();
- QStringList includePaths;
- QStringList frameworkPaths;
+ ProjectPart::HeaderPaths headerPaths;
QStringList precompiledHeaders;
QString projectConfigFile;
@@ -72,8 +71,7 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
if (m_projectPart) {
configFile += m_projectPart->toolchainDefines;
configFile += m_projectPart->projectDefines;
- includePaths = m_projectPart->includePaths;
- frameworkPaths = m_projectPart->frameworkPaths;
+ headerPaths = m_projectPart->headerPaths;
projectConfigFile = m_projectPart->projectConfigFile;
if (m_usePrecompiledHeaders)
precompiledHeaders = m_projectPart->precompiledHeaders;
@@ -91,13 +89,8 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
m_editorDefinesChangedSinceLastUpdate = false;
}
- if (includePaths != m_includePaths) {
- m_includePaths = includePaths;
- invalidateSnapshot = true;
- }
-
- if (frameworkPaths != m_frameworkPaths) {
- m_frameworkPaths = frameworkPaths;
+ if (headerPaths != m_headerPaths) {
+ m_headerPaths = headerPaths;
invalidateSnapshot = true;
}
@@ -174,8 +167,7 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
globalSnapshot.remove(fileInEditor());
sourceProcessor.setGlobalSnapshot(globalSnapshot);
sourceProcessor.setWorkingCopy(workingCopy);
- sourceProcessor.setIncludePaths(m_includePaths);
- sourceProcessor.setFrameworkPaths(m_frameworkPaths);
+ sourceProcessor.setHeaderPaths(m_headerPaths);
sourceProcessor.run(configurationFileName);
if (!m_projectConfigFile.isEmpty())
sourceProcessor.run(m_projectConfigFile);
@@ -218,16 +210,10 @@ Snapshot SnapshotUpdater::snapshot() const
return m_snapshot;
}
-QStringList SnapshotUpdater::includePaths() const
-{
- QMutexLocker locker(&m_mutex);
- return m_includePaths;
-}
-
-QStringList SnapshotUpdater::frameworkPaths() const
+ProjectPart::HeaderPaths SnapshotUpdater::headerPaths() const
{
QMutexLocker locker(&m_mutex);
- return m_frameworkPaths;
+ return m_headerPaths;
}
ProjectPart::Ptr SnapshotUpdater::currentProjectPart() const
diff --git a/src/plugins/cpptools/cppsnapshotupdater.h b/src/plugins/cpptools/cppsnapshotupdater.h
index 92741cf006..b7d786f3ed 100644
--- a/src/plugins/cpptools/cppsnapshotupdater.h
+++ b/src/plugins/cpptools/cppsnapshotupdater.h
@@ -56,8 +56,7 @@ public:
CPlusPlus::Document::Ptr document() const;
CPlusPlus::Snapshot snapshot() const;
- QStringList includePaths() const;
- QStringList frameworkPaths() const;
+ ProjectPart::HeaderPaths headerPaths() const;
ProjectPart::Ptr currentProjectPart() const;
void setProjectPart(ProjectPart::Ptr projectPart);
@@ -76,8 +75,7 @@ private:
QByteArray m_configFile;
bool m_editorDefinesChangedSinceLastUpdate;
QByteArray m_editorDefines;
- QStringList m_includePaths;
- QStringList m_frameworkPaths;
+ ProjectPart::HeaderPaths m_headerPaths;
QString m_projectConfigFile;
QStringList m_precompiledHeaders;
CPlusPlus::Snapshot m_snapshot;
diff --git a/src/plugins/cpptools/cppsourceprocessor.cpp b/src/plugins/cpptools/cppsourceprocessor.cpp
index 64fa8dca0b..47986331b3 100644
--- a/src/plugins/cpptools/cppsourceprocessor.cpp
+++ b/src/plugins/cpptools/cppsourceprocessor.cpp
@@ -6,6 +6,7 @@
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
+#include <utils/qtcassert.h>
#include <utils/textfileformat.h>
#include <QCoreApplication>
@@ -98,36 +99,18 @@ void CppSourceProcessor::setRevision(unsigned revision)
void CppSourceProcessor::setWorkingCopy(const CppModelManagerInterface::WorkingCopy &workingCopy)
{ m_workingCopy = workingCopy; }
-void CppSourceProcessor::setIncludePaths(const QStringList &includePaths)
+void CppSourceProcessor::setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths)
{
- m_includePaths.clear();
-
- for (int i = 0; i < includePaths.size(); ++i) {
- const QString &path = includePaths.at(i);
-
- if (Utils::HostOsInfo::isMacHost()) {
- if (i + 1 < includePaths.size() && path.endsWith(QLatin1String(".framework/Headers"))) {
- const QFileInfo pathInfo(path);
- const QFileInfo frameworkFileInfo(pathInfo.path());
- const QString frameworkName = frameworkFileInfo.baseName();
-
- const QFileInfo nextIncludePath = includePaths.at(i + 1);
- if (nextIncludePath.fileName() == frameworkName) {
- // We got a QtXXX.framework/Headers followed by $QTDIR/include/QtXXX.
- // In this case we prefer to include files from $QTDIR/include/QtXXX.
- continue;
- }
- }
- }
- m_includePaths.append(cleanPath(path));
- }
-}
+ m_headerPaths.clear();
-void CppSourceProcessor::setFrameworkPaths(const QStringList &frameworkPaths)
-{
- m_frameworkPaths.clear();
- foreach (const QString &frameworkPath, frameworkPaths)
- addFrameworkPath(frameworkPath);
+ for (int i = 0, ei = headerPaths.size(); i < ei; ++i) {
+ const ProjectPart::HeaderPath &path = headerPaths.at(i);
+
+ if (path.type == ProjectPart::HeaderPath::IncludePath)
+ m_headerPaths.append(ProjectPart::HeaderPath(cleanPath(path.path), path.type));
+ else
+ addFrameworkPath(path);
+ }
}
// Add the given framework path, and expand private frameworks.
@@ -137,16 +120,19 @@ void CppSourceProcessor::setFrameworkPaths(const QStringList &frameworkPaths)
// has private frameworks in:
// <framework-path>/ApplicationServices.framework/Frameworks
// if the "Frameworks" folder exists inside the top level framework.
-void CppSourceProcessor::addFrameworkPath(const QString &frameworkPath)
+void CppSourceProcessor::addFrameworkPath(const ProjectPart::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 QString cleanFrameworkPath = cleanPath(frameworkPath);
- if (!m_frameworkPaths.contains(cleanFrameworkPath))
- m_frameworkPaths.append(cleanFrameworkPath);
+ const ProjectPart::HeaderPath cleanFrameworkPath(cleanPath(frameworkPath.path),
+ frameworkPath.type);
+ if (!m_headerPaths.contains(cleanFrameworkPath))
+ m_headerPaths.append(cleanFrameworkPath);
- const QDir frameworkDir(cleanFrameworkPath);
+ const QDir frameworkDir(cleanFrameworkPath.path);
const QStringList filter = QStringList() << QLatin1String("*.framework");
foreach (const QFileInfo &framework, frameworkDir.entryInfoList(filter)) {
if (!framework.isDir())
@@ -154,7 +140,8 @@ void CppSourceProcessor::addFrameworkPath(const QString &frameworkPath)
const QFileInfo privateFrameworks(framework.absoluteFilePath(),
QLatin1String("Frameworks"));
if (privateFrameworks.exists() && privateFrameworks.isDir())
- addFrameworkPath(privateFrameworks.absoluteFilePath());
+ addFrameworkPath(ProjectPart::HeaderPath(privateFrameworks.absoluteFilePath(),
+ frameworkPath.type));
}
}
@@ -259,8 +246,10 @@ QString CppSourceProcessor::resolveFile_helper(const QString &fileName, IncludeT
// searching as if this would be a global include.
}
- foreach (const QString &includePath, m_includePaths) {
- const QString path = includePath + fileName;
+ foreach (const ProjectPart::HeaderPath &headerPath, m_headerPaths) {
+ if (headerPath.isFrameworkPath())
+ continue;
+ const QString path = headerPath.path + fileName;
if (m_workingCopy.contains(path) || checkFile(path))
return path;
}
@@ -271,8 +260,10 @@ QString CppSourceProcessor::resolveFile_helper(const QString &fileName, IncludeT
const QString name = frameworkName + QLatin1String(".framework/Headers/")
+ fileName.mid(index + 1);
- foreach (const QString &frameworkPath, m_frameworkPaths) {
- const QString path = frameworkPath + name;
+ foreach (const ProjectPart::HeaderPath &headerPath, m_headerPaths) {
+ if (!headerPath.isFrameworkPath())
+ continue;
+ const QString path = headerPath.path + name;
if (checkFile(path))
return path;
}
diff --git a/src/plugins/cpptools/cppsourceprocessor.h b/src/plugins/cpptools/cppsourceprocessor.h
index 2b8aed6acb..e10d143816 100644
--- a/src/plugins/cpptools/cppsourceprocessor.h
+++ b/src/plugins/cpptools/cppsourceprocessor.h
@@ -40,8 +40,7 @@ public:
void setRevision(unsigned revision);
void setWorkingCopy(const CppTools::CppModelManagerInterface::WorkingCopy &workingCopy);
- void setIncludePaths(const QStringList &includePaths);
- void setFrameworkPaths(const QStringList &frameworkPaths);
+ void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
void setTodo(const QStringList &files);
void run(const QString &fileName);
@@ -54,7 +53,7 @@ public:
void setGlobalSnapshot(const CPlusPlus::Snapshot &snapshot) { m_globalSnapshot = snapshot; }
private:
- void addFrameworkPath(const QString &frameworkPath);
+ void addFrameworkPath(const ProjectPart::HeaderPath &frameworkPath);
CPlusPlus::Document::Ptr switchCurrentDocument(CPlusPlus::Document::Ptr doc);
@@ -90,9 +89,8 @@ private:
bool m_dumpFileNameWhileParsing;
CPlusPlus::Environment m_env;
CPlusPlus::Preprocessor m_preprocess;
- QStringList m_includePaths;
+ ProjectPart::HeaderPaths m_headerPaths;
CppTools::CppModelManagerInterface::WorkingCopy m_workingCopy;
- QStringList m_frameworkPaths;
QSet<QString> m_included;
CPlusPlus::Document::Ptr m_currentDoc;
QSet<QString> m_todo;
diff --git a/src/plugins/cpptools/cppsourceprocessor_test.cpp b/src/plugins/cpptools/cppsourceprocessor_test.cpp
index 57974295f1..db7983cbf3 100644
--- a/src/plugins/cpptools/cppsourceprocessor_test.cpp
+++ b/src/plugins/cpptools/cppsourceprocessor_test.cpp
@@ -71,7 +71,9 @@ public:
QScopedPointer<CppSourceProcessor> sourceProcessor(
CppModelManager::createSourceProcessor());
- sourceProcessor->setIncludePaths(QStringList(TestIncludePaths::directoryOfTestFile()));
+ const ProjectPart::HeaderPath hp(TestIncludePaths::directoryOfTestFile(),
+ ProjectPart::HeaderPath::IncludePath);
+ sourceProcessor->setHeaderPaths(ProjectPart::HeaderPaths() << hp);
sourceProcessor->run(fileName);
Document::Ptr document = m_cmm->document(fileName);
diff --git a/src/plugins/cpptools/includeutils.cpp b/src/plugins/cpptools/includeutils.cpp
index a01fa5a9b8..490e9fcb79 100644
--- a/src/plugins/cpptools/includeutils.cpp
+++ b/src/plugins/cpptools/includeutils.cpp
@@ -518,7 +518,10 @@ static QList<Include> includesForSource(const QByteArray &source)
CppModelManager *cmm = CppModelManager::instance();
cmm->GC();
QScopedPointer<CppSourceProcessor> sourceProcessor(CppModelManager::createSourceProcessor());
- sourceProcessor->setIncludePaths(QStringList(TestIncludePaths::globalIncludePath()));
+ sourceProcessor->setHeaderPaths(ProjectPart::HeaderPaths()
+ << ProjectPart::HeaderPath(
+ TestIncludePaths::globalIncludePath(),
+ ProjectPart::HeaderPath::IncludePath));
sourceProcessor->run(fileName);
Document::Ptr document = cmm->document(fileName);
diff --git a/src/plugins/cpptools/modelmanagertesthelper.cpp b/src/plugins/cpptools/modelmanagertesthelper.cpp
index b53cd40506..efcf81e4b0 100644
--- a/src/plugins/cpptools/modelmanagertesthelper.cpp
+++ b/src/plugins/cpptools/modelmanagertesthelper.cpp
@@ -87,8 +87,7 @@ void ModelManagerTestHelper::verifyClean()
assert(mm);
QVERIFY(mm->projectInfos().isEmpty());
- QVERIFY(mm->includePaths().isEmpty());
- QVERIFY(mm->frameworkPaths().isEmpty());
+ QVERIFY(mm->headerPaths().isEmpty());
QVERIFY(mm->definedMacros().isEmpty());
QVERIFY(mm->projectFiles().isEmpty());
QVERIFY(mm->snapshot().isEmpty());
diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp
index 3b0f469ba3..b824aaf413 100644
--- a/src/plugins/genericprojectmanager/genericproject.cpp
+++ b/src/plugins/genericprojectmanager/genericproject.cpp
@@ -246,7 +246,9 @@ void GenericProject::refresh(RefreshOptions options)
part->displayName = displayName();
part->projectFile = projectFilePath().toString();
- part->includePaths += projectIncludePaths();
+ foreach (const QString &inc, projectIncludePaths())
+ part->headerPaths += CppTools::ProjectPart::HeaderPath(
+ inc, CppTools::ProjectPart::HeaderPath::IncludePath);
Kit *k = activeTarget() ? activeTarget()->kit() : KitManager::defaultKit();
if (ToolChain *tc = ToolChainKitInformation::toolChain(k)) {
diff --git a/src/plugins/qbsprojectmanager/qbsproject.cpp b/src/plugins/qbsprojectmanager/qbsproject.cpp
index 46cdcfab84..c0d69a8c1b 100644
--- a/src/plugins/qbsprojectmanager/qbsproject.cpp
+++ b/src/plugins/qbsprojectmanager/qbsproject.cpp
@@ -546,19 +546,18 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj)
list = props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_INCLUDEPATHS));
- QStringList grpIncludePaths;
- foreach (const QString &p, list) {
- const QString cp = FileName::fromUserInput(p).toString();
- grpIncludePaths.append(cp);
- }
+ CppTools::ProjectPart::HeaderPaths grpHeaderPaths;
+ foreach (const QString &p, list)
+ grpHeaderPaths += CppTools::ProjectPart::HeaderPath(
+ FileName::fromUserInput(p).toString(),
+ CppTools::ProjectPart::HeaderPath::IncludePath);
list = props.getModulePropertiesAsStringList(QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_FRAMEWORKPATHS));
- QStringList grpFrameworkPaths;
- foreach (const QString &p, list) {
- const QString cp = FileName::fromUserInput(p).toString();
- grpFrameworkPaths.append(cp);
- }
+ foreach (const QString &p, list)
+ grpHeaderPaths += CppTools::ProjectPart::HeaderPath(
+ FileName::fromUserInput(p).toString(),
+ CppTools::ProjectPart::HeaderPath::FrameworkPath);
const QString pch = props.getModuleProperty(QLatin1String(CONFIG_CPP_MODULE),
QLatin1String(CONFIG_PRECOMPILEDHEADER)).toString();
@@ -590,8 +589,7 @@ void QbsProject::updateCppCodeModel(const qbs::ProjectData &prj)
CppTools::ProjectFile::CXXHeader);
part->qtVersion = qtVersionForPart;
- part->includePaths += grpIncludePaths;
- part->frameworkPaths += grpFrameworkPaths;
+ part->headerPaths += grpHeaderPaths;
part->precompiledHeaders = QStringList(pch);
part->projectDefines += grpDefines;
pinfo.appendProjectPart(part);
diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
index 17d86a2fd9..cc89d31e85 100644
--- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp
@@ -520,22 +520,27 @@ void QmakeProject::updateCppCodeModel()
// part->defines
part->projectDefines += pro->cxxDefines();
- // part->includePaths, part->frameworkPaths
- part->includePaths.append(pro->variableValue(IncludePathVar));
+ // part->headerPaths
+ foreach (const QString &inc, pro->variableValue(IncludePathVar))
+ part->headerPaths += ProjectPart::HeaderPath(inc, ProjectPart::HeaderPath::IncludePath);
if (qtVersion) {
foreach (const HeaderPath &header, qtVersion->systemHeaderPathes(k)) {
+ ProjectPart::HeaderPath::Type type = ProjectPart::HeaderPath::IncludePath;
if (header.kind() == HeaderPath::FrameworkHeaderPath)
- part->frameworkPaths.append(header.path());
- else
- part->includePaths.append(header.path());
+ type = ProjectPart::HeaderPath::FrameworkPath;
+ part->headerPaths += ProjectPart::HeaderPath(header.path(), type);
+ }
+ if (!qtVersion->frameworkInstallPath().isEmpty()) {
+ part->headerPaths += ProjectPart::HeaderPath(
+ qtVersion->frameworkInstallPath(),
+ ProjectPart::HeaderPath::FrameworkPath);
}
- if (!qtVersion->frameworkInstallPath().isEmpty())
- part->frameworkPaths.append(qtVersion->frameworkInstallPath());
}
if (QmakeProFileNode *node = rootQmakeProjectNode())
- part->includePaths.append(node->resolvedMkspecPath());
+ part->headerPaths += ProjectPart::HeaderPath(node->resolvedMkspecPath(),
+ ProjectPart::HeaderPath::IncludePath);
// part->precompiledHeaders
part->precompiledHeaders.append(pro->variableValue(PrecompiledHeaderVar));