forked from qt-creator/qt-creator
GlslEditor: General editor related code consolidation
Merge editor files, convert to new editor setup scheme, fix names according to convention. Change-Id: I13682c0c86ac22e4cba3a826505248c7a0291a55 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -28,7 +28,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "glsleditor.h"
|
#include "glsleditor.h"
|
||||||
#include "glsleditoreditable.h"
|
|
||||||
#include "glsleditorconstants.h"
|
#include "glsleditorconstants.h"
|
||||||
#include "glsleditorplugin.h"
|
#include "glsleditorplugin.h"
|
||||||
#include "glslhighlighter.h"
|
#include "glslhighlighter.h"
|
||||||
@@ -44,20 +43,29 @@
|
|||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/id.h>
|
|
||||||
#include <coreplugin/actionmanager/command.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/id.h>
|
||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <texteditor/basetextdocument.h>
|
#include <extensionsystem/pluginspec.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
|
||||||
#include <texteditor/syntaxhighlighter.h>
|
|
||||||
#include <texteditor/refactoroverlay.h>
|
#include <texteditor/refactoroverlay.h>
|
||||||
|
#include <texteditor/syntaxhighlighter.h>
|
||||||
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
|
||||||
#include <qmldesigner/qmldesignerconstants.h>
|
#include <qmldesigner/qmldesignerconstants.h>
|
||||||
|
|
||||||
#include <utils/changeset.h>
|
#include <utils/changeset.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/uncommentselection.h>
|
#include <utils/uncommentselection.h>
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QSettings>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
@@ -65,16 +73,17 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
|
using namespace TextEditor;
|
||||||
using namespace GLSL;
|
using namespace GLSL;
|
||||||
using namespace GLSLEditor;
|
using namespace GLSLEditor::Constants;
|
||||||
using namespace GLSLEditor::Internal;
|
|
||||||
|
namespace GLSLEditor {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
UPDATE_DOCUMENT_DEFAULT_INTERVAL = 150
|
UPDATE_DOCUMENT_DEFAULT_INTERVAL = 150
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
class CreateRanges: protected GLSL::Visitor
|
class CreateRanges: protected GLSL::Visitor
|
||||||
{
|
{
|
||||||
QTextDocument *textDocument;
|
QTextDocument *textDocument;
|
||||||
@@ -100,14 +109,11 @@ protected:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of anonymous namespace
|
|
||||||
|
|
||||||
Document::Document()
|
Document::Document()
|
||||||
: _engine(0)
|
: _engine(0)
|
||||||
, _ast(0)
|
, _ast(0)
|
||||||
, _globalScope(0)
|
, _globalScope(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Document::~Document()
|
Document::~Document()
|
||||||
@@ -133,24 +139,21 @@ void Document::addRange(const QTextCursor &cursor, GLSL::Scope *scope)
|
|||||||
_cursors.append(c);
|
_cursors.append(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlslEditorWidget::GlslEditorWidget(const TextEditor::BaseTextDocumentPtr &doc)
|
GlslEditorWidget::GlslEditorWidget()
|
||||||
{
|
{
|
||||||
setTextDocument(doc);
|
|
||||||
setAutoCompleter(new GLSLCompleter);
|
setAutoCompleter(new GLSLCompleter);
|
||||||
|
|
||||||
m_outlineCombo = 0;
|
m_outlineCombo = 0;
|
||||||
setParenthesesMatchingEnabled(true);
|
setParenthesesMatchingEnabled(true);
|
||||||
setMarksVisible(true);
|
setMarksVisible(true);
|
||||||
setCodeFoldingSupported(true);
|
setCodeFoldingSupported(true);
|
||||||
|
|
||||||
m_updateDocumentTimer = new QTimer(this);
|
m_updateDocumentTimer.setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
|
||||||
m_updateDocumentTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
|
m_updateDocumentTimer.setSingleShot(true);
|
||||||
m_updateDocumentTimer->setSingleShot(true);
|
connect(&m_updateDocumentTimer, &QTimer::timeout,
|
||||||
connect(m_updateDocumentTimer, SIGNAL(timeout()), this, SLOT(updateDocumentNow()));
|
this, &GlslEditorWidget::updateDocumentNow);
|
||||||
|
|
||||||
connect(this, SIGNAL(textChanged()), this, SLOT(updateDocument()));
|
connect(this, &QPlainTextEdit::textChanged,
|
||||||
|
[this]() { m_updateDocumentTimer.start(); });
|
||||||
new Highlighter(textDocument());
|
|
||||||
|
|
||||||
m_outlineCombo = new QComboBox;
|
m_outlineCombo = new QComboBox;
|
||||||
m_outlineCombo->setMinimumContentsLength(22);
|
m_outlineCombo->setMinimumContentsLength(22);
|
||||||
@@ -171,7 +174,7 @@ GlslEditorWidget::GlslEditorWidget(const TextEditor::BaseTextDocumentPtr &doc)
|
|||||||
policy.setHorizontalPolicy(QSizePolicy::Expanding);
|
policy.setHorizontalPolicy(QSizePolicy::Expanding);
|
||||||
m_outlineCombo->setSizePolicy(policy);
|
m_outlineCombo->setSizePolicy(policy);
|
||||||
|
|
||||||
insertExtraToolBarWidget(TextEditor::BaseTextEditorWidget::Left, m_outlineCombo);
|
insertExtraToolBarWidget(BaseTextEditorWidget::Left, m_outlineCombo);
|
||||||
|
|
||||||
// if (m_modelManager) {
|
// if (m_modelManager) {
|
||||||
// m_semanticHighlighter->setModelManager(m_modelManager);
|
// m_semanticHighlighter->setModelManager(m_modelManager);
|
||||||
@@ -197,16 +200,10 @@ bool GlslEditorWidget::isOutdated() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IEditor *GlslEditor::duplicate()
|
|
||||||
{
|
|
||||||
GlslEditorWidget *newEditor = new GlslEditorWidget(editorWidget()->textDocumentPtr());
|
|
||||||
return newEditor->editor();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GlslEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
bool GlslEditor::open(QString *errorString, const QString &fileName, const QString &realFileName)
|
||||||
{
|
{
|
||||||
textDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
|
textDocument()->setMimeType(Core::MimeDatabase::findByFile(QFileInfo(fileName)).type());
|
||||||
bool b = TextEditor::BaseTextEditor::open(errorString, fileName, realFileName);
|
bool b = BaseTextEditor::open(errorString, fileName, realFileName);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,26 +220,21 @@ QString GlslEditorWidget::wordUnderCursor() const
|
|||||||
return word;
|
return word;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditor::BaseTextEditor *GlslEditorWidget::createEditor()
|
BaseTextEditor *GlslEditorWidget::createEditor()
|
||||||
{
|
{
|
||||||
return new GlslEditor;
|
QTC_ASSERT("should not happen anymore" && false, return 0);
|
||||||
}
|
|
||||||
|
|
||||||
void GlslEditorWidget::updateDocument()
|
|
||||||
{
|
|
||||||
m_updateDocumentTimer->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlslEditorWidget::updateDocumentNow()
|
void GlslEditorWidget::updateDocumentNow()
|
||||||
{
|
{
|
||||||
m_updateDocumentTimer->stop();
|
m_updateDocumentTimer.stop();
|
||||||
|
|
||||||
int variant = languageVariant(textDocument()->mimeType());
|
int variant = languageVariant(textDocument()->mimeType());
|
||||||
const QString contents = toPlainText(); // get the code from the editor
|
const QString contents = toPlainText(); // get the code from the editor
|
||||||
const QByteArray preprocessedCode = contents.toLatin1(); // ### use the QtCreator C++ preprocessor.
|
const QByteArray preprocessedCode = contents.toLatin1(); // ### use the QtCreator C++ preprocessor.
|
||||||
|
|
||||||
Document::Ptr doc(new Document());
|
Document::Ptr doc(new Document());
|
||||||
GLSL::Engine *engine = new GLSL::Engine();
|
Engine *engine = new GLSL::Engine();
|
||||||
doc->_engine = new GLSL::Engine();
|
doc->_engine = new GLSL::Engine();
|
||||||
Parser parser(doc->_engine, preprocessedCode.constData(), preprocessedCode.size(), variant);
|
Parser parser(doc->_engine, preprocessedCode.constData(), preprocessedCode.size(), variant);
|
||||||
TranslationUnitAST *ast = parser.parse();
|
TranslationUnitAST *ast = parser.parse();
|
||||||
@@ -336,11 +328,10 @@ int GlslEditorWidget::languageVariant(const QString &type)
|
|||||||
return variant;
|
return variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditor::IAssistInterface *GlslEditorWidget::createAssistInterface(
|
IAssistInterface *GlslEditorWidget::createAssistInterface(
|
||||||
TextEditor::AssistKind kind,
|
AssistKind kind, AssistReason reason) const
|
||||||
TextEditor::AssistReason reason) const
|
|
||||||
{
|
{
|
||||||
if (kind == TextEditor::Completion)
|
if (kind == Completion)
|
||||||
return new GLSLCompletionAssistInterface(document(),
|
return new GLSLCompletionAssistInterface(document(),
|
||||||
position(),
|
position(),
|
||||||
editor()->document()->filePath(),
|
editor()->document()->filePath(),
|
||||||
@@ -349,3 +340,59 @@ TextEditor::IAssistInterface *GlslEditorWidget::createAssistInterface(
|
|||||||
m_glslDocument);
|
m_glslDocument);
|
||||||
return BaseTextEditorWidget::createAssistInterface(kind, reason);
|
return BaseTextEditorWidget::createAssistInterface(kind, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// GlslEditor
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
GlslEditor::GlslEditor()
|
||||||
|
{
|
||||||
|
addContext(C_GLSLEDITOR_ID);
|
||||||
|
setDuplicateSupported(true);
|
||||||
|
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
||||||
|
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<GLSLCompletionAssistProvider>());
|
||||||
|
|
||||||
|
setEditorCreator([]() { return new GlslEditor; });
|
||||||
|
setWidgetCreator([]() { return new GlslEditorWidget; });
|
||||||
|
|
||||||
|
setDocumentCreator([]() -> BaseTextDocument * {
|
||||||
|
auto doc = new BaseTextDocument(C_GLSLEDITOR_ID);
|
||||||
|
doc->setIndenter(new GLSLIndenter);
|
||||||
|
new Highlighter(doc);
|
||||||
|
return doc;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// GlslEditorFactory
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
GlslEditorFactory::GlslEditorFactory()
|
||||||
|
{
|
||||||
|
setId(C_GLSLEDITOR_ID);
|
||||||
|
setDisplayName(qApp->translate("OpenWith::Editors", C_GLSLEDITOR_DISPLAY_NAME));
|
||||||
|
addMimeType(GLSL_MIMETYPE);
|
||||||
|
addMimeType(GLSL_MIMETYPE_VERT);
|
||||||
|
addMimeType(GLSL_MIMETYPE_FRAG);
|
||||||
|
addMimeType(GLSL_MIMETYPE_VERT_ES);
|
||||||
|
addMimeType(GLSL_MIMETYPE_FRAG_ES);
|
||||||
|
new TextEditorActionHandler(this, C_GLSLEDITOR_ID,
|
||||||
|
TextEditorActionHandler::Format
|
||||||
|
| TextEditorActionHandler::UnCommentSelection
|
||||||
|
| TextEditorActionHandler::UnCollapseAll);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::IEditor *GlslEditorFactory::createEditor()
|
||||||
|
{
|
||||||
|
return new GlslEditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace GLSLEditor
|
||||||
|
|||||||
@@ -31,13 +31,14 @@
|
|||||||
#define GLSLEDITOR_H
|
#define GLSLEDITOR_H
|
||||||
|
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
|
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QTimer;
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace GLSL {
|
namespace GLSL {
|
||||||
@@ -86,7 +87,7 @@ class GlslEditorWidget : public TextEditor::BaseTextEditorWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GlslEditorWidget(const TextEditor::BaseTextDocumentPtr &doc);
|
GlslEditorWidget();
|
||||||
|
|
||||||
int editorRevision() const;
|
int editorRevision() const;
|
||||||
bool isOutdated() const;
|
bool isOutdated() const;
|
||||||
@@ -98,22 +99,38 @@ public:
|
|||||||
TextEditor::IAssistInterface *createAssistInterface(TextEditor::AssistKind assistKind,
|
TextEditor::IAssistInterface *createAssistInterface(TextEditor::AssistKind assistKind,
|
||||||
TextEditor::AssistReason reason) const;
|
TextEditor::AssistReason reason) const;
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
void updateDocument();
|
|
||||||
void updateDocumentNow();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
TextEditor::BaseTextEditor *createEditor();
|
||||||
|
|
||||||
private:
|
void updateDocumentNow();
|
||||||
void setSelectedElements();
|
void setSelectedElements();
|
||||||
QString wordUnderCursor() const;
|
QString wordUnderCursor() const;
|
||||||
|
|
||||||
QTimer *m_updateDocumentTimer;
|
QTimer m_updateDocumentTimer;
|
||||||
QComboBox *m_outlineCombo;
|
QComboBox *m_outlineCombo;
|
||||||
Document::Ptr m_glslDocument;
|
Document::Ptr m_glslDocument;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GlslEditor : public TextEditor::BaseTextEditor
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GlslEditor();
|
||||||
|
|
||||||
|
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||||
|
};
|
||||||
|
|
||||||
|
class GlslEditorFactory : public Core::IEditorFactory
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GlslEditorFactory();
|
||||||
|
|
||||||
|
Core::IEditor *createEditor();
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace GLSLEditor
|
} // namespace GLSLEditor
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ DEFINES += \
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
glsleditor.h \
|
glsleditor.h \
|
||||||
glsleditorconstants.h \
|
glsleditorconstants.h \
|
||||||
glsleditoreditable.h \
|
|
||||||
glsleditorfactory.h \
|
|
||||||
glsleditorplugin.h \
|
glsleditorplugin.h \
|
||||||
glslfilewizard.h \
|
glslfilewizard.h \
|
||||||
glslhighlighter.h \
|
glslhighlighter.h \
|
||||||
@@ -19,8 +17,6 @@ glslhoverhandler.h \
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
glsleditor.cpp \
|
glsleditor.cpp \
|
||||||
glsleditoreditable.cpp \
|
|
||||||
glsleditorfactory.cpp \
|
|
||||||
glsleditorplugin.cpp \
|
glsleditorplugin.cpp \
|
||||||
glslfilewizard.cpp \
|
glslfilewizard.cpp \
|
||||||
glslhighlighter.cpp \
|
glslhighlighter.cpp \
|
||||||
|
|||||||
@@ -24,10 +24,6 @@ QtcPlugin {
|
|||||||
"glsleditor.h",
|
"glsleditor.h",
|
||||||
"glsleditor.qrc",
|
"glsleditor.qrc",
|
||||||
"glsleditorconstants.h",
|
"glsleditorconstants.h",
|
||||||
"glsleditoreditable.cpp",
|
|
||||||
"glsleditoreditable.h",
|
|
||||||
"glsleditorfactory.cpp",
|
|
||||||
"glsleditorfactory.h",
|
|
||||||
"glsleditorplugin.cpp",
|
"glsleditorplugin.cpp",
|
||||||
"glsleditorplugin.h",
|
"glsleditorplugin.h",
|
||||||
"glslfilewizard.cpp",
|
"glslfilewizard.cpp",
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
namespace GLSLEditor {
|
namespace GLSLEditor {
|
||||||
namespace Constants {
|
namespace Constants {
|
||||||
|
|
||||||
// menus
|
|
||||||
const char M_CONTEXT[] = "GLSL Editor.ContextMenu";
|
const char M_CONTEXT[] = "GLSL Editor.ContextMenu";
|
||||||
const char M_TOOLS_GLSL[] = "GLSLEditor.Tools.Menu";
|
const char M_TOOLS_GLSL[] = "GLSLEditor.Tools.Menu";
|
||||||
|
|
||||||
|
|||||||
@@ -1,54 +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 "glsleditoreditable.h"
|
|
||||||
#include "glsleditorconstants.h"
|
|
||||||
#include "glslcompletionassist.h"
|
|
||||||
#include "glslautocompleter.h"
|
|
||||||
|
|
||||||
#include <texteditor/texteditorconstants.h>
|
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
|
|
||||||
namespace GLSLEditor {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
GlslEditor::GlslEditor()
|
|
||||||
{
|
|
||||||
setContext(Core::Context(GLSLEditor::Constants::C_GLSLEDITOR_ID,
|
|
||||||
TextEditor::Constants::C_TEXTEDITOR));
|
|
||||||
setDuplicateSupported(true);
|
|
||||||
setCommentStyle(Utils::CommentDefinition::CppStyle);
|
|
||||||
setCompletionAssistProvider(ExtensionSystem::PluginManager::getObject<GLSLCompletionAssistProvider>());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace GLSLEditor
|
|
||||||
@@ -1,52 +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 GLSLEDITOREDITABLE_H
|
|
||||||
#define GLSLEDITOREDITABLE_H
|
|
||||||
|
|
||||||
#include <texteditor/basetexteditor.h>
|
|
||||||
|
|
||||||
namespace GLSLEditor {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class GlslEditor : public TextEditor::BaseTextEditor
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
GlslEditor();
|
|
||||||
|
|
||||||
Core::IEditor *duplicate();
|
|
||||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace GLSLEditor
|
|
||||||
|
|
||||||
#endif // GLSLEDITOREDITABLE_H
|
|
||||||
@@ -1,73 +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 "glsleditorfactory.h"
|
|
||||||
#include "glsleditoreditable.h"
|
|
||||||
#include "glsleditor.h"
|
|
||||||
#include "glsleditorconstants.h"
|
|
||||||
#include "glsleditorplugin.h"
|
|
||||||
#include "glslindenter.h"
|
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
#include <extensionsystem/pluginspec.h>
|
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <texteditor/texteditoractionhandler.h>
|
|
||||||
#include <texteditor/texteditorsettings.h>
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
using namespace GLSLEditor::Internal;
|
|
||||||
using namespace GLSLEditor::Constants;
|
|
||||||
|
|
||||||
GLSLEditorFactory::GLSLEditorFactory(QObject *parent)
|
|
||||||
: Core::IEditorFactory(parent)
|
|
||||||
{
|
|
||||||
setId(C_GLSLEDITOR_ID);
|
|
||||||
setDisplayName(qApp->translate("OpenWith::Editors", C_GLSLEDITOR_DISPLAY_NAME));
|
|
||||||
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);
|
|
||||||
new TextEditor::TextEditorActionHandler(this, Constants::C_GLSLEDITOR_ID,
|
|
||||||
TextEditor::TextEditorActionHandler::Format
|
|
||||||
| TextEditor::TextEditorActionHandler::UnCommentSelection
|
|
||||||
| TextEditor::TextEditorActionHandler::UnCollapseAll);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::IEditor *GLSLEditorFactory::createEditor()
|
|
||||||
{
|
|
||||||
TextEditor::BaseTextDocumentPtr doc(new TextEditor::BaseTextDocument(C_GLSLEDITOR_ID));
|
|
||||||
doc->setIndenter(new GLSLIndenter);
|
|
||||||
GlslEditorWidget *rc = new GlslEditorWidget(doc);
|
|
||||||
return rc->editor();
|
|
||||||
}
|
|
||||||
@@ -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 GLSLEDITORFACTORY_H
|
|
||||||
#define GLSLEDITORFACTORY_H
|
|
||||||
|
|
||||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
|
||||||
|
|
||||||
namespace GLSLEditor {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class GLSLEditorFactory : public Core::IEditorFactory
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
GLSLEditorFactory(QObject *parent);
|
|
||||||
|
|
||||||
Core::IEditor *createEditor();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace GLSLEditor
|
|
||||||
|
|
||||||
#endif // GLSLEDITORFACTORY_H
|
|
||||||
@@ -28,42 +28,42 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "glsleditorplugin.h"
|
#include "glsleditorplugin.h"
|
||||||
|
#include "glslcompletionassist.h"
|
||||||
#include "glsleditor.h"
|
#include "glsleditor.h"
|
||||||
#include "glsleditorconstants.h"
|
#include "glsleditorconstants.h"
|
||||||
#include "glsleditorfactory.h"
|
|
||||||
#include "glslfilewizard.h"
|
#include "glslfilewizard.h"
|
||||||
#include "glslhoverhandler.h"
|
|
||||||
#include "glslcompletionassist.h"
|
|
||||||
#include "glslhighlighter.h"
|
#include "glslhighlighter.h"
|
||||||
|
#include "glslhoverhandler.h"
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <coreplugin/coreconstants.h>
|
|
||||||
#include <coreplugin/mimedatabase.h>
|
|
||||||
#include <coreplugin/id.h>
|
|
||||||
#include <coreplugin/fileiconprovider.h>
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
||||||
#include <coreplugin/actionmanager/command.h>
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
|
||||||
#include <projectexplorer/taskhub.h>
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
#include <texteditor/highlighterfactory.h>
|
|
||||||
#include <texteditor/texteditorconstants.h>
|
|
||||||
#include <texteditor/textfilewizard.h>
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
#include <glsl/glslengine.h>
|
#include <glsl/glslengine.h>
|
||||||
#include <glsl/glslparser.h>
|
#include <glsl/glslparser.h>
|
||||||
#include <glsl/glsllexer.h>
|
#include <glsl/glsllexer.h>
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <QDebug>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <QSettings>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <QDir>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <QCoreApplication>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <QTimer>
|
#include <coreplugin/fileiconprovider.h>
|
||||||
#include <QMenu>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/id.h>
|
||||||
|
#include <coreplugin/mimedatabase.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
|
#include <texteditor/highlighterfactory.h>
|
||||||
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
#include <texteditor/textfilewizard.h>
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QtPlugin>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
@@ -75,7 +75,6 @@ class GLSLEditorPluginPrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GLSLEditorPluginPrivate() :
|
GLSLEditorPluginPrivate() :
|
||||||
m_editor(0),
|
|
||||||
m_glsl_120_frag(0),
|
m_glsl_120_frag(0),
|
||||||
m_glsl_120_vert(0),
|
m_glsl_120_vert(0),
|
||||||
m_glsl_120_common(0),
|
m_glsl_120_common(0),
|
||||||
@@ -94,7 +93,6 @@ public:
|
|||||||
delete m_glsl_es_100_common;
|
delete m_glsl_es_100_common;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLSLEditorFactory *m_editor;
|
|
||||||
QPointer<TextEditor::BaseTextEditor> m_currentTextEditable;
|
QPointer<TextEditor::BaseTextEditor> m_currentTextEditable;
|
||||||
|
|
||||||
GLSLEditorPlugin::InitFile *m_glsl_120_frag;
|
GLSLEditorPlugin::InitFile *m_glsl_120_frag;
|
||||||
@@ -121,7 +119,6 @@ GLSLEditorPlugin::GLSLEditorPlugin()
|
|||||||
|
|
||||||
GLSLEditorPlugin::~GLSLEditorPlugin()
|
GLSLEditorPlugin::~GLSLEditorPlugin()
|
||||||
{
|
{
|
||||||
removeObject(dd->m_editor);
|
|
||||||
delete dd;
|
delete dd;
|
||||||
m_instance = 0;
|
m_instance = 0;
|
||||||
}
|
}
|
||||||
@@ -131,14 +128,8 @@ bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er
|
|||||||
if (!MimeDatabase::addMimeTypes(QLatin1String(":/glsleditor/GLSLEditor.mimetypes.xml"), errorMessage))
|
if (!MimeDatabase::addMimeTypes(QLatin1String(":/glsleditor/GLSLEditor.mimetypes.xml"), errorMessage))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// m_modelManager = new ModelManager(this);
|
|
||||||
// addAutoReleasedObject(m_modelManager);
|
|
||||||
|
|
||||||
addAutoReleasedObject(new GLSLHoverHandler(this));
|
addAutoReleasedObject(new GLSLHoverHandler(this));
|
||||||
|
addAutoReleasedObject(new GlslEditorFactory);
|
||||||
dd->m_editor = new GLSLEditorFactory(this);
|
|
||||||
addObject(dd->m_editor);
|
|
||||||
|
|
||||||
addAutoReleasedObject(new GLSLCompletionAssistProvider);
|
addAutoReleasedObject(new GLSLCompletionAssistProvider);
|
||||||
|
|
||||||
ActionContainer *contextMenu = ActionManager::createMenu(GLSLEditor::Constants::M_CONTEXT);
|
ActionContainer *contextMenu = ActionManager::createMenu(GLSLEditor::Constants::M_CONTEXT);
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
#include "glslhoverhandler.h"
|
#include "glslhoverhandler.h"
|
||||||
#include "glsleditor.h"
|
#include "glsleditor.h"
|
||||||
#include "glsleditoreditable.h"
|
|
||||||
|
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
@@ -38,7 +37,6 @@
|
|||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
#include <QUrl>
|
|
||||||
|
|
||||||
using namespace GLSLEditor;
|
using namespace GLSLEditor;
|
||||||
using namespace GLSLEditor::Internal;
|
using namespace GLSLEditor::Internal;
|
||||||
|
|||||||
Reference in New Issue
Block a user