diff --git a/src/plugins/cppeditor/cppquickfix.cpp b/src/plugins/cppeditor/cppquickfix.cpp index ea809580a83886275c948e7a9dfe6e2085d6f3cb..179969fc8dbadd2f0d492c24d36a4283c2e51659 100644 --- a/src/plugins/cppeditor/cppquickfix.cpp +++ b/src/plugins/cppeditor/cppquickfix.cpp @@ -56,6 +56,7 @@ using namespace CppEditor::Internal; using namespace CPlusPlus; +using namespace Utils; namespace { @@ -135,18 +136,20 @@ public: return index; } - virtual void createChangeSet() + virtual void createChanges() { + ChangeSet changes; if (negation) { // can't remove parentheses since that might break precedence - remove(negation->unary_op_token); + remove(&changes, negation->unary_op_token); } else if (nested) { - insert(startOf(nested), "!"); + changes.insert(startOf(nested), "!"); } else { - insert(startOf(binary), "!("); - insert(endOf(binary), ")"); + changes.insert(startOf(binary), "!("); + changes.insert(endOf(binary), ")"); } - replace(binary->binary_op_token, replacement); + replace(&changes, binary->binary_op_token, replacement); + cppRefactoringChanges()->changeFile(fileName(), changes); } private: @@ -221,11 +224,15 @@ public: return index; } - virtual void createChangeSet() + virtual void createChanges() { - flip(binary->left_expression, binary->right_expression); + ChangeSet changes; + + flip(&changes, binary->left_expression, binary->right_expression); if (! replacement.isEmpty()) - replace(binary->binary_op_token, replacement); + replace(&changes, binary->binary_op_token, replacement); + + cppRefactoringChanges()->changeFile(fileName(), changes); } private: @@ -283,14 +290,19 @@ public: return -1; } - virtual void createChangeSet() + virtual void createChanges() { - setTopLevelNode(pattern); - replace(pattern->binary_op_token, QLatin1String("||")); - remove(left->unary_op_token); - remove(right->unary_op_token); - insert(startOf(pattern), QLatin1String("!(")); - insert(endOf(pattern), QLatin1String(")")); + ChangeSet changes; + replace(&changes, pattern->binary_op_token, QLatin1String("||")); + remove(&changes, left->unary_op_token); + remove(&changes, right->unary_op_token); + const int start = startOf(pattern); + const int end = endOf(pattern); + changes.insert(start, QLatin1String("!(")); + changes.insert(end, QLatin1String(")")); + + cppRefactoringChanges()->changeFile(fileName(), changes); + cppRefactoringChanges()->reindent(fileName(), range(start, end)); } private: @@ -374,9 +386,10 @@ public: return -1; } - virtual void createChangeSet() + virtual void createChanges() { - setTopLevelNode(declaration); + ChangeSet changes; + SpecifierListAST *specifiers = declaration->decl_specifier_list; int declSpecifiersStart = startOf(specifiers->firstToken()); int declSpecifiersEnd = endOf(specifiers->lastToken() - 1); @@ -387,16 +400,21 @@ public: for (DeclaratorListAST *it = declaration->declarator_list->next; it; it = it->next) { DeclaratorAST *declarator = it->value; - insert(insertPos, QLatin1String("\n")); - copy(declSpecifiersStart, declSpecifiersEnd, insertPos); - insert(insertPos, QLatin1String(" ")); - move(declarator, insertPos); - insert(insertPos, QLatin1String(";")); + changes.insert(insertPos, QLatin1String("\n")); + changes.copy(declSpecifiersStart, declSpecifiersEnd - declSpecifiersStart, insertPos); + changes.insert(insertPos, QLatin1String(" ")); + move(&changes, declarator, insertPos); + changes.insert(insertPos, QLatin1String(";")); - remove(endOf(prevDeclarator), startOf(declarator)); + const int prevDeclEnd = endOf(prevDeclarator); + changes.remove(prevDeclEnd, startOf(declarator) - prevDeclEnd); prevDeclarator = declarator; } + + cppRefactoringChanges()->changeFile(fileName(), changes); + cppRefactoringChanges()->reindent(fileName(), range(startOf(declaration->firstToken()), + endOf(declaration->lastToken() - 1))); } private: @@ -448,11 +466,18 @@ public: return -1; } - virtual void createChangeSet() + virtual void createChanges() { - setTopLevelNode(_statement); - insert(endOf(_statement->firstToken() - 1), QLatin1String(" {")); - insert(endOf(_statement->lastToken() - 1), "\n}"); + ChangeSet changes; + + const int start = endOf(_statement->firstToken() - 1); + changes.insert(start, QLatin1String(" {")); + + const int end = endOf(_statement->lastToken() - 1); + changes.insert(end, "\n}"); + + cppRefactoringChanges()->changeFile(fileName(), changes); + cppRefactoringChanges()->reindent(fileName(), range(start, end)); } private: @@ -502,15 +527,19 @@ public: return -1; } - virtual void createChangeSet() + virtual void createChanges() { - setTopLevelNode(pattern); + ChangeSet changes; - copy(core, startOf(condition)); + copy(&changes, core, startOf(condition)); int insertPos = startOf(pattern); - move(condition, insertPos); - insert(insertPos, QLatin1String(";\n")); + move(&changes, condition, insertPos); + changes.insert(insertPos, QLatin1String(";\n")); + + cppRefactoringChanges()->changeFile(fileName(), changes); + cppRefactoringChanges()->reindent(fileName(), range(startOf(pattern), + endOf(pattern))); } private: @@ -572,17 +601,22 @@ public: return -1; } - virtual void createChangeSet() + virtual void createChanges() { - setTopLevelNode(pattern); + ChangeSet changes; - insert(startOf(condition), QLatin1String("(")); - insert(endOf(condition), QLatin1String(") != 0")); + changes.insert(startOf(condition), QLatin1String("(")); + changes.insert(endOf(condition), QLatin1String(") != 0")); int insertPos = startOf(pattern); - move(startOf(condition), startOf(core), insertPos); - copy(core, insertPos); - insert(insertPos, QLatin1String(";\n")); + const int conditionStart = startOf(condition); + changes.move(conditionStart, startOf(core) - conditionStart, insertPos); + copy(&changes, core, insertPos); + changes.insert(insertPos, QLatin1String(";\n")); + + cppRefactoringChanges()->changeFile(fileName(), changes); + cppRefactoringChanges()->reindent(fileName(), range(startOf(pattern), + endOf(pattern))); } private: @@ -671,7 +705,7 @@ public: return -1; } - virtual void createChangeSet() + virtual void createChanges() { Token binaryToken = tokenAt(condition->binary_op_token); @@ -683,35 +717,51 @@ public: void splitAndCondition() { - setTopLevelNode(pattern); + ChangeSet changes; int startPos = startOf(pattern); - insert(startPos, QLatin1String("if (")); - move(condition->left_expression, startPos); - insert(startPos, QLatin1String(") {\n")); - - remove(endOf(condition->left_expression), startOf(condition->right_expression)); - insert(endOf(pattern), QLatin1String("\n}")); + changes.insert(startPos, QLatin1String("if (")); + move(&changes, condition->left_expression, startPos); + changes.insert(startPos, QLatin1String(") {\n")); + + const int lExprEnd = endOf(condition->left_expression); + changes.remove(lExprEnd, + startOf(condition->right_expression) - lExprEnd); + changes.insert(endOf(pattern), QLatin1String("\n}")); + + cppRefactoringChanges()->changeFile(fileName(), changes); + cppRefactoringChanges()->reindent(fileName(), range(startOf(pattern), + endOf(pattern))); } void splitOrCondition() { + ChangeSet changes; + StatementAST *ifTrueStatement = pattern->statement; CompoundStatementAST *compoundStatement = ifTrueStatement->asCompoundStatement(); - setTopLevelNode(pattern); - int insertPos = endOf(ifTrueStatement); if (compoundStatement) - insert(insertPos, QLatin1String(" ")); + changes.insert(insertPos, QLatin1String(" ")); else - insert(insertPos, QLatin1String("\n")); - insert(insertPos, QLatin1String("else if (")); - move(startOf(condition->right_expression), startOf(pattern->rparen_token), insertPos); - insert(insertPos, QLatin1String(")")); - copy(endOf(pattern->rparen_token), endOf(pattern->statement), insertPos); + changes.insert(insertPos, QLatin1String("\n")); + changes.insert(insertPos, QLatin1String("else if (")); + + const int rExprStart = startOf(condition->right_expression); + changes.move(rExprStart, startOf(pattern->rparen_token) - rExprStart, + insertPos); + changes.insert(insertPos, QLatin1String(")")); - remove(endOf(condition->left_expression), startOf(condition->right_expression)); + const int rParenEnd = endOf(pattern->rparen_token); + changes.copy(rParenEnd, endOf(pattern->statement) - rParenEnd, insertPos); + + const int lExprEnd = endOf(condition->left_expression); + changes.remove(lExprEnd, startOf(condition->right_expression) - lExprEnd); + + cppRefactoringChanges()->changeFile(fileName(), changes); + cppRefactoringChanges()->reindent(fileName(), range(startOf(pattern), + endOf(pattern))); } private: @@ -775,17 +825,21 @@ public: return index; } - virtual void createChangeSet() + virtual void createChanges() { + ChangeSet changes; + const int startPos = startOf(stringLiteral); const QLatin1String replacement("QLatin1String("); if (isObjCStringLiteral) - replace(startPos, startPos + 1, replacement); + changes.replace(startPos, 1, replacement); else - insert(startPos, replacement); + changes.insert(startPos, replacement); - insert(endOf(stringLiteral), ")"); + changes.insert(endOf(stringLiteral), ")"); + + cppRefactoringChanges()->changeFile(fileName(), changes); } private: @@ -846,14 +900,21 @@ public: return index; } - virtual void createChangeSet() + virtual void createChanges() { + ChangeSet changes; + if (qlatin1Call) { - replace(startOf(qlatin1Call), startOf(stringLiteral), QLatin1String("@")); - remove(endOf(stringLiteral), endOf(qlatin1Call)); + changes.replace(startOf(qlatin1Call), + startOf(stringLiteral) - startOf(qlatin1Call), + QLatin1String("@")); + changes.remove(endOf(stringLiteral), + endOf(qlatin1Call) - endOf(stringLiteral)); } else { - insert(startOf(stringLiteral), "@"); + changes.insert(startOf(stringLiteral), "@"); } + + cppRefactoringChanges()->changeFile(fileName(), changes); } private: @@ -887,6 +948,9 @@ int CppQuickFixOperation::match(TextEditor::QuickFixState *state) return match(s->path); } +QString CppQuickFixOperation::fileName() const +{ return document()->fileName(); } + void CppQuickFixOperation::apply() { cppRefactoringChanges()->apply(); @@ -898,12 +962,6 @@ CppTools::CppRefactoringChanges *CppQuickFixOperation::cppRefactoringChanges() c TextEditor::RefactoringChanges *CppQuickFixOperation::refactoringChanges() const { return cppRefactoringChanges(); } -CPlusPlus::AST *CppQuickFixOperation::topLevelNode() const -{ return _topLevelNode; } - -void CppQuickFixOperation::setTopLevelNode(CPlusPlus::AST *topLevelNode) -{ _topLevelNode = topLevelNode; } - Document::Ptr CppQuickFixOperation::document() const { return _document; } @@ -979,57 +1037,91 @@ bool CppQuickFixOperation::isCursorOn(const CPlusPlus::AST *ast) const return false; } -void CppQuickFixOperation::move(unsigned tokenIndex, int to) +void CppQuickFixOperation::move(ChangeSet *changeSet, unsigned tokenIndex, + int to) { + Q_ASSERT(changeSet); + int start, end; startAndEndOf(tokenIndex, &start, &end); - move(start, end, to); + changeSet->move(start, end - start, to); } -void CppQuickFixOperation::move(const CPlusPlus::AST *ast, int to) +void CppQuickFixOperation::move(ChangeSet *changeSet, const CPlusPlus::AST *ast, + int to) { - move(startOf(ast), endOf(ast), to); + Q_ASSERT(changeSet); + + const int start = startOf(ast); + changeSet->move(start, endOf(ast) - start, to); } -void CppQuickFixOperation::replace(unsigned tokenIndex, const QString &replacement) +void CppQuickFixOperation::replace(ChangeSet *changeSet, unsigned tokenIndex, + const QString &replacement) { + Q_ASSERT(changeSet); + int start, end; startAndEndOf(tokenIndex, &start, &end); - replace(start, end, replacement); + changeSet->replace(start, end - start, replacement); } -void CppQuickFixOperation::replace(const CPlusPlus::AST *ast, const QString &replacement) +void CppQuickFixOperation::replace(ChangeSet *changeSet, + const CPlusPlus::AST *ast, + const QString &replacement) { - replace(startOf(ast), endOf(ast), replacement); + Q_ASSERT(changeSet); + + const int start = startOf(ast); + changeSet->replace(start, endOf(ast) - start, replacement); } -void CppQuickFixOperation::remove(unsigned tokenIndex) +void CppQuickFixOperation::remove(ChangeSet *changeSet, unsigned tokenIndex) { + Q_ASSERT(changeSet); + int start, end; startAndEndOf(tokenIndex, &start, &end); - remove(start, end); + changeSet->remove(start, end - start); } -void CppQuickFixOperation::remove(const CPlusPlus::AST *ast) +void CppQuickFixOperation::remove(ChangeSet *changeSet, const CPlusPlus::AST *ast) { - remove(startOf(ast), endOf(ast)); + Q_ASSERT(changeSet); + + const int start = startOf(ast); + changeSet->remove(start, endOf(ast) - start); } -void CppQuickFixOperation::flip(const CPlusPlus::AST *ast1, const CPlusPlus::AST *ast2) +void CppQuickFixOperation::flip(ChangeSet *changeSet, + const CPlusPlus::AST *ast1, + const CPlusPlus::AST *ast2) { - flip(startOf(ast1), endOf(ast1), startOf(ast2), endOf(ast2)); + Q_ASSERT(changeSet); + + const int start1 = startOf(ast1); + const int start2 = startOf(ast2); + changeSet->flip(start1, endOf(ast1) - start1, + start2, endOf(ast2) - start2); } -void CppQuickFixOperation::copy(unsigned tokenIndex, int to) +void CppQuickFixOperation::copy(ChangeSet *changeSet, unsigned tokenIndex, + int to) { + Q_ASSERT(changeSet); + int start, end; startAndEndOf(tokenIndex, &start, &end); - copy(start, end, to); + changeSet->copy(start, end - start, to); } -void CppQuickFixOperation::copy(const CPlusPlus::AST *ast, int to) +void CppQuickFixOperation::copy(ChangeSet *changeSet, const CPlusPlus::AST *ast, + int to) { - copy(startOf(ast), endOf(ast), to); + Q_ASSERT(changeSet); + + const int start = startOf(ast); + changeSet->copy(start, endOf(ast) - start, to); } QString CppQuickFixOperation::textOf(const AST *ast) const diff --git a/src/plugins/cppeditor/cppquickfix.h b/src/plugins/cppeditor/cppquickfix.h index a16562523a7113461acad17d0a9af11420fa9d49..28e11b545173ef69bf673cee1aaabb4773366e8f 100644 --- a/src/plugins/cppeditor/cppquickfix.h +++ b/src/plugins/cppeditor/cppquickfix.h @@ -65,13 +65,12 @@ public: virtual int match(TextEditor::QuickFixState *state); protected: + QString fileName() const; + virtual void apply(); virtual CppTools::CppRefactoringChanges *cppRefactoringChanges() const; virtual TextEditor::RefactoringChanges *refactoringChanges() const; - CPlusPlus::AST *topLevelNode() const; - void setTopLevelNode(CPlusPlus::AST *topLevelNode); - const CPlusPlus::Token &tokenAt(unsigned index) const; int startOf(unsigned index) const; @@ -83,25 +82,21 @@ protected: bool isCursorOn(unsigned tokenIndex) const; bool isCursorOn(const CPlusPlus::AST *ast) const; - 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; - void move(unsigned tokenIndex, int to); - void move(const CPlusPlus::AST *ast, int to); - void replace(unsigned tokenIndex, const QString &replacement); - void replace(const CPlusPlus::AST *ast, const QString &replacement); - void remove(unsigned tokenIndex); - void remove(const CPlusPlus::AST *ast); - void flip(const CPlusPlus::AST *ast1, const CPlusPlus::AST *ast2); - void copy(unsigned tokenIndex, int to); - void copy(const CPlusPlus::AST *ast, int to); + void move(Utils::ChangeSet *changeSet, unsigned tokenIndex, int to); + void move(Utils::ChangeSet *changeSet, const CPlusPlus::AST *ast, int to); + void replace(Utils::ChangeSet *changeSet, unsigned tokenIndex, + const QString &replacement); + void replace(Utils::ChangeSet *changeSet, const CPlusPlus::AST *ast, + const QString &replacement); + void remove(Utils::ChangeSet *changeSet, unsigned tokenIndex); + void remove(Utils::ChangeSet *changeSet, const CPlusPlus::AST *ast); + void flip(Utils::ChangeSet *changeSet, const CPlusPlus::AST *ast1, + const CPlusPlus::AST *ast2); + void copy(Utils::ChangeSet *changeSet, unsigned tokenIndex, int to); + void copy(Utils::ChangeSet *changeSet, const CPlusPlus::AST *ast, int to); QString textOf(const CPlusPlus::AST *ast) const; diff --git a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp index 38c0a0abd14c5d05d338054fc14248add9104e9b..83225bb2c0edc40f280b97a3299f86289877959c 100644 --- a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp +++ b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp @@ -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() diff --git a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.h b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.h index 5957f4e5a7836bf42ff86985b67f0fc3f8fa3f2b..382e51c7f06fa93f815e6808edb4bfd1793b0d46 100644 --- a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.h +++ b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.h @@ -41,7 +41,7 @@ public: ComponentFromObjectDef(TextEditor::BaseTextEditor *editor); virtual QString description() const; - virtual void createChangeSet(); + virtual void createChanges(); virtual int check(); private: diff --git a/src/plugins/qmljseditor/qmljsquickfix.cpp b/src/plugins/qmljseditor/qmljsquickfix.cpp index d64cee547e9d24c9d45a31bf7540cbdb0251112a..437a5b244cdb0f5e8116516f90f258a0359066f0 100644 --- a/src/plugins/qmljseditor/qmljsquickfix.cpp +++ b/src/plugins/qmljseditor/qmljsquickfix.cpp @@ -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(); diff --git a/src/plugins/qmljseditor/qmljsquickfix.h b/src/plugins/qmljseditor/qmljsquickfix.h index 302f9c666d2c31e6663e74d45a16f04fb5e42b4c..a2cf4f52ea5940f7eab013961090899fae6a33ae 100644 --- a/src/plugins/qmljseditor/qmljsquickfix.h +++ b/src/plugins/qmljseditor/qmljsquickfix.h @@ -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; diff --git a/src/plugins/texteditor/quickfix.cpp b/src/plugins/texteditor/quickfix.cpp index 8e65cd4fbf76048cd31f8e0d2f0332d1dda79786..974a4fa2a97894f12cdef5931f9e327ad760f819 100644 --- a/src/plugins/texteditor/quickfix.cpp +++ b/src/plugins/texteditor/quickfix.cpp @@ -81,43 +81,6 @@ int QuickFixOperation::position(int line, int column) const return doc->findBlockByNumber(line - 1).position() + column - 1; } -void QuickFixOperation::reindent(const RefactoringChanges::Range &range) -{ - if (! range.isNull()) { - refactoringChanges()->reindent(editor()->file()->fileName(), range); - } -} - -void QuickFixOperation::move(int start, int end, int to) -{ - _changeSet.move(start, end-start, to); -} - -void QuickFixOperation::replace(int start, int end, const QString &replacement) -{ - _changeSet.replace(start, end-start, replacement); -} - -void QuickFixOperation::insert(int at, const QString &text) -{ - _changeSet.insert(at, text); -} - -void QuickFixOperation::remove(int start, int end) -{ - _changeSet.remove(start, end-start); -} - -void QuickFixOperation::flip(int start1, int end1, int start2, int end2) -{ - _changeSet.flip(start1, end1-start1, start2, end2-start2); -} - -void QuickFixOperation::copy(int start, int end, int to) -{ - _changeSet.copy(start, end-start, to); -} - QChar QuickFixOperation::charAt(int offset) const { QTextDocument *doc = _textCursor.document(); @@ -139,11 +102,7 @@ TextEditor::RefactoringChanges::Range QuickFixOperation::range(int start, int en void QuickFixOperation::perform() { - createChangeSet(); - - if (!_changeSet.isEmpty()) - refactoringChanges()->changeFile(editor()->file()->fileName(), _changeSet); - + createChanges(); apply(); } diff --git a/src/plugins/texteditor/quickfix.h b/src/plugins/texteditor/quickfix.h index 413fb1a08fad29f81811879305ede62c615f46a3..aec71790231558fa90c988a63da529ca99c59dab 100644 --- a/src/plugins/texteditor/quickfix.h +++ b/src/plugins/texteditor/quickfix.h @@ -65,7 +65,7 @@ public: virtual ~QuickFixOperation(); virtual QString description() const = 0; - virtual void createChangeSet() = 0; + virtual void createChanges() = 0; virtual int match(QuickFixState *state) = 0; @@ -76,20 +76,11 @@ public: QTextCursor textCursor() const; void setTextCursor(const QTextCursor &cursor); - void reindent(const TextEditor::RefactoringChanges::Range &range); - int selectionStart() const; int selectionEnd() const; int position(int line, int column) const; - void move(int start, int end, int to); - void replace(int start, int end, const QString &replacement); - void insert(int at, const QString &text); - void remove(int start, int end); - void flip(int start1, int end1, int start2, int end2); - void copy(int start, int end, int to); - QChar charAt(int offset) const; QString textOf(int start, int end) const; @@ -102,7 +93,6 @@ protected: private: TextEditor::BaseTextEditor *_editor; QTextCursor _textCursor; - Utils::ChangeSet _changeSet; };