diff --git a/src/plugins/clangcodemodel/clangfixitoperation.cpp b/src/plugins/clangcodemodel/clangfixitoperation.cpp index e173592ec06..802bdd17bbb 100644 --- a/src/plugins/clangcodemodel/clangfixitoperation.cpp +++ b/src/plugins/clangcodemodel/clangfixitoperation.cpp @@ -71,10 +71,7 @@ QString ClangFixItOperation::firstRefactoringFileContent_forTestOnly() const void ClangFixItOperation::applyFixitsToFile(TextEditor::RefactoringFile &refactoringFile, const QList fixIts) { - const Utils::ChangeSet changeSet = toChangeSet(refactoringFile, fixIts); - - refactoringFile.setChangeSet(changeSet); - refactoringFile.apply(); + refactoringFile.apply(toChangeSet(refactoringFile, fixIts)); } Utils::ChangeSet ClangFixItOperation::toChangeSet( diff --git a/src/plugins/clangtools/clangtoolsdiagnosticview.cpp b/src/plugins/clangtools/clangtoolsdiagnosticview.cpp index e3d63e1ec9c..b8c516ad1a9 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticview.cpp +++ b/src/plugins/clangtools/clangtoolsdiagnosticview.cpp @@ -328,8 +328,7 @@ void DiagnosticView::suppressCurrentDiagnosticInline() changeSet.insert(insertStart, newText); } } - refactoringFile->setChangeSet(changeSet); - refactoringFile->apply(); + refactoringFile->apply(changeSet); } filterModel->addSuppressedDiagnostics(diags); diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp index b4ec9769d7a..e6722206df2 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp @@ -267,13 +267,11 @@ void FunctionDeclDefLink::apply(CppEditorWidget *editor, bool jumpToMatch) const int targetStart = newTargetFile->position(targetLine, targetColumn); const int targetEnd = targetStart + targetInitial.size(); if (targetInitial == newTargetFile->textOf(targetStart, targetEnd)) { - const ChangeSet changeset = changes(snapshot, targetStart); - newTargetFile->setChangeSet(changeset); if (jumpToMatch) { const int jumpTarget = newTargetFile->position(targetFunction->line(), targetFunction->column()); newTargetFile->setOpenEditor(true, jumpTarget); } - newTargetFile->apply(); + newTargetFile->apply(changes(snapshot, targetStart)); } else { ToolTip::show(editor->toolTipPosition(linkSelection), Tr::tr("Target file was changed, could not apply changes")); diff --git a/src/plugins/cppeditor/cppmodelmanager.cpp b/src/plugins/cppeditor/cppmodelmanager.cpp index aedb81c8c19..6f2aebcca32 100644 --- a/src/plugins/cppeditor/cppmodelmanager.cpp +++ b/src/plugins/cppeditor/cppmodelmanager.cpp @@ -2010,8 +2010,7 @@ void CppModelManager::renameIncludes(const QList> newString); } } - file->setChangeSet(changeSet); - file->apply(); + file->apply(changeSet); } } diff --git a/src/plugins/cppeditor/quickfixes/assigntolocalvariable.cpp b/src/plugins/cppeditor/quickfixes/assigntolocalvariable.cpp index 4eab51274c4..58a9818d8e5 100644 --- a/src/plugins/cppeditor/quickfixes/assigntolocalvariable.cpp +++ b/src/plugins/cppeditor/quickfixes/assigntolocalvariable.cpp @@ -54,8 +54,7 @@ private: varName + QLatin1String(" = ")); ChangeSet changes; changes.insert(m_insertPos, insertString); - m_file->setChangeSet(changes); - m_file->apply(); + m_file->apply(changes); // move cursor to new variable name QTextCursor c = m_file->cursor(); diff --git a/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp b/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp index 018a037d574..315ecfa3a85 100644 --- a/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp +++ b/src/plugins/cppeditor/quickfixes/bringidentifierintoscope.cpp @@ -292,8 +292,7 @@ private: insertion.append('\n'); ChangeSet s; s.insert(insertPos, insertion); - file->setChangeSet(s); - file->apply(); + file->apply(s); } const QString m_className; @@ -314,8 +313,7 @@ void AddIncludeForUndefinedIdentifierOp::perform() ChangeSet changes; insertNewIncludeDirective(m_include, file, semanticInfo().doc, changes); - file->setChangeSet(changes); - file->apply(); + file->apply(changes); } AddForwardDeclForUndefinedIdentifierOp::AddForwardDeclForUndefinedIdentifierOp( diff --git a/src/plugins/cppeditor/quickfixes/completeswitchstatement.cpp b/src/plugins/cppeditor/quickfixes/completeswitchstatement.cpp index 46dc68ba6dd..d2125697bc6 100644 --- a/src/plugins/cppeditor/quickfixes/completeswitchstatement.cpp +++ b/src/plugins/cppeditor/quickfixes/completeswitchstatement.cpp @@ -87,8 +87,7 @@ public: changes.insert(start, QLatin1String("\ncase ") + values.join(QLatin1String(":\nbreak;\ncase ")) + QLatin1String(":\nbreak;")); - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } CompoundStatementAST *compoundStatement; diff --git a/src/plugins/cppeditor/quickfixes/convertfromandtopointer.cpp b/src/plugins/cppeditor/quickfixes/convertfromandtopointer.cpp index 5531cec8844..5eea005200e 100644 --- a/src/plugins/cppeditor/quickfixes/convertfromandtopointer.cpp +++ b/src/plugins/cppeditor/quickfixes/convertfromandtopointer.cpp @@ -67,8 +67,7 @@ public: break; } - m_file->setChangeSet(changes); - m_file->apply(); + m_file->apply(changes); } private: diff --git a/src/plugins/cppeditor/quickfixes/convertnumericliteral.cpp b/src/plugins/cppeditor/quickfixes/convertnumericliteral.cpp index 5be834d99ca..2d977a67301 100644 --- a/src/plugins/cppeditor/quickfixes/convertnumericliteral.cpp +++ b/src/plugins/cppeditor/quickfixes/convertnumericliteral.cpp @@ -30,8 +30,7 @@ public: { ChangeSet changes; changes.replace(start, end, replacement); - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } private: diff --git a/src/plugins/cppeditor/quickfixes/convertqt4connect.cpp b/src/plugins/cppeditor/quickfixes/convertqt4connect.cpp index 18445d2a7d7..b9f08e90216 100644 --- a/src/plugins/cppeditor/quickfixes/convertqt4connect.cpp +++ b/src/plugins/cppeditor/quickfixes/convertqt4connect.cpp @@ -35,8 +35,7 @@ public: private: void perform() override { - currentFile()->setChangeSet(m_changes); - currentFile()->apply(); + currentFile()->apply(m_changes); } const ChangeSet m_changes; diff --git a/src/plugins/cppeditor/quickfixes/convertstringliteral.cpp b/src/plugins/cppeditor/quickfixes/convertstringliteral.cpp index 4636521fb2f..eff4b3a9ae6 100644 --- a/src/plugins/cppeditor/quickfixes/convertstringliteral.cpp +++ b/src/plugins/cppeditor/quickfixes/convertstringliteral.cpp @@ -275,8 +275,7 @@ public: changes.insert(endPos, "\"" + str + "\""); replace = false; } - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } private: @@ -352,8 +351,7 @@ public: changes.insert(startPos, leading); } - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } private: @@ -386,8 +384,7 @@ public: changes.insert(currentFile()->startOf(stringLiteral), QLatin1String("@")); } - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } private: diff --git a/src/plugins/cppeditor/quickfixes/converttocamelcase.cpp b/src/plugins/cppeditor/quickfixes/converttocamelcase.cpp index db16e7e1209..918b43d1a87 100644 --- a/src/plugins/cppeditor/quickfixes/converttocamelcase.cpp +++ b/src/plugins/cppeditor/quickfixes/converttocamelcase.cpp @@ -55,8 +55,7 @@ private: if (m_test) { ChangeSet changeSet; changeSet.replace(currentFile()->range(m_nameAst), newName); - currentFile()->setChangeSet(changeSet); - currentFile()->apply(); + currentFile()->apply(changeSet); } else { editor()->renameUsages(newName); } diff --git a/src/plugins/cppeditor/quickfixes/converttometamethodcall.cpp b/src/plugins/cppeditor/quickfixes/converttometamethodcall.cpp index 95c250595be..9d94808fbf8 100644 --- a/src/plugins/cppeditor/quickfixes/converttometamethodcall.cpp +++ b/src/plugins/cppeditor/quickfixes/converttometamethodcall.cpp @@ -100,8 +100,7 @@ private: } // Apply the changes. - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } const CallAST * const m_callAst; diff --git a/src/plugins/cppeditor/quickfixes/cppcodegenerationquickfixes.cpp b/src/plugins/cppeditor/quickfixes/cppcodegenerationquickfixes.cpp index 350646ee4db..842683cac51 100644 --- a/src/plugins/cppeditor/quickfixes/cppcodegenerationquickfixes.cpp +++ b/src/plugins/cppeditor/quickfixes/cppcodegenerationquickfixes.cpp @@ -307,14 +307,10 @@ public: insertAndIndent(m_sourceFile, m_sourceFileInsertionPoint, m_sourceFileCode); } - if (!m_headerFileChangeSet.isEmpty()) { - m_headerFile->setChangeSet(m_headerFileChangeSet); - m_headerFile->apply(); - } - if (!m_sourceFileChangeSet.isEmpty()) { - m_sourceFile->setChangeSet(m_sourceFileChangeSet); - m_sourceFile->apply(); - } + if (!m_headerFileChangeSet.isEmpty()) + m_headerFile->apply(m_headerFileChangeSet); + if (!m_sourceFileChangeSet.isEmpty()) + m_sourceFile->apply(m_sourceFileChangeSet); } bool hasSourceFile() const { return m_headerFile != m_sourceFile; } diff --git a/src/plugins/cppeditor/quickfixes/cppinsertvirtualmethods.cpp b/src/plugins/cppeditor/quickfixes/cppinsertvirtualmethods.cpp index 0ea79b9dd94..5b7b5e19127 100644 --- a/src/plugins/cppeditor/quickfixes/cppinsertvirtualmethods.cpp +++ b/src/plugins/cppeditor/quickfixes/cppinsertvirtualmethods.cpp @@ -868,9 +868,8 @@ public: // Write header file if (!headerChangeSet.isEmpty()) { - headerFile->setChangeSet(headerChangeSet); headerFile->setOpenEditor(true, m_insertPosDecl); - headerFile->apply(); + headerFile->apply(headerChangeSet); } // Insert in implementation file @@ -921,10 +920,8 @@ public: implementationChangeSet.insert(insertPos, QLatin1String("\n\n") + defText); } - if (!implementationChangeSet.isEmpty()) { - implementationFile->setChangeSet(implementationChangeSet); - implementationFile->apply(); - } + if (!implementationChangeSet.isEmpty()) + implementationFile->apply(implementationChangeSet); } } diff --git a/src/plugins/cppeditor/quickfixes/createdeclarationfromuse.cpp b/src/plugins/cppeditor/quickfixes/createdeclarationfromuse.cpp index 54d178d0d16..57ee646d9f0 100644 --- a/src/plugins/cppeditor/quickfixes/createdeclarationfromuse.cpp +++ b/src/plugins/cppeditor/quickfixes/createdeclarationfromuse.cpp @@ -113,9 +113,8 @@ public: ChangeSet target; target.insert(targetPosition, loc.prefix() + m_decl); - targetFile->setChangeSet(target); targetFile->setOpenEditor(true, targetPosition); - targetFile->apply(); + targetFile->apply(target); } static QString generateDeclaration(const Function *function) @@ -206,8 +205,7 @@ private: const int targetPosition = targetFile->position(loc.line(), loc.column()); ChangeSet target; target.insert(targetPosition, loc.prefix() + decl + ";\n"); - targetFile->setChangeSet(target); - targetFile->apply(); + targetFile->apply(target); } const Class * const m_class; @@ -242,8 +240,7 @@ public: changes.replace(currentFile()->startOf(binaryAST), currentFile()->endOf(simpleNameAST), declaration); - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } } diff --git a/src/plugins/cppeditor/quickfixes/extractfunction.cpp b/src/plugins/cppeditor/quickfixes/extractfunction.cpp index 8d452d7613f..58e5a2ef9d1 100644 --- a/src/plugins/cppeditor/quickfixes/extractfunction.cpp +++ b/src/plugins/cppeditor/quickfixes/extractfunction.cpp @@ -202,8 +202,7 @@ public: ChangeSet change; change.insert(position, funcDef); change.replace(m_extractionStart, m_extractionEnd, funcCall); - currentFile()->setChangeSet(change); - currentFile()->apply(); + currentFile()->apply(change); // Write declaration, if necessary. if (matchingClass) { @@ -215,8 +214,7 @@ public: change.clear(); position = declFile->position(location.line(), location.column()); change.insert(position, location.prefix() + funcDecl + location.suffix()); - declFile->setChangeSet(change); - declFile->apply(); + declFile->apply(change); } } diff --git a/src/plugins/cppeditor/quickfixes/extractliteralasparameter.cpp b/src/plugins/cppeditor/quickfixes/extractliteralasparameter.cpp index 78c69012b47..b5b23906e06 100644 --- a/src/plugins/cppeditor/quickfixes/extractliteralasparameter.cpp +++ b/src/plugins/cppeditor/quickfixes/extractliteralasparameter.cpp @@ -201,15 +201,13 @@ public: ChangeSet declChanges; appendFunctionParameter(functionDeclaration.ast, functionDeclaration.file, &declChanges, true); - functionDeclaration.file->setChangeSet(declChanges); - functionDeclaration.file->apply(); + functionDeclaration.file->apply(declChanges); } else { appendFunctionParameter(functionDeclaration.ast, currentFile(), &changes, true); } } - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); QTextCursor c = currentFile()->cursor(); c.setPosition(c.position() - parameterName().length()); editor()->setTextCursor(c); diff --git a/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp b/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp index 9c519b24b73..740c42909d1 100644 --- a/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp +++ b/src/plugins/cppeditor/quickfixes/insertfunctiondefinition.cpp @@ -114,9 +114,8 @@ public: target->replace(targetPos - 1, targetPos, QLatin1String("\n {\n\n}")); // replace ';' if (!changeSet) { - targetFile->setChangeSet(*target); targetFile->setOpenEditor(true, targetPos); - targetFile->apply(); + targetFile->apply(*target); // Move cursor inside definition QTextCursor c = targetFile->cursor(); @@ -190,9 +189,8 @@ public: target->insert(targetPos, loc.prefix() + defText + loc.suffix()); if (!changeSet) { - targetFile->setChangeSet(*target); targetFile->setOpenEditor(true, targetPos); - targetFile->apply(); + targetFile->apply(*target); // Move cursor inside definition QTextCursor c = targetFile->cursor(); @@ -454,11 +452,8 @@ private: this, loc, setting.defPos, finder.decl()->declarator_list->value, setting.func->asDeclaration(),targetFilePath, &changeSet); } - for (auto it = changeSets.cbegin(); it != changeSets.cend(); ++it) { - const CppRefactoringFilePtr file = refactoring.cppFile(it.key()); - file->setChangeSet(it.value()); - file->apply(); - } + for (auto it = changeSets.cbegin(); it != changeSets.cend(); ++it) + refactoring.cppFile(it.key())->apply(it.value()); } ClassSpecifierAST *m_classAST = nullptr; diff --git a/src/plugins/cppeditor/quickfixes/logicaloperationquickfixes.cpp b/src/plugins/cppeditor/quickfixes/logicaloperationquickfixes.cpp index 0de1c04e274..6faed4b9f03 100644 --- a/src/plugins/cppeditor/quickfixes/logicaloperationquickfixes.cpp +++ b/src/plugins/cppeditor/quickfixes/logicaloperationquickfixes.cpp @@ -41,8 +41,7 @@ public: if (!replacement.isEmpty()) changes.replace(currentFile()->range(binary->binary_op_token), replacement); - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } private: @@ -94,8 +93,7 @@ public: changes.insert(currentFile()->endOf(binary), QLatin1String(")")); } changes.replace(currentFile()->range(binary->binary_op_token), replacement); - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } private: @@ -134,8 +132,7 @@ public: changes.insert(start, QLatin1String("!(")); changes.insert(end, QLatin1String(")")); - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } }; diff --git a/src/plugins/cppeditor/quickfixes/moveclasstoownfile.cpp b/src/plugins/cppeditor/quickfixes/moveclasstoownfile.cpp index fa86fd96d03..896eb149990 100644 --- a/src/plugins/cppeditor/quickfixes/moveclasstoownfile.cpp +++ b/src/plugins/cppeditor/quickfixes/moveclasstoownfile.cpp @@ -441,8 +441,7 @@ private: .append('\n'); changes.remove(rangeToMove); } - refactoringFile->setChangeSet(changes); - refactoringFile->apply(); + refactoringFile->apply(changes); } if (!namespaceNames.isEmpty()) { @@ -455,19 +454,15 @@ private: if (!fileSettings.headerPragmaOnce) headerContent.append("\n#endif // " + headerGuard + '\n'); - CppRefactoringFilePtr headerFile = state->factory.cppFile(headerFilePath); headerFilePath.ensureExistingFile(); ChangeSet headerChanges; headerChanges.insert(0, headerContent); - headerFile->setChangeSet(headerChanges); - headerFile->apply(); + state->factory.cppFile(headerFilePath)->apply(headerChanges); if (hasSourceContent || mustCreateSourceFile) { sourceFilePath.ensureExistingFile(); - CppRefactoringFilePtr sourceFile = state->factory.cppFile(sourceFilePath); ChangeSet sourceChanges; sourceChanges.insert(0, sourceContent); - sourceFile->setChangeSet(sourceChanges); - sourceFile->apply(); + state->factory.cppFile(sourceFilePath)->apply(sourceChanges); } if (!projectNode) diff --git a/src/plugins/cppeditor/quickfixes/movefunctiondefinition.cpp b/src/plugins/cppeditor/quickfixes/movefunctiondefinition.cpp index e94a3863217..0008f53863f 100644 --- a/src/plugins/cppeditor/quickfixes/movefunctiondefinition.cpp +++ b/src/plugins/cppeditor/quickfixes/movefunctiondefinition.cpp @@ -135,14 +135,10 @@ public: void applyChanges() { - if (!m_toFileChangeSet.isEmpty()) { - m_toFile->setChangeSet(m_toFileChangeSet); - m_toFile->apply(); - } - if (!m_fromFileChangeSet.isEmpty()) { - m_fromFile->setChangeSet(m_fromFileChangeSet); - m_fromFile->apply(); - } + if (!m_toFileChangeSet.isEmpty()) + m_toFile->apply(m_toFileChangeSet); + if (!m_fromFileChangeSet.isEmpty()) + m_fromFile->apply(m_fromFileChangeSet); } private: @@ -278,14 +274,12 @@ private: toTarget.replace(m_toRange, wholeFunctionText); if (m_toFilePath == m_fromFilePath) toTarget.remove(m_fromRange); - toFile->setChangeSet(toTarget); toFile->setOpenEditor(true, m_toRange.start); - toFile->apply(); + toFile->apply(toTarget); if (m_toFilePath != m_fromFilePath) { ChangeSet fromTarget; fromTarget.remove(m_fromRange); - fromFile->setChangeSet(fromTarget); - fromFile->apply(); + fromFile->apply(fromTarget); } } diff --git a/src/plugins/cppeditor/quickfixes/rearrangeparamdeclarationlist.cpp b/src/plugins/cppeditor/quickfixes/rearrangeparamdeclarationlist.cpp index df61ba2bc50..61f922cf601 100644 --- a/src/plugins/cppeditor/quickfixes/rearrangeparamdeclarationlist.cpp +++ b/src/plugins/cppeditor/quickfixes/rearrangeparamdeclarationlist.cpp @@ -41,9 +41,8 @@ public: Utils::ChangeSet changes; changes.flip(currentFile()->startOf(m_currentParam), currentFile()->endOf(m_currentParam), currentFile()->startOf(m_targetParam), targetEndPos); - currentFile()->setChangeSet(changes); currentFile()->setOpenEditor(false, targetEndPos); - currentFile()->apply(); + currentFile()->apply(changes); } private: diff --git a/src/plugins/cppeditor/quickfixes/reformatpointerdeclaration.cpp b/src/plugins/cppeditor/quickfixes/reformatpointerdeclaration.cpp index fae08760a38..6a7ab4c2404 100644 --- a/src/plugins/cppeditor/quickfixes/reformatpointerdeclaration.cpp +++ b/src/plugins/cppeditor/quickfixes/reformatpointerdeclaration.cpp @@ -41,8 +41,7 @@ public: void perform() override { - currentFile()->setChangeSet(m_change); - currentFile()->apply(); + currentFile()->apply(m_change); } private: diff --git a/src/plugins/cppeditor/quickfixes/rewritecomment.cpp b/src/plugins/cppeditor/quickfixes/rewritecomment.cpp index c10bdaf1af3..518705039bb 100644 --- a/src/plugins/cppeditor/quickfixes/rewritecomment.cpp +++ b/src/plugins/cppeditor/quickfixes/rewritecomment.cpp @@ -360,14 +360,12 @@ private: targetChangeSet.insert(insertionPos, QString(insertionColumn, ' ')); if (targetFile == sourceFile) removeAtSource(targetChangeSet); - targetFile->setChangeSet(targetChangeSet); - const bool targetFileSuccess = targetFile->apply(); + const bool targetFileSuccess = targetFile->apply(targetChangeSet); if (targetFile == sourceFile || !targetFileSuccess) return; ChangeSet sourceChangeSet; removeAtSource(sourceChangeSet); - sourceFile->setChangeSet(sourceChangeSet); - sourceFile->apply(); + sourceFile->apply(sourceChangeSet); } const Symbol * const m_symbol; diff --git a/src/plugins/cppeditor/quickfixes/rewritecontrolstatements.cpp b/src/plugins/cppeditor/quickfixes/rewritecontrolstatements.cpp index 616fdaab3d0..2b9c2392df4 100644 --- a/src/plugins/cppeditor/quickfixes/rewritecontrolstatements.cpp +++ b/src/plugins/cppeditor/quickfixes/rewritecontrolstatements.cpp @@ -179,8 +179,7 @@ public: changes.move(currentFile()->range(condition), insertPos); changes.insert(insertPos, QLatin1String(";\n")); - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } ASTMatcher matcher; @@ -219,8 +218,7 @@ public: changes.copy(currentFile()->range(core), insertPos); changes.insert(insertPos, QLatin1String(";\n")); - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } ASTMatcher matcher; @@ -265,8 +263,7 @@ public: changes.remove(lExprEnd, currentFile()->startOf(condition->right_expression)); changes.insert(currentFile()->endOf(pattern), QLatin1String("\n}")); - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } void splitOrCondition() const @@ -293,8 +290,7 @@ public: const int lExprEnd = currentFile()->endOf(condition->left_expression); changes.remove(lExprEnd, currentFile()->startOf(condition->right_expression)); - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } private: @@ -376,8 +372,7 @@ public: change.replace(exprRange, varName); } - file->setChangeSet(change); - file->apply(); + file->apply(change); // Select variable name and trigger symbol rename if (renamePos != -1) { diff --git a/src/plugins/cppeditor/quickfixes/splitsimpledeclaration.cpp b/src/plugins/cppeditor/quickfixes/splitsimpledeclaration.cpp index c83fb8c936c..9d160d71ed3 100644 --- a/src/plugins/cppeditor/quickfixes/splitsimpledeclaration.cpp +++ b/src/plugins/cppeditor/quickfixes/splitsimpledeclaration.cpp @@ -67,8 +67,7 @@ public: prevDeclarator = declarator; } - currentFile()->setChangeSet(changes); - currentFile()->apply(); + currentFile()->apply(changes); } private: diff --git a/src/plugins/designer/qtcreatorintegration.cpp b/src/plugins/designer/qtcreatorintegration.cpp index 2da21f0e541..2c4cc907dc6 100644 --- a/src/plugins/designer/qtcreatorintegration.cpp +++ b/src/plugins/designer/qtcreatorintegration.cpp @@ -629,8 +629,7 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName, location.line(), location.column()); ChangeSet changeSet; changeSet.insert(insertionPos, definition); - file->setChangeSet(changeSet); - file->apply(); + file->apply(changeSet); const int indentationPos = file->document()->toPlainText().indexOf('}', insertionPos) - 1; QTextCursor cursor(editor->textDocument()->document()); cursor.setPosition(indentationPos); diff --git a/src/plugins/languageclient/languageclientutils.cpp b/src/plugins/languageclient/languageclientutils.cpp index 4924654ffc9..f7b52fdc9b8 100644 --- a/src/plugins/languageclient/languageclientutils.cpp +++ b/src/plugins/languageclient/languageclientutils.cpp @@ -97,8 +97,7 @@ bool applyTextEdits(const Client *client, if (edits.isEmpty()) return true; const RefactoringFilePtr file = client->createRefactoringFile(filePath); - file->setChangeSet(editsToChangeSet(edits, file->document())); - return file->apply(); + return file->apply(editsToChangeSet(edits, file->document())); } void applyTextEdit(TextDocumentManipulatorInterface &manipulator, diff --git a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp index 134baa58274..261715acbd8 100644 --- a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp +++ b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp @@ -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); diff --git a/src/plugins/qmljseditor/qmljsquickfixes.cpp b/src/plugins/qmljseditor/qmljsquickfixes.cpp index 126361451e2..f60d59e214c 100644 --- a/src/plugins/qmljseditor/qmljsquickfixes.cpp +++ b/src/plugins/qmljseditor/qmljsquickfixes.cpp @@ -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); } }; diff --git a/src/plugins/qmljseditor/qmljswrapinloader.cpp b/src/plugins/qmljseditor/qmljswrapinloader.cpp index bf5fd44d4a7..5f6b474ad62 100644 --- a/src/plugins/qmljseditor/qmljswrapinloader.cpp +++ b/src/plugins/qmljseditor/qmljswrapinloader.cpp @@ -146,8 +146,7 @@ public: " id: %2\n" " sourceComponent: %1\n" "}\n").arg(componentId, loaderId)); - currentFile->setChangeSet(changes); - currentFile->apply(); + currentFile->apply(changes); } }; diff --git a/src/plugins/qmljseditor/qmloutlinemodel.cpp b/src/plugins/qmljseditor/qmloutlinemodel.cpp index 456789f645b..9f156807742 100644 --- a/src/plugins/qmljseditor/qmloutlinemodel.cpp +++ b/src/plugins/qmljseditor/qmloutlinemodel.cpp @@ -897,10 +897,8 @@ void QmlOutlineModel::reparentNodes(QmlOutlineItem *targetItem, int row, QListfileName()); - file->setChangeSet(changeSet); - file->apply(); + QmlJSRefactoringChanges(ModelManagerInterface::instance(), m_semanticInfo.snapshot) + .file(m_semanticInfo.document->fileName())->apply(changeSet); } void QmlOutlineModel::moveObjectMember(AST::Node *toMove, diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index ce6d2f4999f..0faa871b5ce 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -594,8 +594,7 @@ FilePaths BaseFileFind::replaceAll(const QString &text, const SearchResultItems item.mainRange().end.column + 1); changeSet.replace(start, end, replacement); } - file->setChangeSet(changeSet); - file->apply(); + file->apply(changeSet); } return changes.keys(); diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp index ebd487cc370..da45c14a0ef 100644 --- a/src/plugins/texteditor/refactoringchanges.cpp +++ b/src/plugins/texteditor/refactoringchanges.cpp @@ -287,6 +287,12 @@ bool RefactoringFile::apply() return result; } +bool RefactoringFile::apply(const Utils::ChangeSet &changeSet) +{ + setChangeSet(changeSet); + return apply(); +} + void RefactoringFile::setupFormattingRanges(const QList &replaceList) { QTextDocument * const doc = m_editor ? m_editor->document() : m_document; @@ -359,7 +365,7 @@ void RefactoringFile::doFormatting() Utils::sort(m_formattingCursors, [](const auto &tc1, const auto &tc2) { return tc1.first.selectionStart() < tc2.first.selectionStart(); }); - static const QString clangFormatLineRemovalBlocker("// QTC_TEMP"); + static const QString clangFormatLineRemovalBlocker(""); for (auto &[formattingCursor, _] : m_formattingCursors) { const QTextBlock firstBlock = document->findBlock(formattingCursor.selectionStart()); const QTextBlock lastBlock = document->findBlock(formattingCursor.selectionEnd()); diff --git a/src/plugins/texteditor/refactoringchanges.h b/src/plugins/texteditor/refactoringchanges.h index 913c731df27..3e043c4f6be 100644 --- a/src/plugins/texteditor/refactoringchanges.h +++ b/src/plugins/texteditor/refactoringchanges.h @@ -60,6 +60,7 @@ public: void setChangeSet(const Utils::ChangeSet &changeSet); void setOpenEditor(bool activate = false, int pos = -1); bool apply(); + bool apply(const Utils::ChangeSet &changeSet); bool create(const QString &contents, bool reindent, bool openInEditor); protected: diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp index 9d8133912c8..7fcfe5c86c2 100644 --- a/src/plugins/texteditor/textdocument.cpp +++ b/src/plugins/texteditor/textdocument.cpp @@ -522,10 +522,7 @@ bool TextDocument::applyChangeSet(const ChangeSet &changeSet) { if (changeSet.isEmpty()) return true; - PlainRefactoringFileFactory changes; - const RefactoringFilePtr file = changes.file(filePath()); - file->setChangeSet(changeSet); - return file->apply(); + return PlainRefactoringFileFactory().file(filePath())->apply(changeSet); } // the blocks list must be sorted