forked from qt-creator/qt-creator
QmlJsEditor: Hide plugin class definition in .cpp
Change-Id: I7d6325059aedd92b34072de1fbb05bc72fc95efd Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -950,7 +950,7 @@ void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
|||||||
std::unique_ptr<AssistInterface> interface = createAssistInterface(QuickFix, ExplicitlyInvoked);
|
std::unique_ptr<AssistInterface> interface = createAssistInterface(QuickFix, ExplicitlyInvoked);
|
||||||
if (interface) {
|
if (interface) {
|
||||||
QScopedPointer<IAssistProcessor> processor(
|
QScopedPointer<IAssistProcessor> processor(
|
||||||
Internal::QmlJSEditorPlugin::quickFixAssistProvider()->createProcessor(interface.get()));
|
Internal::quickFixAssistProvider()->createProcessor(interface.get()));
|
||||||
QScopedPointer<IAssistProposal> proposal(processor->start(std::move(interface)));
|
QScopedPointer<IAssistProposal> proposal(processor->start(std::move(interface)));
|
||||||
if (!proposal.isNull()) {
|
if (!proposal.isNull()) {
|
||||||
GenericProposalModelPtr model = proposal->model().staticCast<GenericProposalModel>();
|
GenericProposalModelPtr model = proposal->model().staticCast<GenericProposalModel>();
|
||||||
|
|||||||
@@ -859,7 +859,7 @@ TextEditor::IAssistProvider *QmlJSEditorDocument::quickFixAssistProvider() const
|
|||||||
{
|
{
|
||||||
if (const auto baseProvider = TextDocument::quickFixAssistProvider())
|
if (const auto baseProvider = TextDocument::quickFixAssistProvider())
|
||||||
return baseProvider;
|
return baseProvider;
|
||||||
return Internal::QmlJSEditorPlugin::quickFixAssistProvider();
|
return Internal::quickFixAssistProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSEditorDocument::setIsDesignModePreferred(bool value)
|
void QmlJSEditorDocument::setIsDesignModePreferred(bool value)
|
||||||
|
|||||||
@@ -5,12 +5,10 @@
|
|||||||
#include "qmljseditor.h"
|
#include "qmljseditor.h"
|
||||||
#include "qmljseditorconstants.h"
|
#include "qmljseditorconstants.h"
|
||||||
#include "qmljseditordocument.h"
|
#include "qmljseditordocument.h"
|
||||||
#include "qmljseditorplugin.h"
|
|
||||||
#include "qmljseditortr.h"
|
#include "qmljseditortr.h"
|
||||||
#include "qmljsoutline.h"
|
#include "qmljsoutline.h"
|
||||||
#include "qmljsquickfixassist.h"
|
#include "qmljsquickfixassist.h"
|
||||||
#include "qmltaskmanager.h"
|
#include "qmltaskmanager.h"
|
||||||
#include "quicktoolbar.h"
|
|
||||||
|
|
||||||
#include <qmljs/jsoncheck.h>
|
#include <qmljs/jsoncheck.h>
|
||||||
#include <qmljs/qmljsicons.h>
|
#include <qmljs/qmljsicons.h>
|
||||||
@@ -28,6 +26,8 @@
|
|||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/projecttree.h>
|
#include <projectexplorer/projecttree.h>
|
||||||
@@ -54,8 +54,7 @@ using namespace ProjectExplorer;
|
|||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class QmlJSEditorPluginPrivate : public QObject
|
class QmlJSEditorPluginPrivate : public QObject
|
||||||
{
|
{
|
||||||
@@ -89,25 +88,7 @@ public:
|
|||||||
QmlJsEditingSettingsPage m_qmJSEditingSettingsPage;
|
QmlJsEditingSettingsPage m_qmJSEditingSettingsPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
static QmlJSEditorPlugin *m_instance = nullptr;
|
static QmlJSEditorPluginPrivate *dd = nullptr;
|
||||||
|
|
||||||
QmlJSEditorPlugin::QmlJSEditorPlugin()
|
|
||||||
{
|
|
||||||
m_instance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
QmlJSEditorPlugin::~QmlJSEditorPlugin()
|
|
||||||
{
|
|
||||||
delete QmlJS::Icons::instance(); // delete object held by singleton
|
|
||||||
delete d;
|
|
||||||
d = nullptr;
|
|
||||||
m_instance = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlJSEditorPlugin::initialize()
|
|
||||||
{
|
|
||||||
d = new QmlJSEditorPluginPrivate;
|
|
||||||
}
|
|
||||||
|
|
||||||
QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate()
|
QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate()
|
||||||
{
|
{
|
||||||
@@ -203,24 +184,9 @@ QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate()
|
|||||||
this, &QmlJSEditorPluginPrivate::autoFormatOnSave);
|
this, &QmlJSEditorPluginPrivate::autoFormatOnSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSEditorPlugin::extensionsInitialized()
|
QmlJS::JsonSchemaManager *jsonManager()
|
||||||
{
|
{
|
||||||
FileIconProvider::registerIconOverlayForMimeType(ProjectExplorer::Constants::FILEOVERLAY_UI,
|
return &dd->m_jsonManager;
|
||||||
Utils::Constants::QMLUI_MIMETYPE);
|
|
||||||
|
|
||||||
TaskHub::addCategory({Constants::TASK_CATEGORY_QML,
|
|
||||||
Tr::tr("QML"),
|
|
||||||
Tr::tr("Issues that the QML code parser found.")});
|
|
||||||
TaskHub::addCategory({Constants::TASK_CATEGORY_QML_ANALYSIS,
|
|
||||||
Tr::tr("QML Analysis"),
|
|
||||||
Tr::tr("Issues that the QML static analyzer found."),
|
|
||||||
false});
|
|
||||||
QmllsSettingsManager::instance()->setupAutoupdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
QmlJS::JsonSchemaManager *QmlJSEditorPlugin::jsonManager()
|
|
||||||
{
|
|
||||||
return &m_instance->d->m_jsonManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSEditorPluginPrivate::renameUsages()
|
void QmlJSEditorPluginPrivate::renameUsages()
|
||||||
@@ -314,9 +280,9 @@ Command *QmlJSEditorPluginPrivate::addToolAction(QAction *a,
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSQuickFixAssistProvider *QmlJSEditorPlugin::quickFixAssistProvider()
|
QmlJSQuickFixAssistProvider *quickFixAssistProvider()
|
||||||
{
|
{
|
||||||
return &m_instance->d->m_quickFixAssistProvider;
|
return &dd->m_quickFixAssistProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSEditorPluginPrivate::currentEditorChanged(IEditor *editor)
|
void QmlJSEditorPluginPrivate::currentEditorChanged(IEditor *editor)
|
||||||
@@ -369,5 +335,39 @@ void QmlJSEditorPluginPrivate::autoFormatOnSave(IDocument *document)
|
|||||||
reformatFile();
|
reformatFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
class QmlJSEditorPlugin final : public ExtensionSystem::IPlugin
|
||||||
} // namespace QmlJSEditor
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlJSEditor.json")
|
||||||
|
|
||||||
|
~QmlJSEditorPlugin() final
|
||||||
|
{
|
||||||
|
delete QmlJS::Icons::instance(); // delete object held by singleton
|
||||||
|
delete dd;
|
||||||
|
dd = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initialize() final
|
||||||
|
{
|
||||||
|
dd = new QmlJSEditorPluginPrivate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void extensionsInitialized() final
|
||||||
|
{
|
||||||
|
FileIconProvider::registerIconOverlayForMimeType(ProjectExplorer::Constants::FILEOVERLAY_UI,
|
||||||
|
Utils::Constants::QMLUI_MIMETYPE);
|
||||||
|
|
||||||
|
TaskHub::addCategory({Constants::TASK_CATEGORY_QML,
|
||||||
|
Tr::tr("QML"),
|
||||||
|
Tr::tr("Issues that the QML code parser found.")});
|
||||||
|
TaskHub::addCategory({Constants::TASK_CATEGORY_QML_ANALYSIS,
|
||||||
|
Tr::tr("QML Analysis"),
|
||||||
|
Tr::tr("Issues that the QML static analyzer found."),
|
||||||
|
false});
|
||||||
|
QmllsSettingsManager::instance()->setupAutoupdate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // QmlJSEditor::Internal
|
||||||
|
|
||||||
|
#include "qmljseditorplugin.moc"
|
||||||
|
|||||||
@@ -3,34 +3,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
|
||||||
|
|
||||||
namespace QmlJS { class JsonSchemaManager; }
|
namespace QmlJS { class JsonSchemaManager; }
|
||||||
|
|
||||||
namespace QmlJSEditor {
|
namespace QmlJSEditor::Internal {
|
||||||
class QuickToolBar;
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class QmlJSQuickFixAssistProvider;
|
class QmlJSQuickFixAssistProvider;
|
||||||
|
|
||||||
class QmlJSEditorPlugin final : public ExtensionSystem::IPlugin
|
QmlJSQuickFixAssistProvider *quickFixAssistProvider();
|
||||||
{
|
QmlJS::JsonSchemaManager *jsonManager();
|
||||||
Q_OBJECT
|
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlJSEditor.json")
|
|
||||||
|
|
||||||
public:
|
} // QmlJSEditor::Internal
|
||||||
QmlJSEditorPlugin();
|
|
||||||
~QmlJSEditorPlugin() final;
|
|
||||||
|
|
||||||
static QmlJSQuickFixAssistProvider *quickFixAssistProvider();
|
|
||||||
static QmlJS::JsonSchemaManager *jsonManager();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initialize() final;
|
|
||||||
void extensionsInitialized() final;
|
|
||||||
|
|
||||||
class QmlJSEditorPluginPrivate *d = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace QmlJSEditor
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ QmlJSTools::SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::D
|
|||||||
semanticInfo.setRootScopeChain(QSharedPointer<const ScopeChain>(scopeChain));
|
semanticInfo.setRootScopeChain(QSharedPointer<const ScopeChain>(scopeChain));
|
||||||
|
|
||||||
if (doc->language() == Dialect::Json) {
|
if (doc->language() == Dialect::Json) {
|
||||||
JsonSchema *schema = QmlJSEditorPlugin::jsonManager()->schemaForFile(
|
JsonSchema *schema = jsonManager()->schemaForFile(
|
||||||
doc->fileName().toString());
|
doc->fileName().toString());
|
||||||
if (schema) {
|
if (schema) {
|
||||||
JsonCheck jsonChecker(doc);
|
JsonCheck jsonChecker(doc);
|
||||||
|
|||||||
Reference in New Issue
Block a user