aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeandro Melo <leandro.melo@nokia.com>2010-05-20 13:56:11 +0200
committerLeandro Melo <leandro.melo@nokia.com>2010-05-20 14:10:34 +0200
commit55b26868e61bdfc11cb7de23471ebd1dbc9973d3 (patch)
tree05ecd2ad062dd61734dd7c95cbfb7b093e773954 /src
parent9b6c86bdc17f184937c36c5a101e6eead36d9e89 (diff)
Generic highlighter is now part of the text editor plugin.
Diffstat (limited to 'src')
-rw-r--r--src/libs/utils/uncommentselection.cpp7
-rw-r--r--src/libs/utils/uncommentselection.h2
-rw-r--r--src/plugins/genericeditor/GenericEditor.pluginspec20
-rw-r--r--src/plugins/genericeditor/editor.cpp148
-rw-r--r--src/plugins/genericeditor/editor.h101
-rw-r--r--src/plugins/genericeditor/editorfactory.cpp70
-rw-r--r--src/plugins/genericeditor/editorfactory.h64
-rw-r--r--src/plugins/genericeditor/genericeditor.pri3
-rw-r--r--src/plugins/genericeditor/genericeditor.pro43
-rw-r--r--src/plugins/genericeditor/genericeditor_dependencies.pri3
-rw-r--r--src/plugins/genericeditor/genericeditorconstants.h45
-rw-r--r--src/plugins/plugins.pro5
-rw-r--r--src/plugins/texteditor/generichighlighter/context.cpp (renamed from src/plugins/genericeditor/context.cpp)4
-rw-r--r--src/plugins/texteditor/generichighlighter/context.h (renamed from src/plugins/genericeditor/context.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/dynamicrule.cpp (renamed from src/plugins/genericeditor/dynamicrule.cpp)6
-rw-r--r--src/plugins/texteditor/generichighlighter/dynamicrule.h (renamed from src/plugins/genericeditor/dynamicrule.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightdefinition.cpp (renamed from src/plugins/genericeditor/highlightdefinition.cpp)2
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightdefinition.h (renamed from src/plugins/genericeditor/highlightdefinition.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp (renamed from src/plugins/genericeditor/highlightdefinitionhandler.cpp)10
-rw-r--r--src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.h (renamed from src/plugins/genericeditor/highlightdefinitionhandler.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/highlighter.cpp (renamed from src/plugins/genericeditor/highlighter.cpp)19
-rw-r--r--src/plugins/texteditor/generichighlighter/highlighter.h (renamed from src/plugins/genericeditor/highlighter.h)12
-rw-r--r--src/plugins/texteditor/generichighlighter/highlighterexception.h (renamed from src/plugins/genericeditor/highlighterexception.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/includerulesinstruction.cpp (renamed from src/plugins/genericeditor/includerulesinstruction.cpp)2
-rw-r--r--src/plugins/texteditor/generichighlighter/includerulesinstruction.h (renamed from src/plugins/genericeditor/includerulesinstruction.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/itemdata.cpp (renamed from src/plugins/genericeditor/itemdata.cpp)2
-rw-r--r--src/plugins/texteditor/generichighlighter/itemdata.h (renamed from src/plugins/genericeditor/itemdata.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/keywordlist.cpp (renamed from src/plugins/genericeditor/keywordlist.cpp)2
-rw-r--r--src/plugins/texteditor/generichighlighter/keywordlist.h (renamed from src/plugins/genericeditor/keywordlist.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/manager.cpp (renamed from src/plugins/genericeditor/genericeditorplugin.cpp)83
-rw-r--r--src/plugins/texteditor/generichighlighter/manager.h (renamed from src/plugins/genericeditor/genericeditorplugin.h)39
-rw-r--r--src/plugins/texteditor/generichighlighter/progressdata.cpp (renamed from src/plugins/genericeditor/progressdata.cpp)2
-rw-r--r--src/plugins/texteditor/generichighlighter/progressdata.h (renamed from src/plugins/genericeditor/progressdata.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/reuse.h (renamed from src/plugins/genericeditor/reuse.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/rule.cpp (renamed from src/plugins/genericeditor/rule.cpp)2
-rw-r--r--src/plugins/texteditor/generichighlighter/rule.h (renamed from src/plugins/genericeditor/rule.h)4
-rw-r--r--src/plugins/texteditor/generichighlighter/specificrules.cpp (renamed from src/plugins/genericeditor/specificrules.cpp)2
-rw-r--r--src/plugins/texteditor/generichighlighter/specificrules.h (renamed from src/plugins/genericeditor/specificrules.h)4
-rw-r--r--src/plugins/texteditor/plaintexteditor.cpp67
-rw-r--r--src/plugins/texteditor/plaintexteditor.h14
-rw-r--r--src/plugins/texteditor/plaintexteditorfactory.cpp8
-rw-r--r--src/plugins/texteditor/plaintexteditorfactory.h1
-rw-r--r--src/plugins/texteditor/texteditor.pro34
-rw-r--r--src/plugins/texteditor/texteditorplugin.cpp4
-rw-r--r--src/plugins/texteditor/texteditorplugin.h1
45 files changed, 218 insertions, 657 deletions
diff --git a/src/libs/utils/uncommentselection.cpp b/src/libs/utils/uncommentselection.cpp
index 7c00ba22e7..761a040ca4 100644
--- a/src/libs/utils/uncommentselection.cpp
+++ b/src/libs/utils/uncommentselection.cpp
@@ -85,6 +85,13 @@ bool CommentDefinition::hasSingleLineStyle() const
bool CommentDefinition::hasMultiLineStyle() const
{ return !m_multiLineStart.isEmpty() && !m_multiLineEnd.isEmpty(); }
+void CommentDefinition::clearCommentStyles()
+{
+ m_singleLine.clear();
+ m_multiLineStart.clear();
+ m_multiLineEnd.clear();
+}
+
namespace {
bool isComment(const QString &text,
diff --git a/src/libs/utils/uncommentselection.h b/src/libs/utils/uncommentselection.h
index a984d512b3..42a7dc1066 100644
--- a/src/libs/utils/uncommentselection.h
+++ b/src/libs/utils/uncommentselection.h
@@ -58,6 +58,8 @@ public:
bool hasSingleLineStyle() const;
bool hasMultiLineStyle() const;
+ void clearCommentStyles();
+
private:
bool m_afterWhiteSpaces;
QString m_singleLine;
diff --git a/src/plugins/genericeditor/GenericEditor.pluginspec b/src/plugins/genericeditor/GenericEditor.pluginspec
deleted file mode 100644
index 015b17b2c5..0000000000
--- a/src/plugins/genericeditor/GenericEditor.pluginspec
+++ /dev/null
@@ -1,20 +0,0 @@
-<plugin name="GenericEditor" version="2.0.80" compatVersion="2.0.80">
- <vendor>Nokia Corporation</vendor>
- <copyright>(C) 2010 Nokia Corporation</copyright>
- <license>
-Commercial Usage
-
-Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
-
-GNU Lesser General Public License Usage
-
-Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. 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.
- </license>
- <category>Qt Creator</category>
- <description>Generic editor with highlighting for a variety of languages.</description>
- <url>http://qt.nokia.com</url>
- <dependencyList>
- <dependency name="Core" version="2.0.80"/>
- <dependency name="TextEditor" version="2.0.80"/>
- </dependencyList>
-</plugin>
diff --git a/src/plugins/genericeditor/editor.cpp b/src/plugins/genericeditor/editor.cpp
deleted file mode 100644
index 11862e524a..0000000000
--- a/src/plugins/genericeditor/editor.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#include "editor.h"
-#include "genericeditorconstants.h"
-#include "genericeditorplugin.h"
-#include "highlightdefinition.h"
-#include "highlighter.h"
-#include "highlighterexception.h"
-
-#include <coreplugin/uniqueidmanager.h>
-#include <coreplugin/icore.h>
-#include <coreplugin/mimedatabase.h>
-#include <texteditor/texteditorconstants.h>
-#include <texteditor/basetextdocument.h>
-#include <texteditor/texteditorsettings.h>
-#include <texteditor/fontsettings.h>
-#include <texteditor/tabsettings.h>
-#include <texteditor/normalindenter.h>
-
-#include <QtCore/QSharedPointer>
-#include <QtCore/QFileInfo>
-
-using namespace GenericEditor;
-using namespace Internal;
-
-Editor::Editor(QWidget *parent) : TextEditor::BaseTextEditor(parent)
-{
- connect(file(), SIGNAL(changed()), this, SLOT(configure()));
-}
-
-Editor::~Editor()
-{}
-
-void Editor::unCommentSelection()
-{
- Utils::unCommentSelection(this, m_commentDefinition);
-}
-
-TextEditor::BaseTextEditorEditable *Editor::createEditableInterface()
-{
- EditorEditable *editable = new EditorEditable(this);
- return editable;
-}
-
-void Editor::setFontSettings(const TextEditor::FontSettings & fs)
-{
- TextEditor::BaseTextEditor::setFontSettings(fs);
-
- Highlighter *highlighter = static_cast<Highlighter *>(baseTextDocument()->syntaxHighlighter());
- if (!highlighter)
- return;
-
- highlighter->configureFormats(fs);
- highlighter->rehighlight();
-}
-
-void Editor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
-{
- m_indenter->indentBlock(doc, block, typedChar, tabSettings());
-}
-
-void Editor::configure()
-{
- const QString &mimeType = Core::ICore::instance()->mimeDatabase()->findByFile(
- QFileInfo(file()->fileName())).type();
- baseTextDocument()->setMimeType(mimeType);
-
- try {
- const QString &definitionId =
- GenericEditorPlugin::instance()->definitionIdByMimeType(mimeType);
- const QSharedPointer<HighlightDefinition> &definition =
- GenericEditorPlugin::instance()->definition(definitionId);
-
- Highlighter *highlighter = new Highlighter(definition->initialContext());
- highlighter->configureFormats(TextEditor::TextEditorSettings::instance()->fontSettings());
-
- baseTextDocument()->setSyntaxHighlighter(highlighter);
-
- m_commentDefinition.setAfterWhiteSpaces(definition->isCommentAfterWhiteSpaces());
- m_commentDefinition.setSingleLine(definition->singleLineComment());
- m_commentDefinition.setMultiLineStart(definition->multiLineCommentStart());
- m_commentDefinition.setMultiLineEnd(definition->multiLineCommentEnd());
-
- // @todo: It's possible to specify an indenter style in the definition file. However, this
- // is not really being used because Kate recommends to configure indentation through
- // another feature. Maybe we should provide something similar in Creator? For now the
- // normal indenter is used.
- m_indenter.reset(new TextEditor::NormalIndenter);
-
- } catch (const HighlighterException &) {
- // No highlighter will be set.
- }
-}
-
-EditorEditable::EditorEditable(Editor *editor) :
- TextEditor::BaseTextEditorEditable(editor)
-{
- Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
- m_context << uidm->uniqueIdentifier(GenericEditor::Constants::GENERIC_EDITOR);
- m_context << uidm->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
-}
-
-QString EditorEditable::id() const
-{ return QLatin1String(GenericEditor::Constants::GENERIC_EDITOR); }
-
-QList<int> EditorEditable::context() const
-{ return m_context; }
-
-bool EditorEditable::isTemporary() const
-{ return false; }
-
-bool EditorEditable::duplicateSupported() const
-{ return true; }
-
-Core::IEditor *EditorEditable::duplicate(QWidget *parent)
-{
- Editor *newEditor = new Editor(parent);
- newEditor->duplicateFrom(editor());
- GenericEditorPlugin::instance()->initializeEditor(newEditor);
- return newEditor->editableInterface();
-}
diff --git a/src/plugins/genericeditor/editor.h b/src/plugins/genericeditor/editor.h
deleted file mode 100644
index b50d4f11a7..0000000000
--- a/src/plugins/genericeditor/editor.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#ifndef GENERICEDITOR_H
-#define GENERICEDITOR_H
-
-#include <texteditor/basetexteditor.h>
-#include <utils/uncommentselection.h>
-
-#include <QtCore/QList>
-#include <QtCore/QScopedPointer>
-#include <QtGui/QTextBlock>
-
-QT_BEGIN_NAMESPACE
-class QString;
-class QTextDocument;
-QT_END_NAMESPACE
-
-namespace TextEditor {
-class Indenter;
-}
-
-namespace GenericEditor {
-namespace Internal {
-
-class Editor : public TextEditor::BaseTextEditor
-{
- Q_OBJECT
-public:
- Editor(QWidget *parent = 0);
- virtual ~Editor();
-
- virtual void unCommentSelection();
-
-protected:
- virtual TextEditor::BaseTextEditorEditable *createEditableInterface();
-
-public slots:
- virtual void setFontSettings(const TextEditor::FontSettings &);
-
-private slots:
- void configure();
-
-private:
- Q_DISABLE_COPY(Editor)
-
- virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
-
- Utils::CommentDefinition m_commentDefinition;
- QScopedPointer<TextEditor::Indenter> m_indenter;
-};
-
-class EditorEditable : public TextEditor::BaseTextEditorEditable
-{
- Q_OBJECT
-public:
- EditorEditable(Editor *editor);
-
-protected:
- virtual QString id() const;
- virtual QList<int> context() const;
- virtual bool isTemporary() const;
- virtual bool duplicateSupported() const;
- virtual Core::IEditor *duplicate(QWidget *parent);
-
-private:
- QList<int> m_context;
-};
-
-
-
-} // namespace Internal
-} // namespace GenericEditor
-
-#endif // GENERICEDITOR_H
diff --git a/src/plugins/genericeditor/editorfactory.cpp b/src/plugins/genericeditor/editorfactory.cpp
deleted file mode 100644
index dcb2285cb5..0000000000
--- a/src/plugins/genericeditor/editorfactory.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#include "editorfactory.h"
-#include "genericeditorconstants.h"
-#include "editor.h"
-#include "genericeditorplugin.h"
-
-#include <coreplugin/editormanager/editormanager.h>
-
-using namespace GenericEditor;
-using namespace Internal;
-
-EditorFactory::EditorFactory(QObject *parent) : Core::IEditorFactory(parent)
-{}
-
-EditorFactory::~EditorFactory()
-{}
-
-Core::IEditor *EditorFactory::createEditor(QWidget *parent)
-{
- Editor *genericEditor = new Editor(parent);
- GenericEditorPlugin::instance()->initializeEditor(genericEditor);
- return genericEditor->editableInterface();
-}
-
-QStringList EditorFactory::mimeTypes() const
-{ return m_mimeTypes; }
-
-QString EditorFactory::id() const
-{
- return QLatin1String(GenericEditor::Constants::GENERIC_EDITOR);
-}
-
-QString EditorFactory::displayName() const
-{
- return tr(GenericEditor::Constants::GENERIC_EDITOR_DISPLAY_NAME);
-}
-
-Core::IFile *EditorFactory::open(const QString &fileName)
-{
- Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id());
- return iface ? iface->file() : 0;
-}
diff --git a/src/plugins/genericeditor/editorfactory.h b/src/plugins/genericeditor/editorfactory.h
deleted file mode 100644
index f4e44db972..0000000000
--- a/src/plugins/genericeditor/editorfactory.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#ifndef GENERICEDITORFACTORY_H
-#define GENERICEDITORFACTORY_H
-
-#include <coreplugin/editormanager/ieditorfactory.h>
-
-#include <QtCore/QStringList>
-
-namespace GenericEditor {
-namespace Internal {
-
-class Editor;
-
-class EditorFactory : public Core::IEditorFactory
-{
- Q_OBJECT
-
- friend class GenericEditorPlugin;
-public:
- EditorFactory(QObject *parent = 0);
- virtual ~EditorFactory();
-
- virtual Core::IEditor *createEditor(QWidget *parent);
- virtual QStringList mimeTypes() const;
- virtual QString id() const;
- virtual QString displayName() const;
- virtual Core::IFile *open(const QString &fileName);
-
-private:
- QStringList m_mimeTypes;
-};
-
-} // namespace Internal
-} // namespace GenericEditor
-
-#endif // GENERICEDITORFACTORY_H
diff --git a/src/plugins/genericeditor/genericeditor.pri b/src/plugins/genericeditor/genericeditor.pri
deleted file mode 100644
index cd4a9337c6..0000000000
--- a/src/plugins/genericeditor/genericeditor.pri
+++ /dev/null
@@ -1,3 +0,0 @@
-include(genericeditor_dependencies.pri)
-
-LIBS *= -l$$qtLibraryTarget(GenericEditor)
diff --git a/src/plugins/genericeditor/genericeditor.pro b/src/plugins/genericeditor/genericeditor.pro
deleted file mode 100644
index 55bda44b08..0000000000
--- a/src/plugins/genericeditor/genericeditor.pro
+++ /dev/null
@@ -1,43 +0,0 @@
-TEMPLATE = lib
-TARGET = GenericEditor
-include(../../qtcreatorplugin.pri)
-include(genericeditor_dependencies.pri)
-
-CONFIG += help
-
-HEADERS += \
- genericeditorplugin.h \
- progressdata.h \
- specificrules.h \
- rule.h \
- reuse.h \
- keywordlist.h \
- itemdata.h \
- includerulesinstruction.h \
- highlighterexception.h \
- highlighter.h \
- highlightdefinitionhandler.h \
- highlightdefinition.h \
- dynamicrule.h \
- context.h \
- genericeditorconstants.h \
- editor.h \
- editorfactory.h
-
-SOURCES += \
- genericeditorplugin.cpp \
- progressdata.cpp \
- specificrules.cpp \
- rule.cpp \
- keywordlist.cpp \
- itemdata.cpp \
- includerulesinstruction.cpp \
- highlighter.cpp \
- highlightdefinitionhandler.cpp \
- highlightdefinition.cpp \
- dynamicrule.cpp \
- context.cpp \
- editor.cpp \
- editorfactory.cpp
-
-OTHER_FILES += GenericEditor.pluginspec
diff --git a/src/plugins/genericeditor/genericeditor_dependencies.pri b/src/plugins/genericeditor/genericeditor_dependencies.pri
deleted file mode 100644
index accac40500..0000000000
--- a/src/plugins/genericeditor/genericeditor_dependencies.pri
+++ /dev/null
@@ -1,3 +0,0 @@
-include(../../plugins/coreplugin/coreplugin.pri)
-include(../../plugins/texteditor/texteditor.pri)
-include(../../libs/utils/utils.pri)
diff --git a/src/plugins/genericeditor/genericeditorconstants.h b/src/plugins/genericeditor/genericeditorconstants.h
deleted file mode 100644
index 2d9ec05766..0000000000
--- a/src/plugins/genericeditor/genericeditorconstants.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**************************************************************************
-**
-** This file is part of Qt Creator
-**
-** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-**
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** Commercial Usage
-**
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
-**
-**************************************************************************/
-
-#ifndef GENERICEDITORCONSTANTS_H
-#define GENERICEDITORCONSTANTS_H
-
-#include <QtCore/QtGlobal>
-
-namespace GenericEditor {
-namespace Constants {
-
-const char * const GENERIC_EDITOR = "GenericEditorPlugin.GenericEditor";
-const char * const GENERIC_EDITOR_DISPLAY_NAME =
- QT_TRANSLATE_NOOP("OpenWith::Editors", "Generic Editor");
-
-} // namespace Constants
-} // namespace GenericEditor
-
-#endif // GENERICEDITORCONSTANTS_H
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 9928857b82..156d5ce9f8 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -33,7 +33,6 @@ SUBDIRS = plugin_coreplugin \
plugin_genericprojectmanager \
plugin_qmljseditor \
plugin_mercurial \
- plugin_genericeditor \
debugger/dumper.pro
contains(QT_CONFIG, declarative) {
@@ -209,7 +208,3 @@ plugin_mercurial.subdir = mercurial
plugin_mercurial.depends = plugin_vcsbase
plugin_mercurial.depends += plugin_projectexplorer
plugin_mercurial.depends += plugin_coreplugin
-
-plugin_genericeditor.subdir = genericeditor
-plugin_genericeditor.depends = plugin_coreplugin
-plugin_genericeditor.depends += plugin_texteditor
diff --git a/src/plugins/genericeditor/context.cpp b/src/plugins/texteditor/generichighlighter/context.cpp
index 75ad3b5040..d9fea72fd5 100644
--- a/src/plugins/genericeditor/context.cpp
+++ b/src/plugins/texteditor/generichighlighter/context.cpp
@@ -33,7 +33,7 @@
#include "dynamicrule.h"
#include "highlightdefinition.h"
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
Context::Context() : m_fallthrough(false), m_dynamic(false)
@@ -128,7 +128,7 @@ bool Context::isDynamic() const
void Context::updateDynamicRules(const QStringList &captures) const
{
- GenericEditor::Internal::updateDynamicRules(m_rules, captures);
+ TextEditor::Internal::updateDynamicRules(m_rules, captures);
}
void Context::addRule(const QSharedPointer<Rule> &rule)
diff --git a/src/plugins/genericeditor/context.h b/src/plugins/texteditor/generichighlighter/context.h
index aa9db961b9..1d800ca2e5 100644
--- a/src/plugins/genericeditor/context.h
+++ b/src/plugins/texteditor/generichighlighter/context.h
@@ -36,7 +36,7 @@
#include <QtCore/QList>
#include <QtCore/QSharedPointer>
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class Rule;
@@ -105,6 +105,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // CONTEXT_H
diff --git a/src/plugins/genericeditor/dynamicrule.cpp b/src/plugins/texteditor/generichighlighter/dynamicrule.cpp
index 1bb0635494..24d7414dd7 100644
--- a/src/plugins/genericeditor/dynamicrule.cpp
+++ b/src/plugins/texteditor/generichighlighter/dynamicrule.cpp
@@ -30,7 +30,7 @@
#include "dynamicrule.h"
#include "reuse.h"
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
DynamicRule::DynamicRule() : m_active(false)
@@ -51,7 +51,7 @@ void DynamicRule::replaceExpressions(const QStringList &captures)
updateDynamicRules(childs(), captures);
}
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
void updateDynamicRules(const QList<QSharedPointer<Rule> > &rules, const QStringList &captures)
@@ -64,4 +64,4 @@ void updateDynamicRules(const QList<QSharedPointer<Rule> > &rules, const QString
}
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
diff --git a/src/plugins/genericeditor/dynamicrule.h b/src/plugins/texteditor/generichighlighter/dynamicrule.h
index 1fdeb1ff0b..1e116d31bd 100644
--- a/src/plugins/genericeditor/dynamicrule.h
+++ b/src/plugins/texteditor/generichighlighter/dynamicrule.h
@@ -36,7 +36,7 @@ QT_BEGIN_NAMESPACE
class QStringList;
QT_END_NAMESPACE
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class DynamicRule : public Rule
@@ -59,6 +59,6 @@ private:
void updateDynamicRules(const QList<QSharedPointer<Rule> > &rules, const QStringList &captures);
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // DYNAMICRULE_H
diff --git a/src/plugins/genericeditor/highlightdefinition.cpp b/src/plugins/texteditor/generichighlighter/highlightdefinition.cpp
index 90481566f6..7c723229d9 100644
--- a/src/plugins/genericeditor/highlightdefinition.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlightdefinition.cpp
@@ -36,7 +36,7 @@
#include <QLatin1String>
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
HighlightDefinition::HighlightDefinition() :
diff --git a/src/plugins/genericeditor/highlightdefinition.h b/src/plugins/texteditor/generichighlighter/highlightdefinition.h
index ea3278dea3..2f48bc24c8 100644
--- a/src/plugins/genericeditor/highlightdefinition.h
+++ b/src/plugins/texteditor/generichighlighter/highlightdefinition.h
@@ -34,7 +34,7 @@
#include <QtCore/QHash>
#include <QtCore/QSharedPointer>
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class KeywordList;
@@ -112,6 +112,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // HIGHLIGHTDEFINITION_H
diff --git a/src/plugins/genericeditor/highlightdefinitionhandler.cpp b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp
index 0b959fa78a..f18d3de8f2 100644
--- a/src/plugins/genericeditor/highlightdefinitionhandler.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.cpp
@@ -34,12 +34,12 @@
#include "keywordlist.h"
#include "context.h"
#include "reuse.h"
-#include "genericeditorplugin.h"
+#include "manager.h"
#include "highlighterexception.h"
#include <QLatin1String>
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
namespace {
@@ -430,14 +430,14 @@ void HighlightDefinitionHandler::processIncludeRules(const QSharedPointer<Contex
// definition they are from.
QString externalName = QString::fromRawData(sourceName.unicode() + 2,
sourceName.length() - 2);
- const QString &id = GenericEditorPlugin::instance()->definitionIdByName(externalName);
+ const QString &id = Manager::instance()->definitionIdByName(externalName);
// If there is an incorrect circular dependency among definitions this is skipped.
- if (GenericEditorPlugin::instance()->isBuildingDefinition(id))
+ if (Manager::instance()->isBuildingDefinition(id))
continue;
const QSharedPointer<HighlightDefinition> &externalDefinition =
- GenericEditorPlugin::instance()->definition(id);
+ Manager::instance()->definition(id);
sourceContext = externalDefinition->initialContext();
} else if (!sourceName.startsWith(kHash)) {
sourceContext = m_definition->context(sourceName);
diff --git a/src/plugins/genericeditor/highlightdefinitionhandler.h b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.h
index 6a460c0f74..e08be97649 100644
--- a/src/plugins/genericeditor/highlightdefinitionhandler.h
+++ b/src/plugins/texteditor/generichighlighter/highlightdefinitionhandler.h
@@ -37,7 +37,7 @@
#include <QtXml/QXmlDefaultHandler>
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class KeywordList;
@@ -101,6 +101,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // HIGHLIGHTDEFINITIONHANDLER_H
diff --git a/src/plugins/genericeditor/highlighter.cpp b/src/plugins/texteditor/generichighlighter/highlighter.cpp
index 71865eadf9..27b0309795 100644
--- a/src/plugins/genericeditor/highlighter.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlighter.cpp
@@ -35,14 +35,13 @@
#include "highlighterexception.h"
#include "progressdata.h"
#include "reuse.h"
-
-#include <texteditor/texteditorconstants.h>
-#include <texteditor/fontsettings.h>
+#include "texteditorconstants.h"
+#include "fontsettings.h"
#include <QtCore/QLatin1String>
#include <QtCore/QLatin1Char>
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
namespace {
@@ -300,8 +299,8 @@ void Highlighter::applyFormat(int offset,
try {
itemData = definition->itemData(itemDataName);
} catch (const HighlighterException &) {
- // There are broken files which Kate can cope with. For instance the Printf context in
- // java.xml points to an inexistent Printf item data. These are taken as normal text.
+ // There are some broken files. For instance, the Printf context in java.xml points to an
+ // inexistent Printf item data. These cases are considered to have normal text style.
return;
}
@@ -431,15 +430,15 @@ void Highlighter::pushDynamicContext(const QSharedPointer<Context> &baseContext)
void Highlighter::setCurrentContext()
{
if (m_contexts.isEmpty()) {
- // This is not supposed to happen. However, there might be broken files (for example, the
- // php.xml) which will cause this behaviour. In such cases just pushing the default
- // context is enough to keep highlighter working.
+ // This is not supposed to happen. However, there are broken files (for example, php.xml)
+ // which will cause this behaviour. In such cases pushing the default context is enough to
+ // keep highlighter working.
m_contexts.push_back(m_defaultContext);
}
m_currentContext = m_contexts.back();
}
-void Highlighter::configureFormats(const TextEditor::FontSettings & fs)
+void Highlighter::configureFormats(const FontSettings & fs)
{
m_visualWhitespaceFormat = fs.toTextCharFormat(
QLatin1String(TextEditor::Constants::C_VISUAL_WHITESPACE));
diff --git a/src/plugins/genericeditor/highlighter.h b/src/plugins/texteditor/generichighlighter/highlighter.h
index e068af9d28..bbf7e76992 100644
--- a/src/plugins/genericeditor/highlighter.h
+++ b/src/plugins/texteditor/generichighlighter/highlighter.h
@@ -30,6 +30,8 @@
#ifndef HIGHLIGHTER_H
#define HIGHLIGHTER_H
+#include "basetextdocumentlayout.h"
+
#include <QtCore/QString>
#include <QtCore/QVector>
#include <QtCore/QSharedPointer>
@@ -37,13 +39,11 @@
#include <QtGui/QSyntaxHighlighter>
-#include <texteditor/basetextdocumentlayout.h>
-
namespace TextEditor {
class FontSettings;
}
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class Rule;
@@ -57,7 +57,7 @@ public:
Highlighter(const QSharedPointer<Context> &defaultContext, QTextDocument *parent = 0);
virtual ~Highlighter();
- void configureFormats(const TextEditor::FontSettings & fs);
+ void configureFormats(const FontSettings & fs);
protected:
virtual void highlightBlock(const QString &text);
@@ -100,7 +100,7 @@ private:
void createWillContinueBlock();
void analyseConsistencyOfWillContinueBlock(const QString &text);
- struct BlockData : TextEditor::TextBlockUserData
+ struct BlockData : TextBlockUserData
{
BlockData();
virtual ~BlockData();
@@ -149,6 +149,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // HIGHLIGHTER_H
diff --git a/src/plugins/genericeditor/highlighterexception.h b/src/plugins/texteditor/generichighlighter/highlighterexception.h
index c25f34795b..13310402fa 100644
--- a/src/plugins/genericeditor/highlighterexception.h
+++ b/src/plugins/texteditor/generichighlighter/highlighterexception.h
@@ -30,12 +30,12 @@
#ifndef HIGHLIGHTEREXCEPTION_H
#define HIGHLIGHTEREXCEPTION_H
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class HighlighterException {};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // HIGHLIGHTEREXCEPTION_H
diff --git a/src/plugins/genericeditor/includerulesinstruction.cpp b/src/plugins/texteditor/generichighlighter/includerulesinstruction.cpp
index 85c99e0262..8b04826633 100644
--- a/src/plugins/genericeditor/includerulesinstruction.cpp
+++ b/src/plugins/texteditor/generichighlighter/includerulesinstruction.cpp
@@ -30,7 +30,7 @@
#include "includerulesinstruction.h"
#include "reuse.h"
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
IncludeRulesInstruction::IncludeRulesInstruction(const QString &context,
diff --git a/src/plugins/genericeditor/includerulesinstruction.h b/src/plugins/texteditor/generichighlighter/includerulesinstruction.h
index 66823d737f..c0f5d6e498 100644
--- a/src/plugins/genericeditor/includerulesinstruction.h
+++ b/src/plugins/texteditor/generichighlighter/includerulesinstruction.h
@@ -32,7 +32,7 @@
#include <QtCore/QString>
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class IncludeRulesInstruction
@@ -51,6 +51,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // INCLUDERULESINSTRUCTION_H
diff --git a/src/plugins/genericeditor/itemdata.cpp b/src/plugins/texteditor/generichighlighter/itemdata.cpp
index 2511734eb7..498d968e32 100644
--- a/src/plugins/genericeditor/itemdata.cpp
+++ b/src/plugins/texteditor/generichighlighter/itemdata.cpp
@@ -30,7 +30,7 @@
#include "itemdata.h"
#include "reuse.h"
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
const QLatin1String ItemData::kDsNormal("dsNormal");
diff --git a/src/plugins/genericeditor/itemdata.h b/src/plugins/texteditor/generichighlighter/itemdata.h
index ee4c2c3246..c130239749 100644
--- a/src/plugins/genericeditor/itemdata.h
+++ b/src/plugins/texteditor/generichighlighter/itemdata.h
@@ -33,7 +33,7 @@
#include <QtCore/QString>
#include <QtGui/QColor>
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class ItemData
@@ -99,6 +99,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // ITEMDATA_H
diff --git a/src/plugins/genericeditor/keywordlist.cpp b/src/plugins/texteditor/generichighlighter/keywordlist.cpp
index 70ef6ac614..48c9672915 100644
--- a/src/plugins/genericeditor/keywordlist.cpp
+++ b/src/plugins/texteditor/generichighlighter/keywordlist.cpp
@@ -29,7 +29,7 @@
#include "keywordlist.h"
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
void KeywordList::addKeyword(const QString &keyword)
diff --git a/src/plugins/genericeditor/keywordlist.h b/src/plugins/texteditor/generichighlighter/keywordlist.h
index c76a7311be..82495ca220 100644
--- a/src/plugins/genericeditor/keywordlist.h
+++ b/src/plugins/texteditor/generichighlighter/keywordlist.h
@@ -33,7 +33,7 @@
#include <QtCore/QString>
#include <QtCore/QSet>
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class KeywordList
@@ -48,6 +48,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // KEYWORDLIST_H
diff --git a/src/plugins/genericeditor/genericeditorplugin.cpp b/src/plugins/texteditor/generichighlighter/manager.cpp
index 73578134cf..6080c4f764 100644
--- a/src/plugins/genericeditor/genericeditorplugin.cpp
+++ b/src/plugins/texteditor/generichighlighter/manager.cpp
@@ -27,16 +27,15 @@
**
**************************************************************************/
-#include "genericeditorplugin.h"
+#include "manager.h"
#include "highlightdefinition.h"
#include "highlightdefinitionhandler.h"
#include "highlighterexception.h"
-#include "genericeditorconstants.h"
-#include "editor.h"
-#include "editorfactory.h"
+#include "texteditorplugin.h"
+#include "texteditorsettings.h"
+#include "plaintexteditorfactory.h"
#include <coreplugin/icore.h>
-#include <texteditor/texteditorsettings.h>
#include <utils/qtcassert.h>
#include <qtconcurrent/QtConcurrentTools>
@@ -58,64 +57,26 @@
#include <QtXml/QXmlStreamReader>
#include <QtXml/QXmlStreamAttributes>
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
-GenericEditorPlugin *GenericEditorPlugin::m_instance = 0;
-
-GenericEditorPlugin::GenericEditorPlugin() :
- m_actionHandler(0)
-{
- QTC_ASSERT(!m_instance, return);
- m_instance = this;
-
- connect(Core::ICore::instance(), SIGNAL(coreOpened()), this, SLOT(registerMimeTypes()));
-}
-
-GenericEditorPlugin::~GenericEditorPlugin()
-{
- delete m_actionHandler;
- m_instance = 0;
-}
-
-GenericEditorPlugin *GenericEditorPlugin::instance()
-{ return m_instance; }
-
-bool GenericEditorPlugin::initialize(const QStringList &arguments, QString *errorString)
-{
- Q_UNUSED(arguments)
- Q_UNUSED(errorString)
-
- m_factory = new EditorFactory(this);
- addAutoReleasedObject(m_factory);
-
- m_actionHandler = new TextEditor::TextEditorActionHandler(
- GenericEditor::Constants::GENERIC_EDITOR,
- TextEditor::TextEditorActionHandler::Format |
- TextEditor::TextEditorActionHandler::UnCommentSelection);
- m_actionHandler->initializeActions();
-
- return true;
-}
-
-void GenericEditorPlugin::extensionsInitialized()
+Manager::Manager()
{}
-void GenericEditorPlugin::initializeEditor(Editor *editor)
+Manager *Manager::instance()
{
- m_actionHandler->setupActions(editor);
-
- TextEditor::TextEditorSettings::instance()->initializeEditor(editor);
+ static Manager manager;
+ return &manager;
}
-QString GenericEditorPlugin::definitionIdByName(const QString &name) const
+QString Manager::definitionIdByName(const QString &name) const
{ return m_idByName.value(name); }
-QString GenericEditorPlugin::definitionIdByMimeType(const QString &mimeType) const
+QString Manager::definitionIdByMimeType(const QString &mimeType) const
{
- Q_ASSERT(!mimeType.isEmpty() && m_idByMimeType.count(mimeType) > 0);
+ Q_ASSERT(!mimeType.isEmpty());
- if (m_idByMimeType.count(mimeType) == 1) {
+ if (m_idByMimeType.count(mimeType) <= 1) {
return m_idByMimeType.value(mimeType);
} else {
QStringList candidateIds;
@@ -129,7 +90,7 @@ QString GenericEditorPlugin::definitionIdByMimeType(const QString &mimeType) con
}
}
-const QSharedPointer<HighlightDefinition> &GenericEditorPlugin::definition(const QString &id)
+const QSharedPointer<HighlightDefinition> &Manager::definition(const QString &id)
{
if (!m_definitions.contains(id)) {
m_isBuilding.insert(id);
@@ -154,19 +115,19 @@ const QSharedPointer<HighlightDefinition> &GenericEditorPlugin::definition(const
return *m_definitions.constFind(id);
}
-bool GenericEditorPlugin::isBuildingDefinition(const QString &id) const
+bool Manager::isBuildingDefinition(const QString &id) const
{ return m_isBuilding.contains(id); }
-void GenericEditorPlugin::registerMimeTypes()
+void Manager::registerMimeTypes()
{
QFuture<Core::MimeType> future =
- QtConcurrent::run(&GenericEditorPlugin::gatherDefinitionsMimeTypes, this);
+ QtConcurrent::run(&Manager::gatherDefinitionsMimeTypes, this);
m_watcher.setFuture(future);
connect(&m_watcher, SIGNAL(resultReadyAt(int)), this, SLOT(registerMimeType(int)));
}
-void GenericEditorPlugin::gatherDefinitionsMimeTypes(QFutureInterface<Core::MimeType> &future)
+void Manager::gatherDefinitionsMimeTypes(QFutureInterface<Core::MimeType> &future)
{
QDir definitionsDir(Core::ICore::instance()->resourcePath() +
QLatin1String("/generic-highlighter"));
@@ -208,14 +169,14 @@ void GenericEditorPlugin::gatherDefinitionsMimeTypes(QFutureInterface<Core::Mime
}
}
-void GenericEditorPlugin::registerMimeType(int index) const
+void Manager::registerMimeType(int index) const
{
const Core::MimeType &mimeType = m_watcher.resultAt(index);
Core::ICore::instance()->mimeDatabase()->addMimeType(mimeType);
- m_factory->m_mimeTypes.append(mimeType.type());
+ TextEditorPlugin::instance()->editorFactory()->addMimeType(mimeType.type());
}
-void GenericEditorPlugin::parseDefinitionMetadata(const QFileInfo &fileInfo,
+void Manager::parseDefinitionMetadata(const QFileInfo &fileInfo,
QString *comment,
QStringList *mimeTypes,
QStringList *patterns)
@@ -273,5 +234,3 @@ void GenericEditorPlugin::parseDefinitionMetadata(const QFileInfo &fileInfo,
reader.clear();
definitionFile.close();
}
-
-Q_EXPORT_PLUGIN(GenericEditorPlugin)
diff --git a/src/plugins/genericeditor/genericeditorplugin.h b/src/plugins/texteditor/generichighlighter/manager.h
index 43a6742ef9..f5663dc411 100644
--- a/src/plugins/genericeditor/genericeditorplugin.h
+++ b/src/plugins/texteditor/generichighlighter/manager.h
@@ -27,15 +27,12 @@
**
**************************************************************************/
-#ifndef GENERICEDITORPLUGIN_H
-#define GENERICEDITORPLUGIN_H
+#ifndef MANAGER_H
+#define MANAGER_H
#include <coreplugin/mimedatabase.h>
-#include <extensionsystem/iplugin.h>
-#include <texteditor/texteditoractionhandler.h>
#include <QtCore/QString>
-#include <QtCore/QStringList>
#include <QtCore/QHash>
#include <QtCore/QMultiHash>
#include <QtCore/QSet>
@@ -48,27 +45,16 @@ class QStringList;
template <class> class QFutureInterface;
QT_END_NAMESPACE
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class HighlightDefinition;
-class Editor;
-class EditorFactory;
-class GenericEditorPlugin : public ExtensionSystem::IPlugin
+class Manager : public QObject
{
Q_OBJECT
-
-public:
- GenericEditorPlugin();
- virtual ~GenericEditorPlugin();
-
- static GenericEditorPlugin *instance();
-
- virtual bool initialize(const QStringList &arguments, QString *errorString);
- virtual void extensionsInitialized();
-
- void initializeEditor(Editor *editor);
+public:
+ static Manager *instance();
QString definitionIdByName(const QString &name) const;
QString definitionIdByMimeType(const QString &mimeType) const;
@@ -80,9 +66,8 @@ private slots:
void registerMimeType(int index) const;
private:
- Q_DISABLE_COPY(GenericEditorPlugin)
-
- static GenericEditorPlugin *m_instance;
+ Manager();
+ Q_DISABLE_COPY(Manager)
void gatherDefinitionsMimeTypes(QFutureInterface<Core::MimeType> &future);
void parseDefinitionMetadata(const QFileInfo &fileInfo,
@@ -99,10 +84,6 @@ private:
};
PriorityCompare m_priorityComp;
- TextEditor::TextEditorActionHandler *m_actionHandler;
-
- EditorFactory *m_factory;
-
QFutureWatcher<Core::MimeType> m_watcher;
QHash<QString, QString> m_idByName;
@@ -112,6 +93,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
-#endif // GENERICEDITORPLUGIN_H
+#endif // MANAGER_H
diff --git a/src/plugins/genericeditor/progressdata.cpp b/src/plugins/texteditor/generichighlighter/progressdata.cpp
index f751454bfb..12c76079d8 100644
--- a/src/plugins/genericeditor/progressdata.cpp
+++ b/src/plugins/texteditor/generichighlighter/progressdata.cpp
@@ -31,7 +31,7 @@
#include <QtCore/QtGlobal>
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
ProgressData::ProgressData() :
diff --git a/src/plugins/genericeditor/progressdata.h b/src/plugins/texteditor/generichighlighter/progressdata.h
index 6d3d35e95b..a621c15dc7 100644
--- a/src/plugins/genericeditor/progressdata.h
+++ b/src/plugins/texteditor/generichighlighter/progressdata.h
@@ -32,7 +32,7 @@
#include <QtCore/QStringList>
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class ProgressData
@@ -67,6 +67,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // PROGRESSDATA_H
diff --git a/src/plugins/genericeditor/reuse.h b/src/plugins/texteditor/generichighlighter/reuse.h
index 019f0e0e44..197e3042d9 100644
--- a/src/plugins/genericeditor/reuse.h
+++ b/src/plugins/texteditor/generichighlighter/reuse.h
@@ -36,7 +36,7 @@
#include <QtCore/QChar>
#include <QtGui/QFont>
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
inline bool toBool(const QString &s)
@@ -95,6 +95,6 @@ inline void setStartCharacter(QChar &c, const QString &character)
}
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // REUSE_H
diff --git a/src/plugins/genericeditor/rule.cpp b/src/plugins/texteditor/generichighlighter/rule.cpp
index 7c09818571..1ca7349c6a 100644
--- a/src/plugins/genericeditor/rule.cpp
+++ b/src/plugins/texteditor/generichighlighter/rule.cpp
@@ -37,7 +37,7 @@
#include <functional>
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
const QLatin1Char Rule::kBackSlash('\\');
diff --git a/src/plugins/genericeditor/rule.h b/src/plugins/texteditor/generichighlighter/rule.h
index c27d5b0902..a53b2f8e5c 100644
--- a/src/plugins/genericeditor/rule.h
+++ b/src/plugins/texteditor/generichighlighter/rule.h
@@ -34,7 +34,7 @@
#include <QtCore/QList>
#include <QtCore/QSharedPointer>
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class ProgressData;
@@ -155,6 +155,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // RULE_H
diff --git a/src/plugins/genericeditor/specificrules.cpp b/src/plugins/texteditor/generichighlighter/specificrules.cpp
index 41def9aa25..6fe4269367 100644
--- a/src/plugins/genericeditor/specificrules.cpp
+++ b/src/plugins/texteditor/generichighlighter/specificrules.cpp
@@ -35,7 +35,7 @@
#include <QLatin1Char>
-using namespace GenericEditor;
+using namespace TextEditor;
using namespace Internal;
namespace {
diff --git a/src/plugins/genericeditor/specificrules.h b/src/plugins/texteditor/generichighlighter/specificrules.h
index 108f88a407..7ec2552dad 100644
--- a/src/plugins/genericeditor/specificrules.h
+++ b/src/plugins/texteditor/generichighlighter/specificrules.h
@@ -38,7 +38,7 @@
#include <QtCore/QRegExp>
#include <QtCore/QSharedPointer>
-namespace GenericEditor {
+namespace TextEditor {
namespace Internal {
class KeywordList;
@@ -283,6 +283,6 @@ private:
};
} // namespace Internal
-} // namespace GenericEditor
+} // namespace TextEditor
#endif // SPECIFICRULES_H
diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp
index 257280b0b3..2c748b0738 100644
--- a/src/plugins/texteditor/plaintexteditor.cpp
+++ b/src/plugins/texteditor/plaintexteditor.cpp
@@ -31,9 +31,20 @@
#include "tabsettings.h"
#include "texteditorconstants.h"
#include "texteditorplugin.h"
+#include "texteditorsettings.h"
+#include "basetextdocument.h"
+#include "highlightdefinition.h"
+#include "highlighter.h"
+#include "highlighterexception.h"
+#include "manager.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/uniqueidmanager.h>
+#include <coreplugin/icore.h>
+#include <coreplugin/mimedatabase.h>
+
+#include <QtCore/QSharedPointer>
+#include <QtCore/QFileInfo>
using namespace TextEditor;
using namespace TextEditor::Internal;
@@ -54,8 +65,11 @@ PlainTextEditor::PlainTextEditor(QWidget *parent)
setRequestMarkEnabled(false);
setLineSeparatorsAllowed(true);
- setMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
setDisplayName(tr(Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
+
+ m_commentDefinition.clearCommentStyles();
+
+ connect(file(), SIGNAL(changed()), this, SLOT(configure()));
}
QList<int> PlainTextEditorEditable::context() const
@@ -76,7 +90,56 @@ QString PlainTextEditorEditable::id() const
return QLatin1String(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
}
+void PlainTextEditor::unCommentSelection()
+{
+ Utils::unCommentSelection(this, m_commentDefinition);
+}
+
+void PlainTextEditor::setFontSettings(const TextEditor::FontSettings & fs)
+{
+ TextEditor::BaseTextEditor::setFontSettings(fs);
+
+ Highlighter *highlighter = static_cast<Highlighter *>(baseTextDocument()->syntaxHighlighter());
+ if (!highlighter)
+ return;
+
+ highlighter->configureFormats(fs);
+ highlighter->rehighlight();
+}
+
+void PlainTextEditor::configure()
+{
+ const QString &mimeType = Core::ICore::instance()->mimeDatabase()->findByFile(
+ QFileInfo(file()->fileName())).type();
+ baseTextDocument()->setMimeType(mimeType);
+
+ const QString &definitionId = Manager::instance()->definitionIdByMimeType(mimeType);
+ if (!definitionId.isEmpty()) {
+ try {
+ const QSharedPointer<HighlightDefinition> &definition =
+ Manager::instance()->definition(definitionId);
+
+ Highlighter *highlighter = new Highlighter(definition->initialContext());
+ highlighter->configureFormats(TextEditor::TextEditorSettings::instance()->fontSettings());
+
+ baseTextDocument()->setSyntaxHighlighter(highlighter);
+
+ m_commentDefinition.setAfterWhiteSpaces(definition->isCommentAfterWhiteSpaces());
+ m_commentDefinition.setSingleLine(definition->singleLineComment());
+ m_commentDefinition.setMultiLineStart(definition->multiLineCommentStart());
+ m_commentDefinition.setMultiLineEnd(definition->multiLineCommentEnd());
+ } catch (const HighlighterException &) {
+ }
+ }
+
+ // @todo: Indentation specification through the definition files is not really being
+ // used because Kate recommends to configure indentation through another feature.
+ // Maybe we should provide something similar in Creator? For now, only normal
+ // indentation is supported.
+ m_indenter.reset(new TextEditor::NormalIndenter);
+}
+
void PlainTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar)
{
- m_indenter.indentBlock(doc, block, typedChar, tabSettings());
+ m_indenter->indentBlock(doc, block, typedChar, tabSettings());
}
diff --git a/src/plugins/texteditor/plaintexteditor.h b/src/plugins/texteditor/plaintexteditor.h
index f2c5673fb0..fdc85423d2 100644
--- a/src/plugins/texteditor/plaintexteditor.h
+++ b/src/plugins/texteditor/plaintexteditor.h
@@ -33,7 +33,10 @@
#include "basetexteditor.h"
#include "normalindenter.h"
+#include <utils/uncommentselection.h>
+
#include <QtCore/QList>
+#include <QtCore/QScopedPointer>
namespace TextEditor {
@@ -61,13 +64,20 @@ class TEXTEDITOR_EXPORT PlainTextEditor : public BaseTextEditor
public:
PlainTextEditor(QWidget *parent);
+public slots:
+ virtual void unCommentSelection();
+ virtual void setFontSettings(const TextEditor::FontSettings &);
+
+private slots:
+ void configure();
+
protected:
virtual BaseTextEditorEditable *createEditableInterface() { return new PlainTextEditorEditable(this); }
virtual void indentBlock(QTextDocument *doc, QTextBlock block, QChar typedChar);
private:
- // Indent a text block based on previous line.
- NormalIndenter m_indenter;
+ Utils::CommentDefinition m_commentDefinition;
+ QScopedPointer<TextEditor::Indenter> m_indenter;
};
} // namespace TextEditor
diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp
index 3a960bc180..7a21997395 100644
--- a/src/plugins/texteditor/plaintexteditorfactory.cpp
+++ b/src/plugins/texteditor/plaintexteditorfactory.cpp
@@ -44,7 +44,8 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent)
{
m_actionHandler = new TextEditorActionHandler(
QLatin1String(TextEditor::Constants::C_TEXTEDITOR),
- TextEditorActionHandler::Format);
+ TextEditorActionHandler::Format |
+ TextEditorActionHandler::UnCommentSelection);
m_mimeTypes << QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT);
}
@@ -76,6 +77,11 @@ Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent)
return rc->editableInterface();
}
+void PlainTextEditorFactory::addMimeType(const QString &type)
+{
+ m_mimeTypes.append(type);
+}
+
QStringList PlainTextEditorFactory::mimeTypes() const
{
return m_mimeTypes;
diff --git a/src/plugins/texteditor/plaintexteditorfactory.h b/src/plugins/texteditor/plaintexteditorfactory.h
index d55f4808af..a01a80f7f1 100644
--- a/src/plugins/texteditor/plaintexteditorfactory.h
+++ b/src/plugins/texteditor/plaintexteditorfactory.h
@@ -50,6 +50,7 @@ public:
PlainTextEditorFactory(QObject *parent = 0);
virtual ~PlainTextEditorFactory();
+ void addMimeType(const QString &type);
virtual QStringList mimeTypes() const;
//Core::IEditorFactory
QString id() const;
diff --git a/src/plugins/texteditor/texteditor.pro b/src/plugins/texteditor/texteditor.pro
index bf64eb51c1..4892ff2992 100644
--- a/src/plugins/texteditor/texteditor.pro
+++ b/src/plugins/texteditor/texteditor.pro
@@ -1,8 +1,11 @@
TEMPLATE = lib
TARGET = TextEditor
DEFINES += TEXTEDITOR_LIBRARY
+QT += xml
include(../../qtcreatorplugin.pri)
include(texteditor_dependencies.pri)
+INCLUDEPATH += generichighlighter
+DEPENDPATH += generichighlighter
SOURCES += texteditorplugin.cpp \
textfilewizard.cpp \
plaintexteditor.cpp \
@@ -37,7 +40,19 @@ SOURCES += texteditorplugin.cpp \
basetextdocumentlayout.cpp \
completionsettings.cpp \
normalindenter.cpp \
- indenter.cpp
+ indenter.cpp \
+ generichighlighter/itemdata.cpp \
+ generichighlighter/specificrules.cpp \
+ generichighlighter/rule.cpp \
+ generichighlighter/dynamicrule.cpp \
+ generichighlighter/context.cpp \
+ generichighlighter/includerulesinstruction.cpp \
+ generichighlighter/progressdata.cpp \
+ generichighlighter/keywordlist.cpp \
+ generichighlighter/highlightdefinition.cpp \
+ generichighlighter/highlighter.cpp \
+ generichighlighter/manager.cpp \
+ generichighlighter/highlightdefinitionhandler.cpp
HEADERS += texteditorplugin.h \
textfilewizard.h \
@@ -77,7 +92,22 @@ HEADERS += texteditorplugin.h \
basetextdocumentlayout.h \
completionsettings.h \
normalindenter.h \
- indenter.h
+ indenter.h \
+ generichighlighter/reuse.h \
+ generichighlighter/itemdata.h \
+ generichighlighter/specificrules.h \
+ generichighlighter/rule.h \
+ generichighlighter/reuse.h \
+ generichighlighter/dynamicrule.h \
+ generichighlighter/context.h \
+ generichighlighter/includerulesinstruction.h \
+ generichighlighter/progressdata.h \
+ generichighlighter/keywordlist.h \
+ generichighlighter/highlighterexception.h \
+ generichighlighter/highlightdefinition.h \
+ generichighlighter/highlighter.h \
+ generichighlighter/manager.h \
+ generichighlighter/highlightdefinitionhandler.h
FORMS += behaviorsettingspage.ui \
diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp
index dca81bed5a..058fcd6350 100644
--- a/src/plugins/texteditor/texteditorplugin.cpp
+++ b/src/plugins/texteditor/texteditorplugin.cpp
@@ -39,6 +39,7 @@
#include "plaintexteditorfactory.h"
#include "plaintexteditor.h"
#include "storagesettings.h"
+#include "manager.h"
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
@@ -70,6 +71,9 @@ TextEditorPlugin::TextEditorPlugin()
{
QTC_ASSERT(!m_instance, return);
m_instance = this;
+
+ connect(Core::ICore::instance(), SIGNAL(coreOpened()),
+ Manager::instance(), SLOT(registerMimeTypes()));
}
TextEditorPlugin::~TextEditorPlugin()
diff --git a/src/plugins/texteditor/texteditorplugin.h b/src/plugins/texteditor/texteditorplugin.h
index 1fc4c10be7..93f8870e1f 100644
--- a/src/plugins/texteditor/texteditorplugin.h
+++ b/src/plugins/texteditor/texteditorplugin.h
@@ -64,6 +64,7 @@ public:
void initializeEditor(PlainTextEditor *editor);
+ PlainTextEditorFactory *editorFactory() { return m_editorFactory; }
LineNumberFilter *lineNumberFilter() { return m_lineNumberFilter; }
private slots: