diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index ada7f48ab77396daabe653ec96ed41eaa4cad3f1..988bba99665e1b1937492be5c391c7d7ece143ea 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -1239,6 +1239,23 @@ bool CppCodeCompletion::completeInclude(const QTextCursor &cursor) m_completions.append(item); } } + + QStringList frameworkPaths = m_manager->projectInfo(project).frameworkPaths; + foreach (const QString &frameworkPath, frameworkPaths) { + QString realPath = frameworkPath; + if (!directoryPrefix.isEmpty()) { + realPath += QLatin1Char('/'); + realPath += directoryPrefix; + realPath += QLatin1String(".framework/Headers"); + } + foreach (const QString &itemText, m_manager->includesInPath(realPath)) { + TextEditor::CompletionItem item(this); + item.m_text += itemText; + // TODO: Icon for include files + item.m_icon = m_icons.keywordIcon(); + m_completions.append(item); + } + } } return !m_completions.isEmpty(); diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index efb5e43ba207c8944dfcbea106ac92b589c1fe52..8aa6bdf767254cbae5a8387f25739bb8415f653e 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -809,6 +809,7 @@ void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo) QFuture<void> result = QtConcurrent::run(&CppModelManager::updateIncludesInPaths, this, pinfo.includePaths, + pinfo.frameworkPaths, m_headerSuffixes); if (pinfo.includePaths.size() > 1) { @@ -1127,6 +1128,7 @@ void CppModelManager::onAboutToUnloadSession() void CppModelManager::updateIncludesInPaths(QFutureInterface<void> &future, CppModelManager *manager, QStringList paths, + QStringList frameworkPaths, QStringList suffixes) { QMap<QString, QStringList> entriesInPaths; @@ -1137,6 +1139,24 @@ void CppModelManager::updateIncludesInPaths(QFutureInterface<void> &future, future.setProgressRange(0, paths.size()); + // Add framework header directories to path list + QStringList frameworkFilter; + frameworkFilter << QLatin1String("*.framework"); + QStringListIterator fwPathIt(frameworkPaths); + while (fwPathIt.hasNext()) { + const QString &fwPath = fwPathIt.next(); + QStringList entriesInFrameworkPath; + const QStringList &frameworks = QDir(fwPath).entryList(frameworkFilter, QDir::Dirs | QDir::NoDotAndDotDot); + QStringListIterator fwIt(frameworks); + while (fwIt.hasNext()) { + QString framework = fwIt.next(); + paths.append(fwPath + QLatin1Char('/') + framework + QLatin1String("/Headers")); + framework.chop(10); // remove the ".framework" + entriesInFrameworkPath.append(framework + QLatin1Char('/')); + } + entriesInPaths.insert(fwPath, entriesInFrameworkPath); + } + while (!paths.isEmpty()) { if (future.isPaused()) future.waitForResume(); diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h index f1c7eb52db3d4424302b5fa78f5017af7f543bd1..0f6911f97fe9c6dc168b1c85c45bc6534005324f 100644 --- a/src/plugins/cpptools/cppmodelmanager.h +++ b/src/plugins/cpptools/cppmodelmanager.h @@ -166,6 +166,7 @@ private: static void updateIncludesInPaths(QFutureInterface<void> &future, CppModelManager *manager, QStringList paths, + QStringList frameworkPaths, QStringList suffixes); static void parse(QFutureInterface<void> &future,