forked from qt-creator/qt-creator
TextEditor: Add a convenience overload for RefactoringFile::apply()
... and make use of it. In most contexts, apply() immediately follows setChangeSet(), so combining the two can save a lot of code on the call site. Change-Id: I421001bd47000cb64678a57b19760becf59a4863 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -189,8 +189,7 @@ public:
|
||||
|
||||
Utils::ChangeSet changes;
|
||||
changes.replace(start, end, replacement);
|
||||
currentFile->setChangeSet(changes);
|
||||
currentFile->apply();
|
||||
currentFile->apply(changes);
|
||||
|
||||
Core::IVersionControl *versionControl = Core::VcsManager::findVersionControlForDirectory(
|
||||
path);
|
||||
|
||||
@@ -70,8 +70,7 @@ public:
|
||||
changes.insert(currentFile->startOf(_objectInitializer->rbraceToken),
|
||||
QLatin1String("\n"));
|
||||
|
||||
currentFile->setChangeSet(changes);
|
||||
currentFile->apply();
|
||||
currentFile->apply(changes);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -120,8 +119,7 @@ public:
|
||||
Utils::ChangeSet changes;
|
||||
const int insertLoc = _message.location.begin() - _message.location.startColumn + 1;
|
||||
changes.insert(insertLoc, QString::fromLatin1("// %1\n").arg(_message.suppressionString()));
|
||||
currentFile->setChangeSet(changes);
|
||||
currentFile->apply();
|
||||
currentFile->apply(changes);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -146,8 +146,7 @@ public:
|
||||
" id: %2\n"
|
||||
" sourceComponent: %1\n"
|
||||
"}\n").arg(componentId, loaderId));
|
||||
currentFile->setChangeSet(changes);
|
||||
currentFile->apply();
|
||||
currentFile->apply(changes);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -897,10 +897,8 @@ void QmlOutlineModel::reparentNodes(QmlOutlineItem *targetItem, int row, QList<Q
|
||||
changedRanges << range;
|
||||
}
|
||||
|
||||
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(), m_semanticInfo.snapshot);
|
||||
TextEditor::RefactoringFilePtr file = refactoring.file(m_semanticInfo.document->fileName());
|
||||
file->setChangeSet(changeSet);
|
||||
file->apply();
|
||||
QmlJSRefactoringChanges(ModelManagerInterface::instance(), m_semanticInfo.snapshot)
|
||||
.file(m_semanticInfo.document->fileName())->apply(changeSet);
|
||||
}
|
||||
|
||||
void QmlOutlineModel::moveObjectMember(AST::Node *toMove,
|
||||
|
||||
Reference in New Issue
Block a user