Removed implicit change set and related utility methods.

This commit is contained in:
Erik Verbruggen
2010-06-14 17:15:53 +02:00
parent 00b5333745
commit f3faf34db9
8 changed files with 220 additions and 178 deletions

View File

@@ -63,24 +63,27 @@ public:
return QApplication::translate("QmlJSEditor::QuickFix", "Split initializer");
}
virtual void createChangeSet()
virtual void createChanges()
{
Q_ASSERT(_objectInitializer != 0);
Utils::ChangeSet changes;
for (QmlJS::AST::UiObjectMemberList *it = _objectInitializer->members; it; it = it->next) {
if (QmlJS::AST::UiObjectMember *member = it->member) {
const QmlJS::AST::SourceLocation loc = member->firstSourceLocation();
// insert a newline at the beginning of this binding
insert(position(loc), QLatin1String("\n"));
changes.insert(position(loc), QLatin1String("\n"));
}
}
// insert a newline before the closing brace
insert(position(_objectInitializer->rbraceToken), QLatin1String("\n"));
changes.insert(position(_objectInitializer->rbraceToken), QLatin1String("\n"));
reindent(RefactoringChanges::Range(position(_objectInitializer->lbraceToken),
position(_objectInitializer->rbraceToken)));
refactoringChanges()->changeFile(fileName(), changes);
refactoringChanges()->reindent(fileName(), range(position(_objectInitializer->lbraceToken),
position(_objectInitializer->rbraceToken)));
}
@@ -154,6 +157,11 @@ int QmlJSQuickFixOperation::match(TextEditor::QuickFixState *state)
return check();
}
QString QmlJSQuickFixOperation::fileName() const
{
return document()->fileName();
}
void QmlJSQuickFixOperation::apply()
{
_refactoringChanges->apply();