diff options
author | Marco Bubke <marco.bubke@theqtcompany.com> | 2016-01-11 20:50:14 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@theqtcompany.com> | 2016-01-12 10:21:30 +0000 |
commit | 6fe9b0ccc471dd0be161634a28e21d10a660d732 (patch) | |
tree | 91ccea669480957bf30993bd9da94ebdad8c8017 | |
parent | 6157c05f14a9c80378448148059c0a046997eafd (diff) | |
download | qt-creator-6fe9b0ccc471dd0be161634a28e21d10a660d732.tar.gz |
CppTools: Add CppToolsBridge
We broke the dependency of
BaseEditorDocumentProcessor *BaseEditorDocumentProcessor::get(const QString &filePath)
It's hiding static calls and it is much easier to do it that way than to
provide a reference to every user. It's also possible to exchange it with
different implementations for different test cases.
Change-Id: Ic74699b45948e8b48f7efb6a1b295ba2641b8951
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
-rw-r--r-- | src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp | 5 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppcodemodelinspectordialog.cpp | 3 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppincludehierarchymodel.cpp | 5 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppquickfixes.cpp | 3 | ||||
-rw-r--r-- | src/plugins/cpptools/baseeditordocumentprocessor.cpp | 12 | ||||
-rw-r--r-- | src/plugins/cpptools/baseeditordocumentprocessor.h | 3 | ||||
-rw-r--r-- | src/plugins/cpptools/cppsourceprocessor_test.cpp | 3 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptools.pro | 9 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptools.qbs | 3 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptoolsbridge.cpp | 64 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptoolsbridge.h | 62 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptoolsbridgeinterface.h | 56 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.cpp | 96 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.h | 52 | ||||
-rw-r--r-- | src/plugins/cpptools/cpptoolsplugin.cpp | 4 |
15 files changed, 359 insertions, 21 deletions
diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index c511c0cafa..252dc9ed5d 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -42,6 +42,7 @@ #include <cpptools/cppcodemodelsettings.h> #include <cpptools/cppmodelmanager.h> #include <cpptools/cppprojects.h> +#include <cpptools/cpptoolsbridge.h> #include <cpptools/cpptoolsreuse.h> #include <cpptools/cppworkingcopy.h> @@ -249,7 +250,9 @@ void ClangEditorDocumentProcessor::clearDiagnosticsWithFixIts() ClangEditorDocumentProcessor *ClangEditorDocumentProcessor::get(const QString &filePath) { - return qobject_cast<ClangEditorDocumentProcessor *>(BaseEditorDocumentProcessor::get(filePath)); + auto *processor = CppTools::CppToolsBridge::baseEditorDocumentProcessor(filePath); + + return qobject_cast<ClangEditorDocumentProcessor*>(processor); } static bool isProjectPartLoadedOrIsFallback(CppTools::ProjectPart::Ptr projectPart) diff --git a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp index 5f3fe6d636..bcc6ac5320 100644 --- a/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp +++ b/src/plugins/cppeditor/cppcodemodelinspectordialog.cpp @@ -38,6 +38,7 @@ #include <cpptools/baseeditordocumentprocessor.h> #include <cpptools/cppcodemodelinspectordumper.h> #include <cpptools/cppmodelmanager.h> +#include <cpptools/cpptoolsbridge.h> #include <cpptools/cppworkingcopy.h> #include <projectexplorer/project.h> @@ -1367,7 +1368,7 @@ void CppCodeModelInspectorDialog::refresh() if (editor) { const QString editorFilePath = editor->document()->filePath().toString(); cppEditorDocument = cmmi->cppEditorDocument(editorFilePath); - if (auto *documentProcessor = BaseEditorDocumentProcessor::get(editorFilePath)) { + if (auto *documentProcessor = CppToolsBridge::baseEditorDocumentProcessor(editorFilePath)) { const Snapshot editorSnapshot = documentProcessor->snapshot(); m_snapshotInfos->append(SnapshotInfo(editorSnapshot, SnapshotInfo::EditorSnapshot)); const QString editorSnapshotTitle diff --git a/src/plugins/cppeditor/cppincludehierarchymodel.cpp b/src/plugins/cppeditor/cppincludehierarchymodel.cpp index 83a63bc81c..f8131b96c9 100644 --- a/src/plugins/cppeditor/cppincludehierarchymodel.cpp +++ b/src/plugins/cppeditor/cppincludehierarchymodel.cpp @@ -35,6 +35,7 @@ #include <coreplugin/fileiconprovider.h> #include <cpptools/baseeditordocumentprocessor.h> #include <cpptools/cppmodelmanager.h> +#include <cpptools/cpptoolsbridge.h> #include <cpptools/editordocumenthandle.h> #include <texteditor/texteditor.h> @@ -184,7 +185,7 @@ void CppIncludeHierarchyModel::fetchMore(const QModelIndex &parent) } if (item == m_includesItem) { - auto *processor = BaseEditorDocumentProcessor::get(editorFilePath); + auto *processor = CppToolsBridge::baseEditorDocumentProcessor(editorFilePath); QTC_ASSERT(processor, return); const Snapshot editorDocumentSnapshot = processor->snapshot(); buildHierarchyIncludes_helper(parentItem->filePath(), parentItem, @@ -286,7 +287,7 @@ void CppIncludeHierarchyModel::buildHierarchyIncludes(const QString ¤tFile return; const QString editorFilePath = m_editor->document()->filePath().toString(); - auto *documentProcessor = BaseEditorDocumentProcessor::get(editorFilePath); + auto *documentProcessor = CppToolsBridge::baseEditorDocumentProcessor(editorFilePath); QTC_ASSERT(documentProcessor, return); const Snapshot editorDocumentSnapshot = documentProcessor->snapshot(); QSet<QString> cyclic; diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index dd49959110..7e23cddadf 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -44,6 +44,7 @@ #include <cpptools/cppclassesfilter.h> #include <cpptools/cppcodestylesettings.h> #include <cpptools/cpppointerdeclarationformatter.h> +#include <cpptools/cpptoolsbridge.h> #include <cpptools/cpptoolsconstants.h> #include <cpptools/cpptoolsreuse.h> #include <cpptools/includeutils.h> @@ -5965,7 +5966,7 @@ void ConvertQt4Connect::match(const CppQuickFixInterface &interface, QuickFixOpe void ExtraRefactoringOperations::match(const CppQuickFixInterface &interface, QuickFixOperations &result) { - const auto processor = CppTools::BaseEditorDocumentProcessor::get(interface.fileName()); + const auto processor = CppTools::CppToolsBridge::baseEditorDocumentProcessor(interface.fileName()); if (processor) { const auto clangFixItOperations = processor->extraRefactoringOperations(interface); result.append(clangFixItOperations); diff --git a/src/plugins/cpptools/baseeditordocumentprocessor.cpp b/src/plugins/cpptools/baseeditordocumentprocessor.cpp index e90a64dbd0..68dba8d044 100644 --- a/src/plugins/cpptools/baseeditordocumentprocessor.cpp +++ b/src/plugins/cpptools/baseeditordocumentprocessor.cpp @@ -31,6 +31,7 @@ #include "baseeditordocumentprocessor.h" #include "cppmodelmanager.h" +#include "cpptoolsbridge.h" #include "editordocumenthandle.h" #include <texteditor/quickfix.h> @@ -62,14 +63,6 @@ BaseEditorDocumentProcessor::extraRefactoringOperations(const TextEditor::Assist return TextEditor::QuickFixOperations(); } -BaseEditorDocumentProcessor *BaseEditorDocumentProcessor::get(const QString &filePath) -{ - CppModelManager *cmmi = CppModelManager::instance(); - if (CppEditorDocumentHandle *cppEditorDocument = cmmi->cppEditorDocument(filePath)) - return cppEditorDocument->processor(); - return 0; -} - void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future, BaseEditorDocumentParser::Ptr parser, const WorkingCopy workingCopy) @@ -81,8 +74,7 @@ void BaseEditorDocumentProcessor::runParser(QFutureInterface<void> &future, } parser->update(workingCopy); - CppModelManager::instance() - ->finishedRefreshingSourceFiles(QSet<QString>() << parser->filePath()); + CppToolsBridge::finishedRefreshingSourceFiles({parser->filePath()}); future.setProgressValue(1); } diff --git a/src/plugins/cpptools/baseeditordocumentprocessor.h b/src/plugins/cpptools/baseeditordocumentprocessor.h index 353a980f11..6038e46fa3 100644 --- a/src/plugins/cpptools/baseeditordocumentprocessor.h +++ b/src/plugins/cpptools/baseeditordocumentprocessor.h @@ -70,9 +70,6 @@ public: virtual TextEditor::QuickFixOperations extraRefactoringOperations(const TextEditor::AssistInterface &assistInterface); -public: - static BaseEditorDocumentProcessor *get(const QString &filePath); - signals: // Signal interface to implement void codeWarningsUpdated(unsigned revision, diff --git a/src/plugins/cpptools/cppsourceprocessor_test.cpp b/src/plugins/cpptools/cppsourceprocessor_test.cpp index 518eece226..bdc2cf2a38 100644 --- a/src/plugins/cpptools/cppsourceprocessor_test.cpp +++ b/src/plugins/cpptools/cppsourceprocessor_test.cpp @@ -34,6 +34,7 @@ #include "cppmodelmanager.h" #include "cppsourceprocessertesthelper.h" #include "cppsourceprocessor.h" +#include "cpptoolsbridge.h" #include "cpptoolstestcase.h" #include "editordocumenthandle.h" @@ -135,7 +136,7 @@ void CppToolsPlugin::test_cppsourceprocessor_includes_cyclic() // Check editor snapshot const QString filePath = editor->document()->filePath().toString(); - auto *processor = BaseEditorDocumentProcessor::get(filePath); + auto *processor = CppToolsBridge::baseEditorDocumentProcessor(filePath); QVERIFY(processor); QVERIFY(TestCase::waitForProcessedEditorDocument(filePath)); Snapshot snapshot = processor->snapshot(); diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro index b543389456..9004507bd8 100644 --- a/src/plugins/cpptools/cpptools.pro +++ b/src/plugins/cpptools/cpptools.pro @@ -66,7 +66,10 @@ HEADERS += \ symbolfinder.h \ symbolsfindfilter.h \ typehierarchybuilder.h \ - senddocumenttracker.h + senddocumenttracker.h \ + cpptoolsbridge.h \ + cpptoolsbridgeinterface.h \ + cpptoolsbridgeqtcreatorimplementation.h SOURCES += \ abstracteditorsupport.cpp \ @@ -130,7 +133,9 @@ SOURCES += \ symbolfinder.cpp \ symbolsfindfilter.cpp \ typehierarchybuilder.cpp \ - senddocumenttracker.cpp + senddocumenttracker.cpp \ + cpptoolsbridge.cpp \ + cpptoolsbridgeqtcreatorimplementation.cpp FORMS += \ completionsettingspage.ui \ diff --git a/src/plugins/cpptools/cpptools.qbs b/src/plugins/cpptools/cpptools.qbs index 611316c4d9..dd4a7ce1d1 100644 --- a/src/plugins/cpptools/cpptools.qbs +++ b/src/plugins/cpptools/cpptools.qbs @@ -69,6 +69,9 @@ QtcPlugin { "cppsemanticinfo.cpp", "cppsemanticinfo.h", "cppsemanticinfoupdater.cpp", "cppsemanticinfoupdater.h", "cppsourceprocessor.cpp", "cppsourceprocessor.h", + "cpptoolsbridge.cpp", "cpptoolsbridge.h", + "cpptoolsbridgeinterface.h", + "cpptoolsbridgeqtcreatorimplementation.cpp", "cpptoolsbridgeqtcreatorimplementation.h", "cpptools.qrc", "cpptools_global.h", "cpptoolsconstants.h", diff --git a/src/plugins/cpptools/cpptoolsbridge.cpp b/src/plugins/cpptools/cpptoolsbridge.cpp new file mode 100644 index 0000000000..9aec62df33 --- /dev/null +++ b/src/plugins/cpptools/cpptoolsbridge.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** 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 "cpptoolsbridge.h" + +#include "cpptoolsbridgeinterface.h" + +namespace CppTools { + +std::unique_ptr<CppToolsBridgeInterface> CppToolsBridge::m_interface; + +void CppToolsBridge::setCppToolsBridgeImplementation(std::unique_ptr<CppToolsBridgeInterface> &&interface) +{ + m_interface = std::move(interface); +} + +CppTools::CppEditorDocumentHandle *CppToolsBridge::cppEditorDocument(const QString &filePath) +{ + return m_interface->cppEditorDocument(filePath); +} + +QString CppToolsBridge::projectPartIdForFile(const QString &filePath) +{ + return m_interface->projectPartIdForFile(filePath); +} + +BaseEditorDocumentProcessor *CppToolsBridge::baseEditorDocumentProcessor(const QString &filePath) +{ + return m_interface->baseEditorDocumentProcessor(filePath); +} + +void CppToolsBridge::finishedRefreshingSourceFiles(const QSet<QString> &filePaths) +{ + m_interface->finishedRefreshingSourceFiles(filePaths); +} + +} // namespace CppTools diff --git a/src/plugins/cpptools/cpptoolsbridge.h b/src/plugins/cpptools/cpptoolsbridge.h new file mode 100644 index 0000000000..860b6a7ee7 --- /dev/null +++ b/src/plugins/cpptools/cpptoolsbridge.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** 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_CPPTOOLSBRIDGE_H +#define CPPTOOLS_CPPTOOLSBRIDGE_H + +#include "cpptools_global.h" + +#include <QString> + +#include <memory> + +namespace CppTools { +class CppEditorDocumentHandle; +class BaseEditorDocumentProcessor; +class CppToolsBridgeInterface; + +class CPPTOOLS_EXPORT CppToolsBridge +{ +public: + static void setCppToolsBridgeImplementation(std::unique_ptr<CppToolsBridgeInterface> &&interface +); + + static CppEditorDocumentHandle *cppEditorDocument(const QString &filePath); + static QString projectPartIdForFile(const QString &filePath); + static BaseEditorDocumentProcessor *baseEditorDocumentProcessor(const QString &filePath); + static void finishedRefreshingSourceFiles(const QSet<QString> &filePaths); + +private: + static std::unique_ptr<CppToolsBridgeInterface> m_interface; +}; + +} // namespace CppTools + +#endif // CPPTOOLS_CPPTOOLSBRIDGE_H diff --git a/src/plugins/cpptools/cpptoolsbridgeinterface.h b/src/plugins/cpptools/cpptoolsbridgeinterface.h new file mode 100644 index 0000000000..cdc17aa58c --- /dev/null +++ b/src/plugins/cpptools/cpptoolsbridgeinterface.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** 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 CPPTOOLSBRIDGEINTERFACE_H +#define CPPTOOLSBRIDGEINTERFACE_H + +#include <QtGlobal> + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +namespace CppTools { +class CppEditorDocumentHandle; +class BaseEditorDocumentProcessor; + +class CppToolsBridgeInterface +{ +public: + virtual ~CppToolsBridgeInterface() = default; + virtual CppEditorDocumentHandle *cppEditorDocument(const QString &filePath) const = 0; + virtual QString projectPartIdForFile(const QString &filePath) const = 0; + virtual BaseEditorDocumentProcessor *baseEditorDocumentProcessor(const QString &filePath) const = 0; + virtual void finishedRefreshingSourceFiles(const QSet<QString> &filePaths) const = 0; +}; + +} // namespace CppTools + +#endif // CPPTOOLSBRIDGEINTERFACE_H diff --git a/src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.cpp b/src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.cpp new file mode 100644 index 0000000000..9edfcfddf5 --- /dev/null +++ b/src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** 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 "cpptoolsbridgeqtcreatorimplementation.h" + +#include "baseeditordocumentparser.h" +#include "cppmodelmanager.h" +#include "cppprojects.h" +#include "editordocumenthandle.h" + +namespace CppTools { + +namespace Internal { + +CppEditorDocumentHandle * +CppToolsBridgeQtCreatorImplementation::cppEditorDocument(const QString &filePath) const +{ + return CppModelManager::instance()->cppEditorDocument(filePath); +} + +namespace { + +CppTools::ProjectPart::Ptr projectPartForFile(const QString &filePath) +{ + if (const auto parser = BaseEditorDocumentParser::get(filePath)) + return parser->projectPart(); + + return CppTools::ProjectPart::Ptr(); +} + +bool isProjectPartValid(const CppTools::ProjectPart::Ptr projectPart) +{ + if (projectPart) + return CppTools::CppModelManager::instance()->projectPartForId(projectPart->id()); + + return false; +} + +} // anonymous namespace + +QString CppToolsBridgeQtCreatorImplementation::projectPartIdForFile(const QString &filePath) const +{ + const CppTools::ProjectPart::Ptr projectPart = projectPartForFile(filePath); + + if (isProjectPartValid(projectPart)) + return projectPart->id(); // OK, Project Part is still loaded + + return QString(); +} + +BaseEditorDocumentProcessor * +CppToolsBridgeQtCreatorImplementation::baseEditorDocumentProcessor(const QString &filePath) const +{ + auto *document = cppEditorDocument(filePath); + if (document) + return document->processor(); + + return 0; +} + +void CppToolsBridgeQtCreatorImplementation::finishedRefreshingSourceFiles( + const QSet<QString> &filePaths) const +{ + CppModelManager::instance()->finishedRefreshingSourceFiles(filePaths); +} + +} // namespace Internal + +} // namespace CppTools diff --git a/src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.h b/src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.h new file mode 100644 index 0000000000..772c7f96a8 --- /dev/null +++ b/src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** 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_CPPTOOLSBRIDGEQTCREATORIMPLEMENTATION_H +#define CPPTOOLS_CPPTOOLSBRIDGEQTCREATORIMPLEMENTATION_H + +#include "cpptoolsbridgeinterface.h" + +namespace CppTools { + +namespace Internal { + +class CppToolsBridgeQtCreatorImplementation final : public CppToolsBridgeInterface +{ +public: + CppEditorDocumentHandle *cppEditorDocument(const QString &filePath) const override; + QString projectPartIdForFile(const QString &filePath) const override; + BaseEditorDocumentProcessor *baseEditorDocumentProcessor(const QString &filePath) const override; + void finishedRefreshingSourceFiles(const QSet<QString> &filePaths) const override; +}; + +} // namespace Internal +} // namespace CppTools + +#endif // CPPTOOLS_CPPTOOLSBRIDGEQTCREATORIMPLEMENTATION_H diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index f113c5fc62..6298f7a391 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -45,6 +45,8 @@ #include "cppprojectfile.h" #include "cpplocatordata.h" #include "cppincludesfilter.h" +#include "cpptoolsbridge.h" +#include "cpptoolsbridgeqtcreatorimplementation.h" #include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actionmanager.h> @@ -88,6 +90,8 @@ CppToolsPlugin::CppToolsPlugin() , m_codeModelSettings(new CppCodeModelSettings) { m_instance = this; + auto bridgeImplementation = std::unique_ptr<CppToolsBridgeQtCreatorImplementation>(new CppToolsBridgeQtCreatorImplementation); + CppToolsBridge::setCppToolsBridgeImplementation(std::move(bridgeImplementation)); } CppToolsPlugin::~CppToolsPlugin() |