QmlJsEditor: Hide plugin class definition in .cpp

Change-Id: I7d6325059aedd92b34072de1fbb05bc72fc95efd
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2024-01-16 09:28:44 +01:00
parent d9108d1ae2
commit 53ebc15918
5 changed files with 51 additions and 72 deletions

View File

@@ -950,7 +950,7 @@ void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e)
std::unique_ptr<AssistInterface> interface = createAssistInterface(QuickFix, ExplicitlyInvoked);
if (interface) {
QScopedPointer<IAssistProcessor> processor(
Internal::QmlJSEditorPlugin::quickFixAssistProvider()->createProcessor(interface.get()));
Internal::quickFixAssistProvider()->createProcessor(interface.get()));
QScopedPointer<IAssistProposal> proposal(processor->start(std::move(interface)));
if (!proposal.isNull()) {
GenericProposalModelPtr model = proposal->model().staticCast<GenericProposalModel>();

View File

@@ -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)

View File

@@ -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 <qmljs/jsoncheck.h>
#include <qmljs/qmljsicons.h>
@@ -28,6 +26,8 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <extensionsystem/iplugin.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projecttree.h>
@@ -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"

View File

@@ -3,34 +3,13 @@
#pragma once
#include <extensionsystem/iplugin.h>
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

View File

@@ -95,7 +95,7 @@ QmlJSTools::SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::D
semanticInfo.setRootScopeChain(QSharedPointer<const ScopeChain>(scopeChain));
if (doc->language() == Dialect::Json) {
JsonSchema *schema = QmlJSEditorPlugin::jsonManager()->schemaForFile(
JsonSchema *schema = jsonManager()->schemaForFile(
doc->fileName().toString());
if (schema) {
JsonCheck jsonChecker(doc);