diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 51778d9717d..53e8b022edb 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -950,7 +950,7 @@ void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e) std::unique_ptr interface = createAssistInterface(QuickFix, ExplicitlyInvoked); if (interface) { QScopedPointer processor( - Internal::QmlJSEditorPlugin::quickFixAssistProvider()->createProcessor(interface.get())); + Internal::quickFixAssistProvider()->createProcessor(interface.get())); QScopedPointer proposal(processor->start(std::move(interface))); if (!proposal.isNull()) { GenericProposalModelPtr model = proposal->model().staticCast(); diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 9cec12c996d..18a9c4d0f26 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -859,7 +859,7 @@ TextEditor::IAssistProvider *QmlJSEditorDocument::quickFixAssistProvider() const { if (const auto baseProvider = TextDocument::quickFixAssistProvider()) return baseProvider; - return Internal::QmlJSEditorPlugin::quickFixAssistProvider(); + return Internal::quickFixAssistProvider(); } void QmlJSEditorDocument::setIsDesignModePreferred(bool value) diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 08141ea0b36..fe9e38bff7b 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -5,12 +5,10 @@ #include "qmljseditor.h" #include "qmljseditorconstants.h" #include "qmljseditordocument.h" -#include "qmljseditorplugin.h" #include "qmljseditortr.h" #include "qmljsoutline.h" #include "qmljsquickfixassist.h" #include "qmltaskmanager.h" -#include "quicktoolbar.h" #include #include @@ -28,6 +26,8 @@ #include #include +#include + #include #include #include @@ -54,8 +54,7 @@ using namespace ProjectExplorer; using namespace Core; using namespace Utils; -namespace QmlJSEditor { -namespace Internal { +namespace QmlJSEditor::Internal { class QmlJSEditorPluginPrivate : public QObject { @@ -89,25 +88,7 @@ public: QmlJsEditingSettingsPage m_qmJSEditingSettingsPage; }; -static QmlJSEditorPlugin *m_instance = 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; -} +static QmlJSEditorPluginPrivate *dd = nullptr; QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate() { @@ -203,24 +184,9 @@ QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate() this, &QmlJSEditorPluginPrivate::autoFormatOnSave); } -void QmlJSEditorPlugin::extensionsInitialized() +QmlJS::JsonSchemaManager *jsonManager() { - 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(); -} - -QmlJS::JsonSchemaManager *QmlJSEditorPlugin::jsonManager() -{ - return &m_instance->d->m_jsonManager; + return &dd->m_jsonManager; } void QmlJSEditorPluginPrivate::renameUsages() @@ -314,9 +280,9 @@ Command *QmlJSEditorPluginPrivate::addToolAction(QAction *a, return command; } -QmlJSQuickFixAssistProvider *QmlJSEditorPlugin::quickFixAssistProvider() +QmlJSQuickFixAssistProvider *quickFixAssistProvider() { - return &m_instance->d->m_quickFixAssistProvider; + return &dd->m_quickFixAssistProvider; } void QmlJSEditorPluginPrivate::currentEditorChanged(IEditor *editor) @@ -369,5 +335,39 @@ void QmlJSEditorPluginPrivate::autoFormatOnSave(IDocument *document) reformatFile(); } -} // namespace Internal -} // namespace QmlJSEditor +class QmlJSEditorPlugin final : public ExtensionSystem::IPlugin +{ + 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" diff --git a/src/plugins/qmljseditor/qmljseditorplugin.h b/src/plugins/qmljseditor/qmljseditorplugin.h index 2931c8f0bec..1707d2e8027 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.h +++ b/src/plugins/qmljseditor/qmljseditorplugin.h @@ -3,34 +3,13 @@ #pragma once -#include - namespace QmlJS { class JsonSchemaManager; } -namespace QmlJSEditor { -class QuickToolBar; -namespace Internal { +namespace QmlJSEditor::Internal { class QmlJSQuickFixAssistProvider; -class QmlJSEditorPlugin final : public ExtensionSystem::IPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlJSEditor.json") +QmlJSQuickFixAssistProvider *quickFixAssistProvider(); +QmlJS::JsonSchemaManager *jsonManager(); -public: - 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 +} // QmlJSEditor::Internal diff --git a/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp b/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp index 44c1a72f952..de36b64d55b 100644 --- a/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp +++ b/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp @@ -95,7 +95,7 @@ QmlJSTools::SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::D semanticInfo.setRootScopeChain(QSharedPointer(scopeChain)); if (doc->language() == Dialect::Json) { - JsonSchema *schema = QmlJSEditorPlugin::jsonManager()->schemaForFile( + JsonSchema *schema = jsonManager()->schemaForFile( doc->fileName().toString()); if (schema) { JsonCheck jsonChecker(doc);