From 6ba8be3d8a108f014f681a15e38b330efabe0913 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Fri, 29 Apr 2016 13:25:10 +0200 Subject: [PATCH] QmlJSEditor: Export ComponentFromObjectDef This makes it possible to use the functionality from the designer. Change-Id: Id91ed4c0adb22ff91d39be73689aec4f340342b8 Reviewed-by: Tim Jenssen --- .../qmljseditor/qmljscomponentfromobjectdef.cpp | 13 +++++++++++++ .../qmljseditor/qmljscomponentfromobjectdef.h | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp index f0116d28c24..bbe1c5c3dde 100644 --- a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp +++ b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -253,4 +254,16 @@ void ComponentFromObjectDef::match(const QmlJSQuickFixInterface &interface, Quic } } +void ComponentFromObjectDef::perform(const QString &fileName, QmlJS::AST::UiObjectDefinition *objDef) +{ + QmlJSRefactoringChanges refactoring(QmlJS::ModelManagerInterface::instance(), + QmlJS::ModelManagerInterface::instance()->snapshot()); + QmlJSRefactoringFilePtr current = refactoring.file(fileName); + + QmlJSQuickFixInterface interface; + Operation operation(interface, objDef); + + operation.performChanges(current, refactoring); +} + } //namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.h b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.h index f8734612e63..515d322fbed 100644 --- a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.h +++ b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.h @@ -28,13 +28,13 @@ #include "qmljsquickfix.h" namespace QmlJSEditor { -namespace Internal { -class ComponentFromObjectDef: public QmlJSQuickFixFactory +class QMLJSEDITOR_EXPORT ComponentFromObjectDef : public QmlJSQuickFixFactory { public: void match(const QmlJSQuickFixInterface &interface, QuickFixOperations &result); + + static void perform(const QString &fileName, QmlJS::AST::UiObjectDefinition *objDef); }; -} // namespace Internal } // namespace QmlJSEditor