forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user