diff options
author | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2014-09-10 11:46:07 +0200 |
---|---|---|
committer | Fawzi Mohamed <fawzi.mohamed@digia.com> | 2014-09-11 12:42:31 +0200 |
commit | 12b583564f760726b8a074b0f9d245f3a1b80a02 (patch) | |
tree | 1c653a97286cc4d12ea1ec46e599957c8220cb6b /src/plugins/qmljseditor/qmljswrapinloader.cpp | |
parent | d19628ddf85d1a296571948a47181e129cccb780 (diff) | |
download | qt-creator-12b583564f760726b8a074b0f9d245f3a1b80a02.tar.gz |
qmljs: make refactoring work on Object Bindings
“Move Component to Separate File” and “Wrap Component in Loader” did
work only for UiObjectDefinitions, extended them to UiObjectBindings.
Task-number: QTCREATORBUG-12904
Change-Id: I5216110c1edfc6e4536f83eba39e74919c918d50
Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'src/plugins/qmljseditor/qmljswrapinloader.cpp')
-rw-r--r-- | src/plugins/qmljseditor/qmljswrapinloader.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/qmljseditor/qmljswrapinloader.cpp b/src/plugins/qmljseditor/qmljswrapinloader.cpp index 0bb860fdad..6e44ed04e0 100644 --- a/src/plugins/qmljseditor/qmljswrapinloader.cpp +++ b/src/plugins/qmljseditor/qmljswrapinloader.cpp @@ -77,15 +77,16 @@ protected: Result result; }; +template <typename T> class Operation: public QmlJSQuickFixOperation { Q_DECLARE_TR_FUNCTIONS(QmlJSEditor::Internal::Operation) - UiObjectDefinition *m_objDef; + T *m_objDef; public: Operation(const QSharedPointer<const QmlJSQuickFixAssistInterface> &interface, - UiObjectDefinition *objDef) + T *objDef) : QmlJSQuickFixOperation(interface, 0) , m_objDef(objDef) { @@ -156,7 +157,7 @@ public: changes.insert(afterOpenBrace, innerIdForwarders); } - const int objDefStart = m_objDef->firstSourceLocation().begin(); + const int objDefStart = m_objDef->qualifiedTypeNameId->firstSourceLocation().begin(); const int objDefEnd = m_objDef->lastSourceLocation().end(); changes.insert(objDefStart, comment + QString::fromLatin1("Component {\n" @@ -188,9 +189,14 @@ void WrapInLoader::match(const QmlJSQuickFixInterface &interface, QuickFixOperat return; // check that the node is not the root node if (i > 0 && !cast<UiProgram*>(path.at(i - 1))) { - result.append(QuickFixOperation::Ptr(new Operation(interface, objDef))); + result.append(QuickFixOperation::Ptr(new Operation<UiObjectDefinition>(interface, objDef))); return; } + } else if (UiObjectBinding *objBinding = cast<UiObjectBinding *>(node)) { + if (!interface->currentFile()->isCursorOn(objBinding->qualifiedTypeNameId)) + return; + result.append(QuickFixOperation::Ptr(new Operation<UiObjectBinding>(interface, objBinding))); + return; } } } |