diff options
Diffstat (limited to 'src/plugins/cpptools/cppmodelmanager.cpp')
-rw-r--r-- | src/plugins/cpptools/cppmodelmanager.cpp | 112 |
1 files changed, 37 insertions, 75 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 3dad9eea30..cdf5922e42 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of Qt Creator. ** @@ -9,22 +9,17 @@ ** 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. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU 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. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ****************************************************************************/ @@ -34,7 +29,6 @@ #include "baseeditordocumentprocessor.h" #include "builtinindexingsupport.h" #include "cppcodemodelinspectordumper.h" -#include "cppcodemodelsettings.h" #include "cppfindreferences.h" #include "cppindexingsupport.h" #include "cppmodelmanagersupportinternal.h" @@ -64,6 +58,7 @@ #include <QDir> #include <QMutexLocker> #include <QTextBlock> +#include <QThreadPool> #include <QTimer> #if defined(QTCREATOR_WITH_DUMP_AST) && defined(Q_CC_GNU) @@ -143,7 +138,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 @@ -152,7 +147,6 @@ public: QSet<AbstractEditorSupport *> m_extraEditorSupports; // Model Manager Supports for e.g. completion and highlighting - ModelManagerSupportProvider *m_clangModelManagerSupportProvider; ModelManagerSupport::Ptr m_builtinModelManagerSupport; ModelManagerSupport::Ptr m_activeModelManagerSupport; @@ -164,6 +158,7 @@ public: CppFindReferences *m_findReferences; SymbolFinder m_symbolFinder; + QThreadPool m_threadPool; bool m_enableGC; QTimer m_delayedGcTimer; @@ -190,6 +185,12 @@ const char pp_configuration[] = "#define _Pragma(x)\n" // C99 _Pragma operator + "#define __func__ \"\"\n" + + // ### add macros for gcc + "#define __PRETTY_FUNCTION__ \"\"\n" + "#define __FUNCTION__ \"\"\n" + // ### add macros for win32 "#define __cdecl\n" "#define __stdcall\n" @@ -292,9 +293,8 @@ CppModelManager *CppModelManager::instance() return m_instance; } -void CppModelManager::initializeModelManagerSupports() +void CppModelManager::initializeBuiltinModelManagerSupport() { - d->m_clangModelManagerSupportProvider = nullptr; d->m_builtinModelManagerSupport = ModelManagerSupportProviderInternal().createModelManagerSupport(); d->m_activeModelManagerSupport = d->m_builtinModelManagerSupport; @@ -340,12 +340,7 @@ CppModelManager::CppModelManager(QObject *parent) qRegisterMetaType<QList<Document::DiagnosticMessage>>( "QList<CPlusPlus::Document::DiagnosticMessage>"); - QSharedPointer<CppCodeModelSettings> codeModelSettings - = CppToolsPlugin::instance()->codeModelSettings(); - connect(codeModelSettings.data(), &CppCodeModelSettings::changed, - this, &CppModelManager::onCodeModelSettingsChanged); - - initializeModelManagerSupports(); + initializeBuiltinModelManagerSupport(); d->m_internalIndexingSupport = new BuiltinIndexingSupport; } @@ -412,16 +407,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; } @@ -665,14 +660,6 @@ void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const Projec } } -void CppModelManager::closeCppEditorDocuments() -{ - QList<Core::IDocument *> cppDocumentsToClose; - foreach (CppEditorDocumentHandle *cppDocument, cppEditorDocuments()) - cppDocumentsToClose << cppDocument->processor()->baseTextDocument(); - QTC_CHECK(Core::EditorManager::closeDocuments(cppDocumentsToClose)); -} - QList<CppEditorDocumentHandle *> CppModelManager::cppEditorDocuments() const { QMutexLocker locker(&d->m_cppEditorDocumentsMutex); @@ -939,15 +926,9 @@ bool CppModelManager::isCppEditor(Core::IEditor *editor) return editor->context().contains(ProjectExplorer::Constants::LANG_CXX); } -bool CppModelManager::isClangCodeModelAvailable() const -{ - return d->m_clangModelManagerSupportProvider != nullptr; -} - bool CppModelManager::isClangCodeModelActive() const { - return isClangCodeModelAvailable() - && d->m_activeModelManagerSupport != d->m_builtinModelManagerSupport; + return d->m_activeModelManagerSupport != d->m_builtinModelManagerSupport; } void CppModelManager::emitDocumentUpdated(Document::Ptr doc) @@ -1031,27 +1012,6 @@ void CppModelManager::onCurrentEditorChanged(Core::IEditor *editor) } } -void CppModelManager::onCodeModelSettingsChanged() -{ - const bool isClangActive = isClangCodeModelActive(); - const QSharedPointer<CppCodeModelSettings> settings - = CppToolsPlugin::instance()->codeModelSettings(); - - ModelManagerSupport::Ptr newCodeModelSupport; - - if (isClangCodeModelAvailable()) { - if (!isClangActive && settings->useClangCodeModel()) - newCodeModelSupport = d->m_clangModelManagerSupportProvider->createModelManagerSupport(); - else if (isClangActive && !settings->useClangCodeModel()) - newCodeModelSupport = d->m_builtinModelManagerSupport; - } - - if (newCodeModelSupport) { - closeCppEditorDocuments(); - d->m_activeModelManagerSupport = newCodeModelSupport; - } -} - void CppModelManager::onAboutToLoadSession() { if (d->m_delayedGcTimer.isActive()) @@ -1151,15 +1111,12 @@ void CppModelManager::finishedRefreshingSourceFiles(const QSet<QString> &files) emit sourceFilesRefreshed(files); } -void CppModelManager::setClangModelManagerSupportProvider( +void CppModelManager::activateClangCodeModel( ModelManagerSupportProvider *modelManagerSupportProvider) { QTC_ASSERT(modelManagerSupportProvider, return); - QTC_CHECK(d->m_clangModelManagerSupportProvider == nullptr); - - d->m_clangModelManagerSupportProvider = modelManagerSupportProvider; - onCodeModelSettingsChanged(); + d->m_activeModelManagerSupport = modelManagerSupportProvider->createModelManagerSupport(); } CppCompletionAssistProvider *CppModelManager::completionAssistProvider() const @@ -1196,7 +1153,7 @@ QStringList CppModelManager::projectFiles() return d->m_projectFiles; } -ProjectPart::HeaderPaths CppModelManager::headerPaths() +ProjectPartHeaderPaths CppModelManager::headerPaths() { QMutexLocker locker(&d->m_projectMutex); ensureUpdated(); @@ -1204,7 +1161,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; @@ -1229,4 +1186,9 @@ SymbolFinder *CppModelManager::symbolFinder() return &d->m_symbolFinder; } +QThreadPool *CppModelManager::sharedThreadPool() +{ + return &d->m_threadPool; +} + } // namespace CppTools |