forked from qt-creator/qt-creator
QuickFix: Clean up RefactoringChanges and add missing functionality.
* Can change files without opening an editor. * Can open an editor without changing a file. * Default to reindenting new files. * Allow reading a file temporarily to access document and text.
This commit is contained in:
@@ -91,17 +91,16 @@ public:
|
||||
const InsertionLocation loc = locator.methodDeclarationInClass(m_targetSymbol, m_xsSpec);
|
||||
Q_ASSERT(loc.isValid());
|
||||
|
||||
int targetPosition1 = changes->positionInFile(m_targetFileName, loc.line(), loc.column());
|
||||
int targetPosition2 = qMax(0, changes->positionInFile(m_targetFileName, loc.line(), 1) - 1);
|
||||
TextEditor::RefactoringFile targetFile = changes->file(m_targetFileName);
|
||||
int targetPosition1 = targetFile.position(loc.line(), loc.column());
|
||||
int targetPosition2 = qMax(0, targetFile.position(loc.line(), 1) - 1);
|
||||
|
||||
Utils::ChangeSet target;
|
||||
target.insert(targetPosition1, loc.prefix() + m_decl);
|
||||
changes->changeFile(m_targetFileName, target);
|
||||
targetFile.change(target);
|
||||
targetFile.indent(Utils::ChangeSet::Range(targetPosition2, targetPosition1));
|
||||
|
||||
changes->reindent(m_targetFileName,
|
||||
Utils::ChangeSet::Range(targetPosition2, targetPosition1));
|
||||
|
||||
changes->openEditor(m_targetFileName, loc.line(), loc.column());
|
||||
changes->setActiveEditor(m_targetFileName, targetPosition1);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user