TextEditor: Get rid of extra indent ranges in RefactoringFile

Having extra indent regions complicates the interface, the
implementation and the calling code.
Instead, derive the indent regions from the change set and let callers
opt out for the relatively few cases where indentation is not desired.

Change-Id: I49d2854830a51778534ef260fb5c9f2c7685554a
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2023-11-20 11:28:41 +01:00
parent 2bd02671d8
commit 240748c106
18 changed files with 120 additions and 272 deletions

View File

@@ -190,7 +190,6 @@ public:
Utils::ChangeSet changes;
changes.replace(start, end, replacement);
currentFile->setChangeSet(changes);
currentFile->appendIndentRange(Range(start, end + 1));
currentFile->apply();
Core::IVersionControl *versionControl = Core::VcsManager::findVersionControlForDirectory(

View File

@@ -71,8 +71,6 @@ public:
QLatin1String("\n"));
currentFile->setChangeSet(changes);
currentFile->appendIndentRange(Range(currentFile->startOf(_objectInitializer->lbraceToken),
currentFile->startOf(_objectInitializer->rbraceToken)));
currentFile->apply();
}
};
@@ -123,7 +121,6 @@ public:
const int insertLoc = _message.location.begin() - _message.location.startColumn + 1;
changes.insert(insertLoc, QString::fromLatin1("// %1\n").arg(_message.suppressionString()));
currentFile->setChangeSet(changes);
currentFile->appendIndentRange(Range(insertLoc, insertLoc + 1));
currentFile->apply();
}
};

View File

@@ -147,7 +147,6 @@ public:
" sourceComponent: %1\n"
"}\n").arg(componentId, loaderId));
currentFile->setChangeSet(changes);
currentFile->appendIndentRange(Range(objDefStart, objDefEnd));
currentFile->apply();
}
};

View File

@@ -860,9 +860,6 @@ void QmlOutlineModel::reparentNodes(QmlOutlineItem *targetItem, int row, QList<Q
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(), m_semanticInfo.snapshot);
TextEditor::RefactoringFilePtr file = refactoring.file(m_semanticInfo.document->fileName());
file->setChangeSet(changeSet);
for (const Utils::ChangeSet::Range &range : std::as_const(changedRanges)) {
file->appendIndentRange(range);
}
file->apply();
}