From 62a870a14fda87248ec1ab4a6ff1c7880bd2d8ac Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 26 Jun 2014 00:27:27 +0200 Subject: [PATCH] TextEditor: Simplify HighlighterFactory hierarchy Change-Id: I555639a9137dcb8ccb471e1615823870c8158b3c Reviewed-by: Daniel Teske Reviewed-by: hjk --- .../cmakehighlighterfactory.cpp | 45 ---------------- .../cmakehighlighterfactory.h | 51 ------------------- .../cmakeprojectmanager.pro | 2 - .../cmakeprojectmanager.qbs | 2 - .../cmakeprojectplugin.cpp | 11 +++- src/plugins/cppeditor/cppeditor.pro | 2 - src/plugins/cppeditor/cppeditor.qbs | 1 - src/plugins/cppeditor/cppeditorplugin.cpp | 13 ++++- .../cppeditor/cpphighlighterfactory.cpp | 48 ----------------- src/plugins/cppeditor/cpphighlighterfactory.h | 51 ------------------- .../diffeditor/sidebysidediffeditorwidget.cpp | 12 ++--- .../diffeditor/unifieddiffeditorwidget.cpp | 2 +- src/plugins/glsleditor/glsleditor.pro | 2 - src/plugins/glsleditor/glsleditor.qbs | 2 - src/plugins/glsleditor/glsleditorplugin.cpp | 13 ++++- .../glsleditor/glslhighlighterfactory.cpp | 49 ------------------ .../glsleditor/glslhighlighterfactory.h | 51 ------------------- src/plugins/pythoneditor/pythoneditor.pro | 2 - src/plugins/pythoneditor/pythoneditor.qbs | 1 - .../pythoneditor/pythoneditorplugin.cpp | 10 +++- .../tools/pythonhighlighterfactory.cpp | 45 ---------------- .../tools/pythonhighlighterfactory.h | 51 ------------------- .../profilehighlighterfactory.cpp | 47 ----------------- .../profilehighlighterfactory.h | 51 ------------------- .../qmakeprojectmanager.pro | 2 - .../qmakeprojectmanager.qbs | 1 - .../qmakeprojectmanagerplugin.cpp | 12 ++++- src/plugins/qmljseditor/qmljseditor.pro | 2 - src/plugins/qmljseditor/qmljseditor.qbs | 2 - src/plugins/qmljseditor/qmljseditorplugin.cpp | 14 ++++- .../qmljseditor/qmljshighlighterfactory.cpp | 51 ------------------- .../qmljseditor/qmljshighlighterfactory.h | 51 ------------------- ...hlighterfactory.h => highlighterfactory.h} | 19 ++++--- src/plugins/texteditor/texteditor.pro | 2 +- src/plugins/texteditor/texteditor.qbs | 2 +- 35 files changed, 82 insertions(+), 640 deletions(-) delete mode 100644 src/plugins/cmakeprojectmanager/cmakehighlighterfactory.cpp delete mode 100644 src/plugins/cmakeprojectmanager/cmakehighlighterfactory.h delete mode 100644 src/plugins/cppeditor/cpphighlighterfactory.cpp delete mode 100644 src/plugins/cppeditor/cpphighlighterfactory.h delete mode 100644 src/plugins/glsleditor/glslhighlighterfactory.cpp delete mode 100644 src/plugins/glsleditor/glslhighlighterfactory.h delete mode 100644 src/plugins/pythoneditor/tools/pythonhighlighterfactory.cpp delete mode 100644 src/plugins/pythoneditor/tools/pythonhighlighterfactory.h delete mode 100644 src/plugins/qmakeprojectmanager/profilehighlighterfactory.cpp delete mode 100644 src/plugins/qmakeprojectmanager/profilehighlighterfactory.h delete mode 100644 src/plugins/qmljseditor/qmljshighlighterfactory.cpp delete mode 100644 src/plugins/qmljseditor/qmljshighlighterfactory.h rename src/plugins/texteditor/{ihighlighterfactory.h => highlighterfactory.h} (83%) diff --git a/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.cpp b/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.cpp deleted file mode 100644 index 6cb28fcb05f..00000000000 --- a/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "cmakehighlighterfactory.h" -#include "cmakeprojectconstants.h" -#include "cmakehighlighter.h" - -using namespace CMakeProjectManager::Internal; - -CMakeHighlighterFactory::CMakeHighlighterFactory() -{ - setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); - addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE); -} - -TextEditor::SyntaxHighlighter *CMakeHighlighterFactory::createHighlighter() const -{ - return new CMakeHighlighter; -} diff --git a/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.h b/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.h deleted file mode 100644 index bd5371b2efc..00000000000 --- a/src/plugins/cmakeprojectmanager/cmakehighlighterfactory.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CMAKEHIGHLIGHTERFACTORY_H -#define CMAKEHIGHLIGHTERFACTORY_H - -#include - -namespace CMakeProjectManager { -namespace Internal { - -class CMakeHighlighterFactory : public TextEditor::IHighlighterFactory -{ - Q_OBJECT - -public: - CMakeHighlighterFactory(); - - virtual TextEditor::SyntaxHighlighter *createHighlighter() const; -}; - -} // namespace Internal -} // namespace CMakeProjectManager - -#endif // CMAKEHIGHLIGHTERFACTORY_H diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index 953dfbb7478..79096afd0fd 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -13,7 +13,6 @@ HEADERS = cmakebuildinfo.h \ cmakeeditorfactory.h \ cmakeeditor.h \ cmakehighlighter.h \ - cmakehighlighterfactory.h \ cmakelocatorfilter.h \ cmakefilecompletionassist.h \ cmaketool.h \ @@ -32,7 +31,6 @@ SOURCES = cmakeproject.cpp \ cmakeeditorfactory.cpp \ cmakeeditor.cpp \ cmakehighlighter.cpp \ - cmakehighlighterfactory.cpp \ cmakelocatorfilter.cpp \ cmakefilecompletionassist.cpp \ cmaketool.cpp \ diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs index aaa7e9c65b6..2fd4f5719b4 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs @@ -32,8 +32,6 @@ QtcPlugin { "cmakefilecompletionassist.h", "cmakehighlighter.cpp", "cmakehighlighter.h", - "cmakehighlighterfactory.cpp", - "cmakehighlighterfactory.h", "cmakelocatorfilter.cpp", "cmakelocatorfilter.h", "cmakeopenprojectwizard.cpp", diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index 91e3b7a9102..bbe3a19c20e 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -36,11 +36,12 @@ #include "cmakeprojectconstants.h" #include "cmakelocatorfilter.h" #include "cmakefilecompletionassist.h" -#include "cmakehighlighterfactory.h" +#include "cmakehighlighter.h" #include #include #include +#include #include #include @@ -82,7 +83,13 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString * addAutoReleasedObject(new CMakeLocatorFilter); addAutoReleasedObject(new CMakeFileCompletionAssistProvider(cmp)); addAutoReleasedObject(new CMakeFeatureProvider); - addAutoReleasedObject(new CMakeHighlighterFactory); + + auto hf = new TextEditor::HighlighterFactory; + hf->setProductType(); + hf->setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); + hf->addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE); + addAutoReleasedObject(hf); + return true; } diff --git a/src/plugins/cppeditor/cppeditor.pro b/src/plugins/cppeditor/cppeditor.pro index f193965cff7..60879a983d5 100644 --- a/src/plugins/cppeditor/cppeditor.pro +++ b/src/plugins/cppeditor/cppeditor.pro @@ -19,7 +19,6 @@ HEADERS += \ cppfollowsymbolundercursor.h \ cppfunctiondecldeflink.h \ cpphighlighter.h \ - cpphighlighterfactory.h \ cpphoverhandler.h \ cppincludehierarchy.h \ cppincludehierarchyitem.h \ @@ -52,7 +51,6 @@ SOURCES += \ cppfollowsymbolundercursor.cpp \ cppfunctiondecldeflink.cpp \ cpphighlighter.cpp \ - cpphighlighterfactory.cpp \ cpphoverhandler.cpp \ cppincludehierarchy.cpp \ cppincludehierarchyitem.cpp \ diff --git a/src/plugins/cppeditor/cppeditor.qbs b/src/plugins/cppeditor/cppeditor.qbs index 73dd841d4f0..75d62cf271a 100644 --- a/src/plugins/cppeditor/cppeditor.qbs +++ b/src/plugins/cppeditor/cppeditor.qbs @@ -37,7 +37,6 @@ QtcPlugin { "cppfollowsymbolundercursor.cpp", "cppfollowsymbolundercursor.h", "cppfunctiondecldeflink.cpp", "cppfunctiondecldeflink.h", "cpphighlighter.cpp", "cpphighlighter.h", - "cpphighlighterfactory.cpp", "cpphighlighterfactory.h", "cpphoverhandler.cpp", "cpphoverhandler.h", "cppincludehierarchy.cpp", "cppincludehierarchy.h", "cppincludehierarchyitem.cpp", "cppincludehierarchyitem.h", diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index cd0b053fa33..3cd16607be5 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -35,7 +35,7 @@ #include "cppeditor.h" #include "cppeditoroutline.h" #include "cppfilewizard.h" -#include "cpphighlighterfactory.h" +#include "cpphighlighter.h" #include "cpphoverhandler.h" #include "cppincludehierarchy.h" #include "cppoutline.h" @@ -55,6 +55,7 @@ #include #include #include +#include #include @@ -165,7 +166,15 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err addAutoReleasedObject(new CppTypeHierarchyFactory); addAutoReleasedObject(new CppIncludeHierarchyFactory); addAutoReleasedObject(new CppSnippetProvider); - addAutoReleasedObject(new CppHighlighterFactory); + + auto hf = new TextEditor::HighlighterFactory; + hf->setProductType(); + hf->setId(CppEditor::Constants::CPPEDITOR_ID); + hf->addMimeType(CppEditor::Constants::C_SOURCE_MIMETYPE); + hf->addMimeType(CppEditor::Constants::C_HEADER_MIMETYPE); + hf->addMimeType(CppEditor::Constants::CPP_SOURCE_MIMETYPE); + hf->addMimeType(CppEditor::Constants::CPP_HEADER_MIMETYPE); + addAutoReleasedObject(hf); m_quickFixProvider = new CppQuickFixAssistProvider; addAutoReleasedObject(m_quickFixProvider); diff --git a/src/plugins/cppeditor/cpphighlighterfactory.cpp b/src/plugins/cppeditor/cpphighlighterfactory.cpp deleted file mode 100644 index d4abb8cedc4..00000000000 --- a/src/plugins/cppeditor/cpphighlighterfactory.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "cpphighlighterfactory.h" -#include "cppeditorconstants.h" -#include "cpphighlighter.h" - -using namespace CppEditor::Internal; - -CppHighlighterFactory::CppHighlighterFactory() -{ - setId(CppEditor::Constants::CPPEDITOR_ID); - addMimeType(CppEditor::Constants::C_SOURCE_MIMETYPE); - addMimeType(CppEditor::Constants::C_HEADER_MIMETYPE); - addMimeType(CppEditor::Constants::CPP_SOURCE_MIMETYPE); - addMimeType(CppEditor::Constants::CPP_HEADER_MIMETYPE); -} - -TextEditor::SyntaxHighlighter *CppHighlighterFactory::createHighlighter() const -{ - return new CppHighlighter; -} diff --git a/src/plugins/cppeditor/cpphighlighterfactory.h b/src/plugins/cppeditor/cpphighlighterfactory.h deleted file mode 100644 index bf73d2aa14f..00000000000 --- a/src/plugins/cppeditor/cpphighlighterfactory.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CPPHIGHLIGHTERFACTORY_H -#define CPPHIGHLIGHTERFACTORY_H - -#include - -namespace CppEditor { -namespace Internal { - -class CppHighlighterFactory : public TextEditor::IHighlighterFactory -{ - Q_OBJECT - -public: - CppHighlighterFactory(); - - virtual TextEditor::SyntaxHighlighter *createHighlighter() const; -}; - -} // namespace Internal -} // namespace CppEditor - -#endif // CPPHIGHLIGHTERFACTORY_H diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp index 357eac2fe2f..adb6ab52e8a 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include #include @@ -110,7 +110,7 @@ protected: private: SideDiffEditorWidget *m_editor; - QMap m_mimeTypeToHighlighterFactory; + QMap m_mimeTypeToHighlighterFactory; QList m_highlighters; QList m_documents; }; @@ -235,9 +235,9 @@ MultiHighlighter::MultiHighlighter(SideDiffEditorWidget *editor, QTextDocument * : SyntaxHighlighter(document), m_editor(editor) { - const QList &factories = - ExtensionSystem::PluginManager::getObjects(); - foreach (IHighlighterFactory *factory, factories) { + const QList &factories = + ExtensionSystem::PluginManager::getObjects(); + foreach (HighlighterFactory *factory, factories) { QStringList mimeTypes = factory->mimeTypes(); foreach (const QString &mimeType, mimeTypes) m_mimeTypeToHighlighterFactory.insert(mimeType, factory); @@ -274,7 +274,7 @@ void MultiHighlighter::setDocuments(const QList > & QTextDocument *document = new QTextDocument(contents); const MimeType mimeType = MimeDatabase::findByFile(QFileInfo(fileInfo.fileName)); SyntaxHighlighter *highlighter = 0; - if (const IHighlighterFactory *factory = m_mimeTypeToHighlighterFactory.value(mimeType.type())) { + if (const HighlighterFactory *factory = m_mimeTypeToHighlighterFactory.value(mimeType.type())) { highlighter = factory->createHighlighter(); if (highlighter) highlighter->setDocument(document); diff --git a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp index ec887c6d727..040dba1345b 100644 --- a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp +++ b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp @@ -45,7 +45,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/plugins/glsleditor/glsleditor.pro b/src/plugins/glsleditor/glsleditor.pro index e7f5375a74a..ad353b0b462 100644 --- a/src/plugins/glsleditor/glsleditor.pro +++ b/src/plugins/glsleditor/glsleditor.pro @@ -11,7 +11,6 @@ glsleditorfactory.h \ glsleditorplugin.h \ glslfilewizard.h \ glslhighlighter.h \ -glslhighlighterfactory.h \ glslautocompleter.h \ glslindenter.h \ glslhoverhandler.h \ @@ -25,7 +24,6 @@ glsleditorfactory.cpp \ glsleditorplugin.cpp \ glslfilewizard.cpp \ glslhighlighter.cpp \ -glslhighlighterfactory.cpp \ glslautocompleter.cpp \ glslindenter.cpp \ glslhoverhandler.cpp \ diff --git a/src/plugins/glsleditor/glsleditor.qbs b/src/plugins/glsleditor/glsleditor.qbs index 7bdb7069246..79f0dd0a6af 100644 --- a/src/plugins/glsleditor/glsleditor.qbs +++ b/src/plugins/glsleditor/glsleditor.qbs @@ -34,8 +34,6 @@ QtcPlugin { "glslfilewizard.h", "glslhighlighter.cpp", "glslhighlighter.h", - "glslhighlighterfactory.cpp", - "glslhighlighterfactory.h", "glslhoverhandler.cpp", "glslhoverhandler.h", "glslindenter.cpp", diff --git a/src/plugins/glsleditor/glsleditorplugin.cpp b/src/plugins/glsleditor/glsleditorplugin.cpp index 9b79c19ae19..a8ecc376591 100644 --- a/src/plugins/glsleditor/glsleditorplugin.cpp +++ b/src/plugins/glsleditor/glsleditorplugin.cpp @@ -34,7 +34,7 @@ #include "glslfilewizard.h" #include "glslhoverhandler.h" #include "glslcompletionassist.h" -#include "glslhighlighterfactory.h" +#include "glslhighlighter.h" #include #include @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -219,7 +220,15 @@ bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er wizard->setId(QLatin1String("K.GLSL")); addAutoReleasedObject(wizard); - addAutoReleasedObject(new GLSLHighlighterFactory); + auto hf = new TextEditor::HighlighterFactory; + hf->setProductType(); + hf->setId(GLSLEditor::Constants::C_GLSLEDITOR_ID); + hf->addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE); + hf->addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_VERT); + hf->addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG); + hf->addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_VERT_ES); + hf->addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG_ES); + addAutoReleasedObject(hf); return true; } diff --git a/src/plugins/glsleditor/glslhighlighterfactory.cpp b/src/plugins/glsleditor/glslhighlighterfactory.cpp deleted file mode 100644 index 2ca6bb12c9d..00000000000 --- a/src/plugins/glsleditor/glslhighlighterfactory.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "glslhighlighterfactory.h" -#include "glsleditorconstants.h" -#include "glslhighlighter.h" - -using namespace GLSLEditor::Internal; - -GLSLHighlighterFactory::GLSLHighlighterFactory() -{ - setId(GLSLEditor::Constants::C_GLSLEDITOR_ID); - addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE); - addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_VERT); - addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG); - addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_VERT_ES); - addMimeType(GLSLEditor::Constants::GLSL_MIMETYPE_FRAG_ES); -} - -TextEditor::SyntaxHighlighter *GLSLHighlighterFactory::createHighlighter() const -{ - return new Highlighter; -} diff --git a/src/plugins/glsleditor/glslhighlighterfactory.h b/src/plugins/glsleditor/glslhighlighterfactory.h deleted file mode 100644 index a5233e5f78b..00000000000 --- a/src/plugins/glsleditor/glslhighlighterfactory.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef GLSLHIGHLIGHTERFACTORY_H -#define GLSLHIGHLIGHTERFACTORY_H - -#include - -namespace GLSLEditor { -namespace Internal { - -class GLSLHighlighterFactory : public TextEditor::IHighlighterFactory -{ - Q_OBJECT - -public: - GLSLHighlighterFactory(); - - virtual TextEditor::SyntaxHighlighter *createHighlighter() const; -}; - -} // namespace Internal -} // namespace GLSLEditor - -#endif // GLSLHIGHLIGHTERFACTORY_H diff --git a/src/plugins/pythoneditor/pythoneditor.pro b/src/plugins/pythoneditor/pythoneditor.pro index 9d87e03a12a..0e7e02672fd 100644 --- a/src/plugins/pythoneditor/pythoneditor.pro +++ b/src/plugins/pythoneditor/pythoneditor.pro @@ -18,7 +18,6 @@ HEADERS += \ wizard/pythonclasswizarddialog.h \ wizard/pythonsourcegenerator.h \ tools/pythonhighlighter.h \ - tools/pythonhighlighterfactory.h \ tools/pythonindenter.h \ tools/lexical/pythonformattoken.h \ tools/lexical/pythonscanner.h \ @@ -35,6 +34,5 @@ SOURCES += \ wizard/pythonclassnamepage.cpp \ wizard/pythonsourcegenerator.cpp \ tools/pythonhighlighter.cpp \ - tools/pythonhighlighterfactory.cpp \ tools/pythonindenter.cpp \ tools/lexical/pythonscanner.cpp diff --git a/src/plugins/pythoneditor/pythoneditor.qbs b/src/plugins/pythoneditor/pythoneditor.qbs index f7452298c59..b4fa33999ec 100644 --- a/src/plugins/pythoneditor/pythoneditor.qbs +++ b/src/plugins/pythoneditor/pythoneditor.qbs @@ -33,7 +33,6 @@ QtcPlugin { "lexical/pythonscanner.h", "lexical/pythonscanner.cpp", "lexical/sourcecodestream.h", "pythonhighlighter.h", "pythonhighlighter.cpp", - "pythonhighlighterfactory.h", "pythonhighlighterfactory.cpp", "pythonindenter.cpp", "pythonindenter.h" ] } diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index 4be66910696..3b1c3bccce2 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -33,7 +33,7 @@ #include "wizard/pythonclasswizard.h" #include "pythoneditorwidget.h" #include "pythoneditorfactory.h" -#include "tools/pythonhighlighterfactory.h" +#include "tools/pythonhighlighter.h" #include #include @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -229,7 +230,12 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error // Add Python files and classes creation dialogs addAutoReleasedObject(new FileWizard); addAutoReleasedObject(new ClassWizard); - addAutoReleasedObject(new Internal::PythonHighlighterFactory); + + auto hf = new TextEditor::HighlighterFactory; + hf->setId(Constants::C_PYTHONEDITOR_ID); + hf->setProductType(); + hf->addMimeType(QLatin1String(Constants::C_PY_MIMETYPE)); + addAutoReleasedObject(hf); return true; } diff --git a/src/plugins/pythoneditor/tools/pythonhighlighterfactory.cpp b/src/plugins/pythoneditor/tools/pythonhighlighterfactory.cpp deleted file mode 100644 index 8ed05e42797..00000000000 --- a/src/plugins/pythoneditor/tools/pythonhighlighterfactory.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "pythonhighlighterfactory.h" -#include "../pythoneditorconstants.h" -#include "pythonhighlighter.h" - -using namespace PythonEditor::Internal; - -PythonHighlighterFactory::PythonHighlighterFactory() -{ - setId(Constants::C_PYTHONEDITOR_ID); - addMimeType(QLatin1String(Constants::C_PY_MIMETYPE)); -} - -TextEditor::SyntaxHighlighter *PythonHighlighterFactory::createHighlighter() const -{ - return new PythonHighlighter; -} diff --git a/src/plugins/pythoneditor/tools/pythonhighlighterfactory.h b/src/plugins/pythoneditor/tools/pythonhighlighterfactory.h deleted file mode 100644 index 5b54b12375b..00000000000 --- a/src/plugins/pythoneditor/tools/pythonhighlighterfactory.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef PYTHONHIGHLIGHTERFACTORY_H -#define PYTHONHIGHLIGHTERFACTORY_H - -#include - -namespace PythonEditor { -namespace Internal { - -class PythonHighlighterFactory : public TextEditor::IHighlighterFactory -{ - Q_OBJECT - -public: - PythonHighlighterFactory(); - - virtual TextEditor::SyntaxHighlighter *createHighlighter() const; -}; - -} // namespace Internal -} // namespace PythonEditor - -#endif // PYTHONHIGHLIGHTERFACTORY_H diff --git a/src/plugins/qmakeprojectmanager/profilehighlighterfactory.cpp b/src/plugins/qmakeprojectmanager/profilehighlighterfactory.cpp deleted file mode 100644 index 904745a7f64..00000000000 --- a/src/plugins/qmakeprojectmanager/profilehighlighterfactory.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "profilehighlighterfactory.h" -#include "qmakeprojectmanagerconstants.h" -#include "profilehighlighter.h" - -using namespace QmakeProjectManager::Internal; - -ProFileHighlighterFactory::ProFileHighlighterFactory() -{ - setId(QmakeProjectManager::Constants::PROFILE_EDITOR_ID); - addMimeType(QmakeProjectManager::Constants::PROFILE_MIMETYPE); - addMimeType(QmakeProjectManager::Constants::PROINCLUDEFILE_MIMETYPE); - addMimeType(QmakeProjectManager::Constants::PROFEATUREFILE_MIMETYPE); -} - -TextEditor::SyntaxHighlighter *ProFileHighlighterFactory::createHighlighter() const -{ - return new ProFileHighlighter; -} diff --git a/src/plugins/qmakeprojectmanager/profilehighlighterfactory.h b/src/plugins/qmakeprojectmanager/profilehighlighterfactory.h deleted file mode 100644 index bfeafaa6b76..00000000000 --- a/src/plugins/qmakeprojectmanager/profilehighlighterfactory.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef PROFILEHIGHLIGHTERFACTORY_H -#define PROFILEHIGHLIGHTERFACTORY_H - -#include - -namespace QmakeProjectManager { -namespace Internal { - -class ProFileHighlighterFactory : public TextEditor::IHighlighterFactory -{ - Q_OBJECT - -public: - ProFileHighlighterFactory(); - - virtual TextEditor::SyntaxHighlighter *createHighlighter() const; -}; - -} // namespace Internal -} // namespace QmakeProjectManager - -#endif // PROFILEHIGHLIGHTERFACTORY_H diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro index c115379c673..7146c0f11b1 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro @@ -16,7 +16,6 @@ HEADERS += \ qmakenodes.h \ profileeditor.h \ profilehighlighter.h \ - profilehighlighterfactory.h \ profileeditorfactory.h \ profilehoverhandler.h \ wizards/qtprojectparameters.h \ @@ -68,7 +67,6 @@ SOURCES += \ qmakenodes.cpp \ profileeditor.cpp \ profilehighlighter.cpp \ - profilehighlighterfactory.cpp \ profileeditorfactory.cpp \ profilehoverhandler.cpp \ wizards/qtprojectparameters.cpp \ diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs index a6d4d6ce575..dc98d61df25 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs @@ -36,7 +36,6 @@ QtcPlugin { "profileeditor.cpp", "profileeditor.h", "profileeditorfactory.cpp", "profileeditorfactory.h", "profilehighlighter.cpp", "profilehighlighter.h", - "profilehighlighterfactory.cpp", "profilehighlighterfactory.h", "profilehoverhandler.cpp", "profilehoverhandler.h", "qmakebuildinfo.h", "qmakeparser.cpp", "qmakeparser.h", diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp index 0895a8d758e..83df8908f64 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp @@ -50,7 +50,7 @@ #include "externaleditors.h" #include "profilecompletionassist.h" #include "qmakekitinformation.h" -#include "profilehighlighterfactory.h" +#include "profilehighlighter.h" #include #include @@ -65,6 +65,7 @@ #include #include #include +#include #include #include @@ -142,7 +143,14 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString addAutoReleasedObject(new ProFileCompletionAssistProvider); addAutoReleasedObject(new ProFileHoverHandler(this)); - addAutoReleasedObject(new ProFileHighlighterFactory); + + auto hf = new TextEditor::HighlighterFactory; + hf->setProductType(); + hf->setId(QmakeProjectManager::Constants::PROFILE_EDITOR_ID); + hf->addMimeType(QmakeProjectManager::Constants::PROFILE_MIMETYPE); + hf->addMimeType(QmakeProjectManager::Constants::PROINCLUDEFILE_MIMETYPE); + hf->addMimeType(QmakeProjectManager::Constants::PROFEATUREFILE_MIMETYPE); + addAutoReleasedObject(hf); //menus Core::ActionContainer *mbuild = diff --git a/src/plugins/qmljseditor/qmljseditor.pro b/src/plugins/qmljseditor/qmljseditor.pro index 6b93b7913db..c09ce621e70 100644 --- a/src/plugins/qmljseditor/qmljseditor.pro +++ b/src/plugins/qmljseditor/qmljseditor.pro @@ -13,7 +13,6 @@ HEADERS += \ qmlexpressionundercursor.h \ qmlfilewizard.h \ qmljshighlighter.h \ - qmljshighlighterfactory.h \ qmljshoverhandler.h \ qmljspreviewrunner.h \ qmljscomponentfromobjectdef.h \ @@ -46,7 +45,6 @@ SOURCES += \ qmlexpressionundercursor.cpp \ qmlfilewizard.cpp \ qmljshighlighter.cpp \ - qmljshighlighterfactory.cpp \ qmljshoverhandler.cpp \ qmljspreviewrunner.cpp \ qmljscomponentfromobjectdef.cpp \ diff --git a/src/plugins/qmljseditor/qmljseditor.qbs b/src/plugins/qmljseditor/qmljseditor.qbs index 67f23d2fc08..6bde46b85a5 100644 --- a/src/plugins/qmljseditor/qmljseditor.qbs +++ b/src/plugins/qmljseditor/qmljseditor.qbs @@ -51,8 +51,6 @@ QtcPlugin { "qmljsfindreferences.h", "qmljshighlighter.cpp", "qmljshighlighter.h", - "qmljshighlighterfactory.cpp", - "qmljshighlighterfactory.h", "qmljshoverhandler.cpp", "qmljshoverhandler.h", "qmljsoutline.cpp", diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 752dab8730a..0e3442c6c0f 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -44,7 +44,6 @@ #include "quicktoolbarsettingspage.h" #include "qmljscompletionassist.h" #include "qmljsquickfixassist.h" -#include "qmljshighlighterfactory.h" #include #include @@ -64,6 +63,7 @@ #include #include #include +#include #include #include @@ -114,7 +114,17 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e { m_modelManager = QmlJS::ModelManagerInterface::instance(); addAutoReleasedObject(new QmlJSSnippetProvider); - addAutoReleasedObject(new QmlJSHighlighterFactory); + + auto hf = new TextEditor::HighlighterFactory; + hf->setProductType(); + hf->setId(Constants::C_QMLJSEDITOR_ID); + hf->addMimeType(QmlJSTools::Constants::QML_MIMETYPE); + hf->addMimeType(QmlJSTools::Constants::QMLPROJECT_MIMETYPE); + hf->addMimeType(QmlJSTools::Constants::QBS_MIMETYPE); + hf->addMimeType(QmlJSTools::Constants::QMLTYPES_MIMETYPE); + hf->addMimeType(QmlJSTools::Constants::JS_MIMETYPE); + hf->addMimeType(QmlJSTools::Constants::JSON_MIMETYPE); + addAutoReleasedObject(hf); // QML task updating manager m_qmlTaskManager = new QmlTaskManager; diff --git a/src/plugins/qmljseditor/qmljshighlighterfactory.cpp b/src/plugins/qmljseditor/qmljshighlighterfactory.cpp deleted file mode 100644 index 0de134616a2..00000000000 --- a/src/plugins/qmljseditor/qmljshighlighterfactory.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qmljshighlighterfactory.h" -#include "qmljseditorconstants.h" -#include "qmljshighlighter.h" -#include - -using namespace QmlJSEditor::Internal; - -QmlJSHighlighterFactory::QmlJSHighlighterFactory() -{ - setId(Constants::C_QMLJSEDITOR_ID); - addMimeType(QmlJSTools::Constants::QML_MIMETYPE); - addMimeType(QmlJSTools::Constants::QMLPROJECT_MIMETYPE); - addMimeType(QmlJSTools::Constants::QBS_MIMETYPE); - addMimeType(QmlJSTools::Constants::QMLTYPES_MIMETYPE); - addMimeType(QmlJSTools::Constants::JS_MIMETYPE); - addMimeType(QmlJSTools::Constants::JSON_MIMETYPE); -} - -TextEditor::SyntaxHighlighter *QmlJSHighlighterFactory::createHighlighter() const -{ - return new Highlighter; -} diff --git a/src/plugins/qmljseditor/qmljshighlighterfactory.h b/src/plugins/qmljseditor/qmljshighlighterfactory.h deleted file mode 100644 index 842e5dcef9b..00000000000 --- a/src/plugins/qmljseditor/qmljshighlighterfactory.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** 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 Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/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 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QMLJSHIGHLIGHTERFACTORY_H -#define QMLJSHIGHLIGHTERFACTORY_H - -#include - -namespace QmlJSEditor { -namespace Internal { - -class QmlJSHighlighterFactory : public TextEditor::IHighlighterFactory -{ - Q_OBJECT - -public: - QmlJSHighlighterFactory(); - - virtual TextEditor::SyntaxHighlighter *createHighlighter() const; -}; - -} // namespace Internal -} // namespace QmlJSEditor - -#endif // QMLJSHIGHLIGHTERFACTORY_H diff --git a/src/plugins/texteditor/ihighlighterfactory.h b/src/plugins/texteditor/highlighterfactory.h similarity index 83% rename from src/plugins/texteditor/ihighlighterfactory.h rename to src/plugins/texteditor/highlighterfactory.h index a3c39e635b4..5576480824d 100644 --- a/src/plugins/texteditor/ihighlighterfactory.h +++ b/src/plugins/texteditor/highlighterfactory.h @@ -27,8 +27,8 @@ ** ****************************************************************************/ -#ifndef IHIGHLIGHTERFACTORY_H -#define IHIGHLIGHTERFACTORY_H +#ifndef HIGHLIGHTERFACTORY_H +#define HIGHLIGHTERFACTORY_H #include #include @@ -36,20 +36,24 @@ #include #include +#include + namespace TextEditor { class SyntaxHighlighter; -class TEXTEDITOR_EXPORT IHighlighterFactory : public QObject +class TEXTEDITOR_EXPORT HighlighterFactory : public QObject { Q_OBJECT -public: - virtual TextEditor::SyntaxHighlighter *createHighlighter() const = 0; +public: + typedef std::function Creator; + TextEditor::SyntaxHighlighter *createHighlighter() const { return m_creator(); } + + template void setProductType() { m_creator = []() { return new T; }; } Core::Id id() const { return m_id; } QStringList mimeTypes() const { return m_mimeTypes; } -protected: void setId(Core::Id id) { m_id = id; } void setMimeTypes(const QStringList &mimeTypes) { m_mimeTypes = mimeTypes; } void addMimeType(const char *mimeType) { m_mimeTypes.append(QLatin1String(mimeType)); } @@ -58,9 +62,10 @@ protected: private: Core::Id m_id; QStringList m_mimeTypes; + Creator m_creator; }; } // TextEditor -#endif // IHIGHLIGHTERFACTORY_H +#endif // HIGHLIGHTERFACTORY_H diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro index a580e286bb0..8e226aec200 100644 --- a/src/plugins/texteditor/texteditor.pro +++ b/src/plugins/texteditor/texteditor.pro @@ -146,7 +146,7 @@ HEADERS += texteditorplugin.h \ normalindenter.h \ indenter.h \ quickfix.h \ - ihighlighterfactory.h \ + highlighterfactory.h \ syntaxhighlighter.h \ highlighterutils.h \ generichighlighter/reuse.h \ diff --git a/src/plugins/texteditor/texteditor.qbs b/src/plugins/texteditor/texteditor.qbs index a695c2af8d8..c630ae0715d 100644 --- a/src/plugins/texteditor/texteditor.qbs +++ b/src/plugins/texteditor/texteditor.qbs @@ -87,7 +87,7 @@ QtcPlugin { "icodestylepreferences.h", "icodestylepreferencesfactory.cpp", "icodestylepreferencesfactory.h", - "ihighlighterfactory.h", + "highlighterfactory.h", "indenter.cpp", "indenter.h", "ioutlinewidget.h",