QmlJSEditorPlugin: Refactor

This follows the recently introduced pattern for plugin setup
- Pimpl QmlJSEditorPlugin
- remove unneeded uses of global object pool
- apply "static pattern"
- simplify some constructors of data members in some cases
- use in-class initialization in some case

Change-Id: I95b42d0885f4a8d6c9bfe1e4c004d3ace0a3eba5
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2018-02-15 09:50:02 +01:00
parent 4786c5928a
commit 3da9c89981
11 changed files with 120 additions and 163 deletions

View File

@@ -26,32 +26,13 @@
#pragma once
#include <extensionsystem/iplugin.h>
#include <coreplugin/icontext.h>
#include <coreplugin/id.h>
#include <QPointer>
QT_FORWARD_DECLARE_CLASS(QAction)
namespace Utils { class JsonSchemaManager; }
namespace Core {
class Command;
class ActionContainer;
class IDocument;
class IEditor;
}
namespace QmlJS { class ModelManagerInterface; }
namespace QmlJSEditor {
class QmlJSEditorDocument;
namespace Internal {
class QmlJSQuickFixAssistProvider;
class QmlTaskManager;
class QmlJSEditorPlugin : public ExtensionSystem::IPlugin
{
@@ -60,44 +41,17 @@ class QmlJSEditorPlugin : public ExtensionSystem::IPlugin
public:
QmlJSEditorPlugin();
virtual ~QmlJSEditorPlugin();
~QmlJSEditorPlugin() final;
// IPlugin
bool initialize(const QStringList &arguments, QString *errorMessage = 0);
void extensionsInitialized();
ShutdownFlag aboutToShutdown();
static QmlJSEditorPlugin *instance()
{ return m_instance; }
QmlJSQuickFixAssistProvider *quickFixAssistProvider() const;
Utils::JsonSchemaManager *jsonManager() const;
void findUsages();
void renameUsages();
void reformatFile();
void showContextPane();
static QmlJSQuickFixAssistProvider *quickFixAssistProvider();
static Utils::JsonSchemaManager *jsonManager();
private:
void currentEditorChanged(Core::IEditor *editor);
void runSemanticScan();
void checkCurrentEditorSemanticInfoUpToDate();
void autoFormatOnSave(Core::IDocument *document);
bool initialize(const QStringList &arguments, QString *errorMessage) final;
void extensionsInitialized() final;
ShutdownFlag aboutToShutdown() final;
Core::Command *addToolAction(QAction *a, Core::Context &context, Core::Id id,
Core::ActionContainer *c1, const QString &keySequence);
static QmlJSEditorPlugin *m_instance;
QmlJS::ModelManagerInterface *m_modelManager;
QmlJSQuickFixAssistProvider *m_quickFixAssistProvider;
QmlTaskManager *m_qmlTaskManager;
QAction *m_reformatFileAction;
QPointer<QmlJSEditorDocument> m_currentDocument;
QScopedPointer<Utils::JsonSchemaManager> m_jsonManager;
class QmlJSEditorPluginPrivate *d = nullptr;
};
} // namespace Internal