forked from qt-creator/qt-creator
Removed implicit change set and related utility methods.
This commit is contained in:
@@ -82,7 +82,7 @@ QString ComponentFromObjectDef::description() const
|
||||
"Extract Component");
|
||||
}
|
||||
|
||||
void ComponentFromObjectDef::createChangeSet()
|
||||
void ComponentFromObjectDef::createChanges()
|
||||
{
|
||||
Q_ASSERT(_objDef != 0);
|
||||
|
||||
@@ -90,7 +90,7 @@ void ComponentFromObjectDef::createChangeSet()
|
||||
componentName[0] = componentName.at(0).toUpper();
|
||||
|
||||
const QString path = editor()->file()->fileName();
|
||||
const QString fileName = QFileInfo(path).path() + QDir::separator() + componentName + QLatin1String(".qml");
|
||||
const QString newFileName = QFileInfo(path).path() + QDir::separator() + componentName + QLatin1String(".qml");
|
||||
|
||||
QString imports;
|
||||
UiProgram *prog = semanticInfo().document->qmlProgram();
|
||||
@@ -104,11 +104,13 @@ void ComponentFromObjectDef::createChangeSet()
|
||||
const int end = position(_objDef->lastSourceLocation());
|
||||
const QString txt = imports + textOf(start, end) + QLatin1String("}\n");
|
||||
|
||||
replace(start, end, componentName + QLatin1String(" {\n"));
|
||||
reindent(range(start, end + 1));
|
||||
Utils::ChangeSet changes;
|
||||
changes.replace(start, end - start, componentName + QLatin1String(" {\n"));
|
||||
qmljsRefactoringChanges()->changeFile(fileName(), changes);
|
||||
qmljsRefactoringChanges()->reindent(fileName(), range(start, end + 1));
|
||||
|
||||
qmljsRefactoringChanges()->createFile(fileName, txt);
|
||||
qmljsRefactoringChanges()->reindent(fileName, range(0, txt.length() - 1));
|
||||
qmljsRefactoringChanges()->createFile(newFileName, txt);
|
||||
qmljsRefactoringChanges()->reindent(newFileName, range(0, txt.length() - 1));
|
||||
}
|
||||
|
||||
int ComponentFromObjectDef::check()
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
ComponentFromObjectDef(TextEditor::BaseTextEditor *editor);
|
||||
|
||||
virtual QString description() const;
|
||||
virtual void createChangeSet();
|
||||
virtual void createChanges();
|
||||
virtual int check();
|
||||
|
||||
private:
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -61,16 +61,12 @@ public:
|
||||
virtual int match(TextEditor::QuickFixState *state);
|
||||
|
||||
protected:
|
||||
using TextEditor::QuickFixOperation::move;
|
||||
using TextEditor::QuickFixOperation::replace;
|
||||
using TextEditor::QuickFixOperation::insert;
|
||||
using TextEditor::QuickFixOperation::remove;
|
||||
using TextEditor::QuickFixOperation::flip;
|
||||
using TextEditor::QuickFixOperation::copy;
|
||||
using TextEditor::QuickFixOperation::textOf;
|
||||
using TextEditor::QuickFixOperation::charAt;
|
||||
using TextEditor::QuickFixOperation::position;
|
||||
|
||||
QString fileName() const;
|
||||
|
||||
virtual void apply();
|
||||
QmlJSRefactoringChanges *qmljsRefactoringChanges() const;
|
||||
virtual TextEditor::RefactoringChanges *refactoringChanges() const;
|
||||
|
||||
Reference in New Issue
Block a user