TextEditor: Simplify HighlighterFactory hierarchy

Change-Id: I555639a9137dcb8ccb471e1615823870c8158b3c
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hjk
2014-06-26 00:27:27 +02:00
parent 922f25170c
commit 62a870a14f
35 changed files with 82 additions and 640 deletions

View File

@@ -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;
}

View File

@@ -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 <texteditor/ihighlighterfactory.h>
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

View File

@@ -13,7 +13,6 @@ HEADERS = cmakebuildinfo.h \
cmakeeditorfactory.h \ cmakeeditorfactory.h \
cmakeeditor.h \ cmakeeditor.h \
cmakehighlighter.h \ cmakehighlighter.h \
cmakehighlighterfactory.h \
cmakelocatorfilter.h \ cmakelocatorfilter.h \
cmakefilecompletionassist.h \ cmakefilecompletionassist.h \
cmaketool.h \ cmaketool.h \
@@ -32,7 +31,6 @@ SOURCES = cmakeproject.cpp \
cmakeeditorfactory.cpp \ cmakeeditorfactory.cpp \
cmakeeditor.cpp \ cmakeeditor.cpp \
cmakehighlighter.cpp \ cmakehighlighter.cpp \
cmakehighlighterfactory.cpp \
cmakelocatorfilter.cpp \ cmakelocatorfilter.cpp \
cmakefilecompletionassist.cpp \ cmakefilecompletionassist.cpp \
cmaketool.cpp \ cmaketool.cpp \

View File

@@ -32,8 +32,6 @@ QtcPlugin {
"cmakefilecompletionassist.h", "cmakefilecompletionassist.h",
"cmakehighlighter.cpp", "cmakehighlighter.cpp",
"cmakehighlighter.h", "cmakehighlighter.h",
"cmakehighlighterfactory.cpp",
"cmakehighlighterfactory.h",
"cmakelocatorfilter.cpp", "cmakelocatorfilter.cpp",
"cmakelocatorfilter.h", "cmakelocatorfilter.h",
"cmakeopenprojectwizard.cpp", "cmakeopenprojectwizard.cpp",

View File

@@ -36,11 +36,12 @@
#include "cmakeprojectconstants.h" #include "cmakeprojectconstants.h"
#include "cmakelocatorfilter.h" #include "cmakelocatorfilter.h"
#include "cmakefilecompletionassist.h" #include "cmakefilecompletionassist.h"
#include "cmakehighlighterfactory.h" #include "cmakehighlighter.h"
#include <coreplugin/featureprovider.h> #include <coreplugin/featureprovider.h>
#include <coreplugin/mimedatabase.h> #include <coreplugin/mimedatabase.h>
#include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditoractionhandler.h>
#include <texteditor/highlighterfactory.h>
#include <QtPlugin> #include <QtPlugin>
#include <QDebug> #include <QDebug>
@@ -82,7 +83,13 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
addAutoReleasedObject(new CMakeLocatorFilter); addAutoReleasedObject(new CMakeLocatorFilter);
addAutoReleasedObject(new CMakeFileCompletionAssistProvider(cmp)); addAutoReleasedObject(new CMakeFileCompletionAssistProvider(cmp));
addAutoReleasedObject(new CMakeFeatureProvider); addAutoReleasedObject(new CMakeFeatureProvider);
addAutoReleasedObject(new CMakeHighlighterFactory);
auto hf = new TextEditor::HighlighterFactory;
hf->setProductType<CMakeHighlighter>();
hf->setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID);
hf->addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE);
addAutoReleasedObject(hf);
return true; return true;
} }

View File

@@ -19,7 +19,6 @@ HEADERS += \
cppfollowsymbolundercursor.h \ cppfollowsymbolundercursor.h \
cppfunctiondecldeflink.h \ cppfunctiondecldeflink.h \
cpphighlighter.h \ cpphighlighter.h \
cpphighlighterfactory.h \
cpphoverhandler.h \ cpphoverhandler.h \
cppincludehierarchy.h \ cppincludehierarchy.h \
cppincludehierarchyitem.h \ cppincludehierarchyitem.h \
@@ -52,7 +51,6 @@ SOURCES += \
cppfollowsymbolundercursor.cpp \ cppfollowsymbolundercursor.cpp \
cppfunctiondecldeflink.cpp \ cppfunctiondecldeflink.cpp \
cpphighlighter.cpp \ cpphighlighter.cpp \
cpphighlighterfactory.cpp \
cpphoverhandler.cpp \ cpphoverhandler.cpp \
cppincludehierarchy.cpp \ cppincludehierarchy.cpp \
cppincludehierarchyitem.cpp \ cppincludehierarchyitem.cpp \

View File

@@ -37,7 +37,6 @@ QtcPlugin {
"cppfollowsymbolundercursor.cpp", "cppfollowsymbolundercursor.h", "cppfollowsymbolundercursor.cpp", "cppfollowsymbolundercursor.h",
"cppfunctiondecldeflink.cpp", "cppfunctiondecldeflink.h", "cppfunctiondecldeflink.cpp", "cppfunctiondecldeflink.h",
"cpphighlighter.cpp", "cpphighlighter.h", "cpphighlighter.cpp", "cpphighlighter.h",
"cpphighlighterfactory.cpp", "cpphighlighterfactory.h",
"cpphoverhandler.cpp", "cpphoverhandler.h", "cpphoverhandler.cpp", "cpphoverhandler.h",
"cppincludehierarchy.cpp", "cppincludehierarchy.h", "cppincludehierarchy.cpp", "cppincludehierarchy.h",
"cppincludehierarchyitem.cpp", "cppincludehierarchyitem.h", "cppincludehierarchyitem.cpp", "cppincludehierarchyitem.h",

View File

@@ -35,7 +35,7 @@
#include "cppeditor.h" #include "cppeditor.h"
#include "cppeditoroutline.h" #include "cppeditoroutline.h"
#include "cppfilewizard.h" #include "cppfilewizard.h"
#include "cpphighlighterfactory.h" #include "cpphighlighter.h"
#include "cpphoverhandler.h" #include "cpphoverhandler.h"
#include "cppincludehierarchy.h" #include "cppincludehierarchy.h"
#include "cppoutline.h" #include "cppoutline.h"
@@ -55,6 +55,7 @@
#include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>
#include <texteditor/highlighterfactory.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
@@ -165,7 +166,15 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err
addAutoReleasedObject(new CppTypeHierarchyFactory); addAutoReleasedObject(new CppTypeHierarchyFactory);
addAutoReleasedObject(new CppIncludeHierarchyFactory); addAutoReleasedObject(new CppIncludeHierarchyFactory);
addAutoReleasedObject(new CppSnippetProvider); addAutoReleasedObject(new CppSnippetProvider);
addAutoReleasedObject(new CppHighlighterFactory);
auto hf = new TextEditor::HighlighterFactory;
hf->setProductType<CppHighlighter>();
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; m_quickFixProvider = new CppQuickFixAssistProvider;
addAutoReleasedObject(m_quickFixProvider); addAutoReleasedObject(m_quickFixProvider);

View File

@@ -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;
}

View File

@@ -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 <texteditor/ihighlighterfactory.h>
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

View File

@@ -46,7 +46,7 @@
#include <texteditor/basetexteditor.h> #include <texteditor/basetexteditor.h>
#include <texteditor/basetextdocumentlayout.h> #include <texteditor/basetextdocumentlayout.h>
#include <texteditor/ihighlighterfactory.h> #include <texteditor/highlighterfactory.h>
#include <texteditor/syntaxhighlighter.h> #include <texteditor/syntaxhighlighter.h>
#include <texteditor/basetextdocument.h> #include <texteditor/basetextdocument.h>
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>
@@ -110,7 +110,7 @@ protected:
private: private:
SideDiffEditorWidget *m_editor; SideDiffEditorWidget *m_editor;
QMap<QString, IHighlighterFactory *> m_mimeTypeToHighlighterFactory; QMap<QString, HighlighterFactory *> m_mimeTypeToHighlighterFactory;
QList<SyntaxHighlighter *> m_highlighters; QList<SyntaxHighlighter *> m_highlighters;
QList<QTextDocument *> m_documents; QList<QTextDocument *> m_documents;
}; };
@@ -235,9 +235,9 @@ MultiHighlighter::MultiHighlighter(SideDiffEditorWidget *editor, QTextDocument *
: SyntaxHighlighter(document), : SyntaxHighlighter(document),
m_editor(editor) m_editor(editor)
{ {
const QList<IHighlighterFactory *> &factories = const QList<HighlighterFactory *> &factories =
ExtensionSystem::PluginManager::getObjects<TextEditor::IHighlighterFactory>(); ExtensionSystem::PluginManager::getObjects<TextEditor::HighlighterFactory>();
foreach (IHighlighterFactory *factory, factories) { foreach (HighlighterFactory *factory, factories) {
QStringList mimeTypes = factory->mimeTypes(); QStringList mimeTypes = factory->mimeTypes();
foreach (const QString &mimeType, mimeTypes) foreach (const QString &mimeType, mimeTypes)
m_mimeTypeToHighlighterFactory.insert(mimeType, factory); m_mimeTypeToHighlighterFactory.insert(mimeType, factory);
@@ -274,7 +274,7 @@ void MultiHighlighter::setDocuments(const QList<QPair<DiffFileInfo, QString> > &
QTextDocument *document = new QTextDocument(contents); QTextDocument *document = new QTextDocument(contents);
const MimeType mimeType = MimeDatabase::findByFile(QFileInfo(fileInfo.fileName)); const MimeType mimeType = MimeDatabase::findByFile(QFileInfo(fileInfo.fileName));
SyntaxHighlighter *highlighter = 0; SyntaxHighlighter *highlighter = 0;
if (const IHighlighterFactory *factory = m_mimeTypeToHighlighterFactory.value(mimeType.type())) { if (const HighlighterFactory *factory = m_mimeTypeToHighlighterFactory.value(mimeType.type())) {
highlighter = factory->createHighlighter(); highlighter = factory->createHighlighter();
if (highlighter) if (highlighter)
highlighter->setDocument(document); highlighter->setDocument(document);

View File

@@ -45,7 +45,7 @@
#include <texteditor/basetexteditor.h> #include <texteditor/basetexteditor.h>
#include <texteditor/basetextdocumentlayout.h> #include <texteditor/basetextdocumentlayout.h>
#include <texteditor/ihighlighterfactory.h> #include <texteditor/highlighterfactory.h>
#include <texteditor/syntaxhighlighter.h> #include <texteditor/syntaxhighlighter.h>
#include <texteditor/basetextdocument.h> #include <texteditor/basetextdocument.h>
#include <texteditor/texteditorsettings.h> #include <texteditor/texteditorsettings.h>

View File

@@ -11,7 +11,6 @@ glsleditorfactory.h \
glsleditorplugin.h \ glsleditorplugin.h \
glslfilewizard.h \ glslfilewizard.h \
glslhighlighter.h \ glslhighlighter.h \
glslhighlighterfactory.h \
glslautocompleter.h \ glslautocompleter.h \
glslindenter.h \ glslindenter.h \
glslhoverhandler.h \ glslhoverhandler.h \
@@ -25,7 +24,6 @@ glsleditorfactory.cpp \
glsleditorplugin.cpp \ glsleditorplugin.cpp \
glslfilewizard.cpp \ glslfilewizard.cpp \
glslhighlighter.cpp \ glslhighlighter.cpp \
glslhighlighterfactory.cpp \
glslautocompleter.cpp \ glslautocompleter.cpp \
glslindenter.cpp \ glslindenter.cpp \
glslhoverhandler.cpp \ glslhoverhandler.cpp \

View File

@@ -34,8 +34,6 @@ QtcPlugin {
"glslfilewizard.h", "glslfilewizard.h",
"glslhighlighter.cpp", "glslhighlighter.cpp",
"glslhighlighter.h", "glslhighlighter.h",
"glslhighlighterfactory.cpp",
"glslhighlighterfactory.h",
"glslhoverhandler.cpp", "glslhoverhandler.cpp",
"glslhoverhandler.h", "glslhoverhandler.h",
"glslindenter.cpp", "glslindenter.cpp",

View File

@@ -34,7 +34,7 @@
#include "glslfilewizard.h" #include "glslfilewizard.h"
#include "glslhoverhandler.h" #include "glslhoverhandler.h"
#include "glslcompletionassist.h" #include "glslcompletionassist.h"
#include "glslhighlighterfactory.h" #include "glslhighlighter.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
@@ -47,6 +47,7 @@
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <projectexplorer/taskhub.h> #include <projectexplorer/taskhub.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <texteditor/highlighterfactory.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <texteditor/textfilewizard.h> #include <texteditor/textfilewizard.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -219,7 +220,15 @@ bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er
wizard->setId(QLatin1String("K.GLSL")); wizard->setId(QLatin1String("K.GLSL"));
addAutoReleasedObject(wizard); addAutoReleasedObject(wizard);
addAutoReleasedObject(new GLSLHighlighterFactory); auto hf = new TextEditor::HighlighterFactory;
hf->setProductType<Highlighter>();
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; return true;
} }

View File

@@ -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;
}

View File

@@ -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 <texteditor/ihighlighterfactory.h>
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

View File

@@ -18,7 +18,6 @@ HEADERS += \
wizard/pythonclasswizarddialog.h \ wizard/pythonclasswizarddialog.h \
wizard/pythonsourcegenerator.h \ wizard/pythonsourcegenerator.h \
tools/pythonhighlighter.h \ tools/pythonhighlighter.h \
tools/pythonhighlighterfactory.h \
tools/pythonindenter.h \ tools/pythonindenter.h \
tools/lexical/pythonformattoken.h \ tools/lexical/pythonformattoken.h \
tools/lexical/pythonscanner.h \ tools/lexical/pythonscanner.h \
@@ -35,6 +34,5 @@ SOURCES += \
wizard/pythonclassnamepage.cpp \ wizard/pythonclassnamepage.cpp \
wizard/pythonsourcegenerator.cpp \ wizard/pythonsourcegenerator.cpp \
tools/pythonhighlighter.cpp \ tools/pythonhighlighter.cpp \
tools/pythonhighlighterfactory.cpp \
tools/pythonindenter.cpp \ tools/pythonindenter.cpp \
tools/lexical/pythonscanner.cpp tools/lexical/pythonscanner.cpp

View File

@@ -33,7 +33,6 @@ QtcPlugin {
"lexical/pythonscanner.h", "lexical/pythonscanner.cpp", "lexical/pythonscanner.h", "lexical/pythonscanner.cpp",
"lexical/sourcecodestream.h", "lexical/sourcecodestream.h",
"pythonhighlighter.h", "pythonhighlighter.cpp", "pythonhighlighter.h", "pythonhighlighter.cpp",
"pythonhighlighterfactory.h", "pythonhighlighterfactory.cpp",
"pythonindenter.cpp", "pythonindenter.h" "pythonindenter.cpp", "pythonindenter.h"
] ]
} }

View File

@@ -33,7 +33,7 @@
#include "wizard/pythonclasswizard.h" #include "wizard/pythonclasswizard.h"
#include "pythoneditorwidget.h" #include "pythoneditorwidget.h"
#include "pythoneditorfactory.h" #include "pythoneditorfactory.h"
#include "tools/pythonhighlighterfactory.h" #include "tools/pythonhighlighter.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
@@ -43,6 +43,7 @@
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <texteditor/highlighterfactory.h>
#include <QtPlugin> #include <QtPlugin>
#include <QCoreApplication> #include <QCoreApplication>
@@ -229,7 +230,12 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error
// Add Python files and classes creation dialogs // Add Python files and classes creation dialogs
addAutoReleasedObject(new FileWizard); addAutoReleasedObject(new FileWizard);
addAutoReleasedObject(new ClassWizard); addAutoReleasedObject(new ClassWizard);
addAutoReleasedObject(new Internal::PythonHighlighterFactory);
auto hf = new TextEditor::HighlighterFactory;
hf->setId(Constants::C_PYTHONEDITOR_ID);
hf->setProductType<PythonHighlighter>();
hf->addMimeType(QLatin1String(Constants::C_PY_MIMETYPE));
addAutoReleasedObject(hf);
return true; return true;
} }

View File

@@ -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;
}

View File

@@ -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 <texteditor/ihighlighterfactory.h>
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

View File

@@ -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;
}

View File

@@ -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 <texteditor/ihighlighterfactory.h>
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

View File

@@ -16,7 +16,6 @@ HEADERS += \
qmakenodes.h \ qmakenodes.h \
profileeditor.h \ profileeditor.h \
profilehighlighter.h \ profilehighlighter.h \
profilehighlighterfactory.h \
profileeditorfactory.h \ profileeditorfactory.h \
profilehoverhandler.h \ profilehoverhandler.h \
wizards/qtprojectparameters.h \ wizards/qtprojectparameters.h \
@@ -68,7 +67,6 @@ SOURCES += \
qmakenodes.cpp \ qmakenodes.cpp \
profileeditor.cpp \ profileeditor.cpp \
profilehighlighter.cpp \ profilehighlighter.cpp \
profilehighlighterfactory.cpp \
profileeditorfactory.cpp \ profileeditorfactory.cpp \
profilehoverhandler.cpp \ profilehoverhandler.cpp \
wizards/qtprojectparameters.cpp \ wizards/qtprojectparameters.cpp \

View File

@@ -36,7 +36,6 @@ QtcPlugin {
"profileeditor.cpp", "profileeditor.h", "profileeditor.cpp", "profileeditor.h",
"profileeditorfactory.cpp", "profileeditorfactory.h", "profileeditorfactory.cpp", "profileeditorfactory.h",
"profilehighlighter.cpp", "profilehighlighter.h", "profilehighlighter.cpp", "profilehighlighter.h",
"profilehighlighterfactory.cpp", "profilehighlighterfactory.h",
"profilehoverhandler.cpp", "profilehoverhandler.h", "profilehoverhandler.cpp", "profilehoverhandler.h",
"qmakebuildinfo.h", "qmakebuildinfo.h",
"qmakeparser.cpp", "qmakeparser.h", "qmakeparser.cpp", "qmakeparser.h",

View File

@@ -50,7 +50,7 @@
#include "externaleditors.h" #include "externaleditors.h"
#include "profilecompletionassist.h" #include "profilecompletionassist.h"
#include "qmakekitinformation.h" #include "qmakekitinformation.h"
#include "profilehighlighterfactory.h" #include "profilehighlighter.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <projectexplorer/buildmanager.h> #include <projectexplorer/buildmanager.h>
@@ -65,6 +65,7 @@
#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/ieditor.h>
#include <texteditor/texteditoractionhandler.h> #include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <texteditor/highlighterfactory.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/parameteraction.h> #include <utils/parameteraction.h>
@@ -142,7 +143,14 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString
addAutoReleasedObject(new ProFileCompletionAssistProvider); addAutoReleasedObject(new ProFileCompletionAssistProvider);
addAutoReleasedObject(new ProFileHoverHandler(this)); addAutoReleasedObject(new ProFileHoverHandler(this));
addAutoReleasedObject(new ProFileHighlighterFactory);
auto hf = new TextEditor::HighlighterFactory;
hf->setProductType<ProFileHighlighter>();
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 //menus
Core::ActionContainer *mbuild = Core::ActionContainer *mbuild =

View File

@@ -13,7 +13,6 @@ HEADERS += \
qmlexpressionundercursor.h \ qmlexpressionundercursor.h \
qmlfilewizard.h \ qmlfilewizard.h \
qmljshighlighter.h \ qmljshighlighter.h \
qmljshighlighterfactory.h \
qmljshoverhandler.h \ qmljshoverhandler.h \
qmljspreviewrunner.h \ qmljspreviewrunner.h \
qmljscomponentfromobjectdef.h \ qmljscomponentfromobjectdef.h \
@@ -46,7 +45,6 @@ SOURCES += \
qmlexpressionundercursor.cpp \ qmlexpressionundercursor.cpp \
qmlfilewizard.cpp \ qmlfilewizard.cpp \
qmljshighlighter.cpp \ qmljshighlighter.cpp \
qmljshighlighterfactory.cpp \
qmljshoverhandler.cpp \ qmljshoverhandler.cpp \
qmljspreviewrunner.cpp \ qmljspreviewrunner.cpp \
qmljscomponentfromobjectdef.cpp \ qmljscomponentfromobjectdef.cpp \

View File

@@ -51,8 +51,6 @@ QtcPlugin {
"qmljsfindreferences.h", "qmljsfindreferences.h",
"qmljshighlighter.cpp", "qmljshighlighter.cpp",
"qmljshighlighter.h", "qmljshighlighter.h",
"qmljshighlighterfactory.cpp",
"qmljshighlighterfactory.h",
"qmljshoverhandler.cpp", "qmljshoverhandler.cpp",
"qmljshoverhandler.h", "qmljshoverhandler.h",
"qmljsoutline.cpp", "qmljsoutline.cpp",

View File

@@ -44,7 +44,6 @@
#include "quicktoolbarsettingspage.h" #include "quicktoolbarsettingspage.h"
#include "qmljscompletionassist.h" #include "qmljscompletionassist.h"
#include "qmljsquickfixassist.h" #include "qmljsquickfixassist.h"
#include "qmljshighlighterfactory.h"
#include <qmljs/qmljsicons.h> #include <qmljs/qmljsicons.h>
#include <qmljs/qmljsmodelmanagerinterface.h> #include <qmljs/qmljsmodelmanagerinterface.h>
@@ -64,6 +63,7 @@
#include <projectexplorer/taskhub.h> #include <projectexplorer/taskhub.h>
#include <texteditor/texteditorconstants.h> #include <texteditor/texteditorconstants.h>
#include <texteditor/textfilewizard.h> #include <texteditor/textfilewizard.h>
#include <texteditor/highlighterfactory.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/json.h> #include <utils/json.h>
@@ -114,7 +114,17 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
{ {
m_modelManager = QmlJS::ModelManagerInterface::instance(); m_modelManager = QmlJS::ModelManagerInterface::instance();
addAutoReleasedObject(new QmlJSSnippetProvider); addAutoReleasedObject(new QmlJSSnippetProvider);
addAutoReleasedObject(new QmlJSHighlighterFactory);
auto hf = new TextEditor::HighlighterFactory;
hf->setProductType<Highlighter>();
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 // QML task updating manager
m_qmlTaskManager = new QmlTaskManager; m_qmlTaskManager = new QmlTaskManager;

View File

@@ -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 <qmljstools/qmljstoolsconstants.h>
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;
}

View File

@@ -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 <texteditor/ihighlighterfactory.h>
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

View File

@@ -27,8 +27,8 @@
** **
****************************************************************************/ ****************************************************************************/
#ifndef IHIGHLIGHTERFACTORY_H #ifndef HIGHLIGHTERFACTORY_H
#define IHIGHLIGHTERFACTORY_H #define HIGHLIGHTERFACTORY_H
#include <texteditor/texteditor_global.h> #include <texteditor/texteditor_global.h>
#include <coreplugin/id.h> #include <coreplugin/id.h>
@@ -36,20 +36,24 @@
#include <QObject> #include <QObject>
#include <QStringList> #include <QStringList>
#include <functional>
namespace TextEditor { namespace TextEditor {
class SyntaxHighlighter; class SyntaxHighlighter;
class TEXTEDITOR_EXPORT IHighlighterFactory : public QObject class TEXTEDITOR_EXPORT HighlighterFactory : public QObject
{ {
Q_OBJECT Q_OBJECT
public:
virtual TextEditor::SyntaxHighlighter *createHighlighter() const = 0;
public:
typedef std::function<SyntaxHighlighter *()> Creator;
TextEditor::SyntaxHighlighter *createHighlighter() const { return m_creator(); }
template <class T> void setProductType() { m_creator = []() { return new T; }; }
Core::Id id() const { return m_id; } Core::Id id() const { return m_id; }
QStringList mimeTypes() const { return m_mimeTypes; } QStringList mimeTypes() const { return m_mimeTypes; }
protected:
void setId(Core::Id id) { m_id = id; } void setId(Core::Id id) { m_id = id; }
void setMimeTypes(const QStringList &mimeTypes) { m_mimeTypes = mimeTypes; } void setMimeTypes(const QStringList &mimeTypes) { m_mimeTypes = mimeTypes; }
void addMimeType(const char *mimeType) { m_mimeTypes.append(QLatin1String(mimeType)); } void addMimeType(const char *mimeType) { m_mimeTypes.append(QLatin1String(mimeType)); }
@@ -58,9 +62,10 @@ protected:
private: private:
Core::Id m_id; Core::Id m_id;
QStringList m_mimeTypes; QStringList m_mimeTypes;
Creator m_creator;
}; };
} // TextEditor } // TextEditor
#endif // IHIGHLIGHTERFACTORY_H #endif // HIGHLIGHTERFACTORY_H

View File

@@ -146,7 +146,7 @@ HEADERS += texteditorplugin.h \
normalindenter.h \ normalindenter.h \
indenter.h \ indenter.h \
quickfix.h \ quickfix.h \
ihighlighterfactory.h \ highlighterfactory.h \
syntaxhighlighter.h \ syntaxhighlighter.h \
highlighterutils.h \ highlighterutils.h \
generichighlighter/reuse.h \ generichighlighter/reuse.h \

View File

@@ -87,7 +87,7 @@ QtcPlugin {
"icodestylepreferences.h", "icodestylepreferences.h",
"icodestylepreferencesfactory.cpp", "icodestylepreferencesfactory.cpp",
"icodestylepreferencesfactory.h", "icodestylepreferencesfactory.h",
"ihighlighterfactory.h", "highlighterfactory.h",
"indenter.cpp", "indenter.cpp",
"indenter.h", "indenter.h",
"ioutlinewidget.h", "ioutlinewidget.h",