forked from qt-creator/qt-creator
Remove the need to create ISnippetProvider subclasses
Change-Id: I1810aaa945136d9726a66dad41377429a6adc8e1 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
#include <qmljs/qmljsutils.h>
|
||||
|
||||
#include <qmljstools/qmljsindenter.h>
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
||||
@@ -1054,7 +1055,14 @@ QmlJSEditorFactory::QmlJSEditorFactory()
|
||||
setEditorActionHandlers(TextEditorActionHandler::Format
|
||||
| TextEditorActionHandler::UnCommentSelection
|
||||
| TextEditorActionHandler::UnCollapseAll
|
||||
| TextEditorActionHandler::FollowSymbolUnderCursor);
|
||||
| TextEditorActionHandler::FollowSymbolUnderCursor);
|
||||
}
|
||||
|
||||
void QmlJSEditorFactory::decorateEditor(TextEditorWidget *editor)
|
||||
{
|
||||
editor->textDocument()->setSyntaxHighlighter(new QmlJSHighlighter);
|
||||
editor->textDocument()->setIndenter(new Indenter);
|
||||
editor->setAutoCompleter(new AutoCompleter);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -148,6 +148,8 @@ class QmlJSEditorFactory : public TextEditor::TextEditorFactory
|
||||
|
||||
public:
|
||||
QmlJSEditorFactory();
|
||||
|
||||
static void decorateEditor(TextEditor::TextEditorWidget *editor);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -22,7 +22,6 @@ HEADERS += \
|
||||
qmljscomponentnamedialog.h \
|
||||
qmljsfindreferences.h \
|
||||
qmljsautocompleter.h \
|
||||
qmljssnippetprovider.h \
|
||||
qmljsreuse.h \
|
||||
qmljsquickfixassist.h \
|
||||
qmljscompletionassist.h \
|
||||
@@ -51,7 +50,6 @@ SOURCES += \
|
||||
qmljscomponentnamedialog.cpp \
|
||||
qmljsfindreferences.cpp \
|
||||
qmljsautocompleter.cpp \
|
||||
qmljssnippetprovider.cpp \
|
||||
qmljsreuse.cpp \
|
||||
qmljsquickfixassist.cpp \
|
||||
qmljscompletionassist.cpp \
|
||||
|
||||
@@ -61,8 +61,6 @@ QtcPlugin {
|
||||
"qmljssemantichighlighter.h",
|
||||
"qmljssemanticinfoupdater.cpp",
|
||||
"qmljssemanticinfoupdater.h",
|
||||
"qmljssnippetprovider.cpp",
|
||||
"qmljssnippetprovider.h",
|
||||
"qmljswrapinloader.cpp",
|
||||
"qmljswrapinloader.h",
|
||||
"qmloutlinemodel.cpp",
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "qmljsoutline.h"
|
||||
#include "qmljspreviewrunner.h"
|
||||
#include "qmljsquickfixassist.h"
|
||||
#include "qmljssnippetprovider.h"
|
||||
#include "qmltaskmanager.h"
|
||||
#include "quicktoolbar.h"
|
||||
|
||||
@@ -53,6 +52,7 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <texteditor/snippets/snippetprovider.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/json.h>
|
||||
@@ -101,7 +101,9 @@ QmlJSEditorPlugin::~QmlJSEditorPlugin()
|
||||
bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage)
|
||||
{
|
||||
m_modelManager = QmlJS::ModelManagerInterface::instance();
|
||||
addAutoReleasedObject(new QmlJSSnippetProvider);
|
||||
TextEditor::SnippetProvider::registerGroup(Constants::QML_SNIPPETS_GROUP_ID,
|
||||
tr("QML", "SnippetProvider"),
|
||||
&QmlJSEditorFactory::decorateEditor);
|
||||
|
||||
// QML task updating manager
|
||||
m_qmlTaskManager = new QmlTaskManager;
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmljssnippetprovider.h"
|
||||
#include "qmljshighlighter.h"
|
||||
#include "qmljseditor.h"
|
||||
#include "qmljsautocompleter.h"
|
||||
#include "qmljseditorconstants.h"
|
||||
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <texteditor/snippets/snippeteditor.h>
|
||||
|
||||
#include <qmljstools/qmljsindenter.h>
|
||||
|
||||
#include <QLatin1String>
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace QmlJSEditor;
|
||||
using namespace Internal;
|
||||
|
||||
QString QmlJSSnippetProvider::groupId() const
|
||||
{
|
||||
return QLatin1String(Constants::QML_SNIPPETS_GROUP_ID);
|
||||
}
|
||||
|
||||
QString QmlJSSnippetProvider::displayName() const
|
||||
{
|
||||
return QCoreApplication::translate("QmlJSEditor::Internal::QmlJSSnippetProvider", "QML");
|
||||
}
|
||||
|
||||
void QmlJSSnippetProvider::decorateEditor(TextEditor::SnippetEditorWidget *editor) const
|
||||
{
|
||||
editor->textDocument()->setSyntaxHighlighter(new QmlJSHighlighter);
|
||||
editor->textDocument()->setIndenter(new Indenter);
|
||||
editor->setAutoCompleter(new AutoCompleter);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <texteditor/snippets/isnippetprovider.h>
|
||||
|
||||
namespace QmlJSEditor {
|
||||
namespace Internal {
|
||||
|
||||
class QmlJSSnippetProvider : public TextEditor::ISnippetProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
~QmlJSSnippetProvider() final = default;
|
||||
|
||||
QString groupId() const final;
|
||||
QString displayName() const final;
|
||||
void decorateEditor(TextEditor::SnippetEditorWidget *editor) const final;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
} // QmlJSEditor
|
||||
Reference in New Issue
Block a user