forked from qt-creator/qt-creator
Unify Utils::ChangeSet usages
* Remove using Utils::ChangeSet from header files * Remove unused typedef for Range * Add it only in source files that contain many occurrences Change-Id: I60a8b77e2d5a46431507f53b6d60186d511ccf30 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
c5012f258c
commit
04e8b332bb
@@ -298,7 +298,7 @@ void FunctionDeclDefLink::apply(CPPEditorWidget *editor, bool jumpToMatch)
|
|||||||
const int targetStart = newTargetFile->position(targetLine, targetColumn);
|
const int targetStart = newTargetFile->position(targetLine, targetColumn);
|
||||||
const int targetEnd = targetStart + targetInitial.size();
|
const int targetEnd = targetStart + targetInitial.size();
|
||||||
if (targetInitial == newTargetFile->textOf(targetStart, targetEnd)) {
|
if (targetInitial == newTargetFile->textOf(targetStart, targetEnd)) {
|
||||||
const ChangeSet changeset = changes(snapshot, targetStart);
|
const Utils::ChangeSet changeset = changes(snapshot, targetStart);
|
||||||
newTargetFile->setChangeSet(changeset);
|
newTargetFile->setChangeSet(changeset);
|
||||||
if (jumpToMatch) {
|
if (jumpToMatch) {
|
||||||
const int jumpTarget = newTargetFile->position(targetFunction->line(), targetFunction->column());
|
const int jumpTarget = newTargetFile->position(targetFunction->line(), targetFunction->column());
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ using namespace CppEditor;
|
|||||||
using namespace CppEditor::Internal;
|
using namespace CppEditor::Internal;
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
|
using Utils::ChangeSet;
|
||||||
|
|
||||||
void CppEditor::Internal::registerQuickFixes(ExtensionSystem::IPlugin *plugIn)
|
void CppEditor::Internal::registerQuickFixes(ExtensionSystem::IPlugin *plugIn)
|
||||||
{
|
{
|
||||||
@@ -4216,7 +4217,7 @@ public:
|
|||||||
toFile->apply();
|
toFile->apply();
|
||||||
|
|
||||||
// remove definition from fromFile
|
// remove definition from fromFile
|
||||||
Utils::ChangeSet headerTarget;
|
ChangeSet headerTarget;
|
||||||
if (m_type == MoveOutsideMemberToCppFile) {
|
if (m_type == MoveOutsideMemberToCppFile) {
|
||||||
headerTarget.remove(fromFile->range(m_funcDef));
|
headerTarget.remove(fromFile->range(m_funcDef));
|
||||||
} else {
|
} else {
|
||||||
@@ -4330,7 +4331,7 @@ public:
|
|||||||
fromFile->endOf(m_funcAST->function_body));
|
fromFile->endOf(m_funcAST->function_body));
|
||||||
|
|
||||||
// Replace declaration with function and delete old definition
|
// Replace declaration with function and delete old definition
|
||||||
Utils::ChangeSet toTarget;
|
ChangeSet toTarget;
|
||||||
toTarget.replace(m_toRange, wholeFunctionText);
|
toTarget.replace(m_toRange, wholeFunctionText);
|
||||||
if (m_toFileName == m_fromFileName)
|
if (m_toFileName == m_fromFileName)
|
||||||
toTarget.remove(fromRange);
|
toTarget.remove(fromRange);
|
||||||
@@ -4339,7 +4340,7 @@ public:
|
|||||||
toFile->setOpenEditor(true, m_toRange.start);
|
toFile->setOpenEditor(true, m_toRange.start);
|
||||||
toFile->apply();
|
toFile->apply();
|
||||||
if (m_toFileName != m_fromFileName) {
|
if (m_toFileName != m_fromFileName) {
|
||||||
Utils::ChangeSet fromTarget;
|
ChangeSet fromTarget;
|
||||||
fromTarget.remove(fromRange);
|
fromTarget.remove(fromRange);
|
||||||
fromFile->setChangeSet(fromTarget);
|
fromFile->setChangeSet(fromTarget);
|
||||||
fromFile->apply();
|
fromFile->apply();
|
||||||
|
|||||||
@@ -382,8 +382,8 @@ void PointerDeclarationFormatter::checkAndRewrite(DeclaratorAST *declarator,
|
|||||||
for (unsigned token = tokenRange.start; token <= tokenRange.end; ++token)
|
for (unsigned token = tokenRange.start; token <= tokenRange.end; ++token)
|
||||||
CHECK_R(!tokenAt(token).expanded(), "Token is expanded");
|
CHECK_R(!tokenAt(token).expanded(), "Token is expanded");
|
||||||
|
|
||||||
Range range(m_cppRefactoringFile->startOf(tokenRange.start),
|
Utils::ChangeSet::Range range(m_cppRefactoringFile->startOf(tokenRange.start),
|
||||||
m_cppRefactoringFile->endOf(tokenRange.end));
|
m_cppRefactoringFile->endOf(tokenRange.end));
|
||||||
|
|
||||||
CHECK_R(range.start >= 0 && range.end > 0, "ChangeRange invalid1");
|
CHECK_R(range.start >= 0 && range.end > 0, "ChangeRange invalid1");
|
||||||
CHECK_R(range.start < range.end, "ChangeRange invalid2");
|
CHECK_R(range.start < range.end, "ChangeRange invalid2");
|
||||||
@@ -446,7 +446,7 @@ void PointerDeclarationFormatter::checkAndRewrite(DeclaratorAST *declarator,
|
|||||||
// original source. It tries to create an replacement operation
|
// original source. It tries to create an replacement operation
|
||||||
// at this position and fails due to overlapping ranges (the
|
// at this position and fails due to overlapping ranges (the
|
||||||
// simple declaration range includes parameter declaration range).
|
// simple declaration range includes parameter declaration range).
|
||||||
ChangeSet change(m_changeSet);
|
Utils::ChangeSet change(m_changeSet);
|
||||||
if (change.replace(range, rewrittenDeclaration))
|
if (change.replace(range, rewrittenDeclaration))
|
||||||
m_changeSet = change;
|
m_changeSet = change;
|
||||||
else if (DEBUG_OUTPUT)
|
else if (DEBUG_OUTPUT)
|
||||||
|
|||||||
@@ -39,9 +39,6 @@ namespace CppTools {
|
|||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
using Utils::ChangeSet;
|
|
||||||
|
|
||||||
typedef Utils::ChangeSet::Range Range;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class CppTools::PointerDeclarationFormatter
|
\class CppTools::PointerDeclarationFormatter
|
||||||
@@ -85,7 +82,7 @@ public:
|
|||||||
Returns a ChangeSet for applying the formatting changes.
|
Returns a ChangeSet for applying the formatting changes.
|
||||||
The ChangeSet is empty if it was not possible to rewrite anything.
|
The ChangeSet is empty if it was not possible to rewrite anything.
|
||||||
*/
|
*/
|
||||||
ChangeSet format(AST *ast)
|
Utils::ChangeSet format(AST *ast)
|
||||||
{
|
{
|
||||||
if (ast)
|
if (ast)
|
||||||
accept(ast);
|
accept(ast);
|
||||||
@@ -119,7 +116,7 @@ private:
|
|||||||
Overview &m_overview;
|
Overview &m_overview;
|
||||||
const CursorHandling m_cursorHandling;
|
const CursorHandling m_cursorHandling;
|
||||||
|
|
||||||
ChangeSet m_changeSet;
|
Utils::ChangeSet m_changeSet;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|||||||
@@ -48,14 +48,10 @@ using namespace CPlusPlus;
|
|||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
using namespace CppTools::Internal;
|
using namespace CppTools::Internal;
|
||||||
|
|
||||||
using Utils::ChangeSet;
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Overview)
|
Q_DECLARE_METATYPE(Overview)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
typedef Utils::ChangeSet::Range Range;
|
|
||||||
|
|
||||||
QString stripCursor(const QString &source)
|
QString stripCursor(const QString &source)
|
||||||
{
|
{
|
||||||
QString copy(source);
|
QString copy(source);
|
||||||
@@ -127,7 +123,7 @@ public:
|
|||||||
|
|
||||||
// Run the formatter
|
// Run the formatter
|
||||||
PointerDeclarationFormatter formatter(cppRefactoringFile, overview, cursorHandling);
|
PointerDeclarationFormatter formatter(cppRefactoringFile, overview, cursorHandling);
|
||||||
ChangeSet change = formatter.format(ast); // ChangeSet may be empty.
|
Utils::ChangeSet change = formatter.format(ast); // ChangeSet may be empty.
|
||||||
|
|
||||||
// Apply change
|
// Apply change
|
||||||
QTextCursor changeCursor(textDocument);
|
QTextCursor changeCursor(textDocument);
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
|
|
||||||
using namespace CPlusPlus;
|
using namespace CPlusPlus;
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
using namespace Utils;
|
|
||||||
|
|
||||||
class CppTools::CppRefactoringChangesData : public TextEditor::RefactoringChangesData
|
class CppTools::CppRefactoringChangesData : public TextEditor::RefactoringChangesData
|
||||||
{
|
{
|
||||||
@@ -195,18 +194,18 @@ bool CppRefactoringFile::isCursorOn(const AST *ast) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
|
Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
|
||||||
{
|
{
|
||||||
const Token &token = tokenAt(tokenIndex);
|
const Token &token = tokenAt(tokenIndex);
|
||||||
unsigned line, column;
|
unsigned line, column;
|
||||||
cppDocument()->translationUnit()->getPosition(token.utf16charsBegin(), &line, &column);
|
cppDocument()->translationUnit()->getPosition(token.utf16charsBegin(), &line, &column);
|
||||||
const int start = document()->findBlockByNumber(line - 1).position() + column - 1;
|
const int start = document()->findBlockByNumber(line - 1).position() + column - 1;
|
||||||
return ChangeSet::Range(start, start + token.utf16chars());
|
return Utils::ChangeSet::Range(start, start + token.utf16chars());
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeSet::Range CppRefactoringFile::range(AST *ast) const
|
Utils::ChangeSet::Range CppRefactoringFile::range(AST *ast) const
|
||||||
{
|
{
|
||||||
return ChangeSet::Range(startOf(ast), endOf(ast));
|
return Utils::ChangeSet::Range(startOf(ast), endOf(ast));
|
||||||
}
|
}
|
||||||
|
|
||||||
int CppRefactoringFile::startOf(unsigned index) const
|
int CppRefactoringFile::startOf(unsigned index) const
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
class LineColumnLabel;
|
class LineColumnLabel;
|
||||||
class ChangeSet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
//TESTED_COMPONENT=src/utils/changeset
|
//TESTED_COMPONENT=src/utils/changeset
|
||||||
|
|
||||||
|
using Utils::ChangeSet;
|
||||||
|
|
||||||
class tst_ChangeSet : public QObject
|
class tst_ChangeSet : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -53,35 +55,35 @@ private slots:
|
|||||||
void tst_ChangeSet::singleReplace()
|
void tst_ChangeSet::singleReplace()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.replace(0, 2, "ghi"));
|
QVERIFY(cs.replace(0, 2, "ghi"));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("ghicdef"));
|
QCOMPARE(test, QLatin1String("ghicdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.replace(4, 6, "ghi"));
|
QVERIFY(cs.replace(4, 6, "ghi"));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdghi"));
|
QCOMPARE(test, QLatin1String("abcdghi"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.replace(3, 3, "ghi"));
|
QVERIFY(cs.replace(3, 3, "ghi"));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcghidef"));
|
QCOMPARE(test, QLatin1String("abcghidef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.replace(0, 6, ""));
|
QVERIFY(cs.replace(0, 6, ""));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String(""));
|
QCOMPARE(test, QLatin1String(""));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.replace(3, 13, "ghi"));
|
QVERIFY(cs.replace(3, 13, "ghi"));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
@@ -92,35 +94,35 @@ void tst_ChangeSet::singleReplace()
|
|||||||
void tst_ChangeSet::singleMove()
|
void tst_ChangeSet::singleMove()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.move(0, 2, 4));
|
QVERIFY(cs.move(0, 2, 4));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("cdabef"));
|
QCOMPARE(test, QLatin1String("cdabef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.move(4, 6, 0));
|
QVERIFY(cs.move(4, 6, 0));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("efabcd"));
|
QCOMPARE(test, QLatin1String("efabcd"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.move(3, 13, 0));
|
QVERIFY(cs.move(3, 13, 0));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("defabc"));
|
QCOMPARE(test, QLatin1String("defabc"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.move(3, 3, 0));
|
QVERIFY(cs.move(3, 3, 0));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdef"));
|
QCOMPARE(test, QLatin1String("abcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.move(0, 1, 10));
|
QVERIFY(cs.move(0, 1, 10));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
@@ -132,28 +134,28 @@ void tst_ChangeSet::singleMove()
|
|||||||
void tst_ChangeSet::singleInsert()
|
void tst_ChangeSet::singleInsert()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.insert(0, "ghi"));
|
QVERIFY(cs.insert(0, "ghi"));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("ghiabcdef"));
|
QCOMPARE(test, QLatin1String("ghiabcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.insert(6, "ghi"));
|
QVERIFY(cs.insert(6, "ghi"));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdefghi"));
|
QCOMPARE(test, QLatin1String("abcdefghi"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.insert(3, ""));
|
QVERIFY(cs.insert(3, ""));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdef"));
|
QCOMPARE(test, QLatin1String("abcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.insert(7, "g"));
|
QVERIFY(cs.insert(7, "g"));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
@@ -165,35 +167,35 @@ void tst_ChangeSet::singleInsert()
|
|||||||
void tst_ChangeSet::singleRemove()
|
void tst_ChangeSet::singleRemove()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.remove(0, 1));
|
QVERIFY(cs.remove(0, 1));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("bcdef"));
|
QCOMPARE(test, QLatin1String("bcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.remove(3, 6));
|
QVERIFY(cs.remove(3, 6));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abc"));
|
QCOMPARE(test, QLatin1String("abc"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.remove(4, 14));
|
QVERIFY(cs.remove(4, 14));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcd"));
|
QCOMPARE(test, QLatin1String("abcd"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.remove(2, 2));
|
QVERIFY(cs.remove(2, 2));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdef"));
|
QCOMPARE(test, QLatin1String("abcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.remove(7, 8));
|
QVERIFY(cs.remove(7, 8));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
@@ -204,42 +206,42 @@ void tst_ChangeSet::singleRemove()
|
|||||||
void tst_ChangeSet::singleFlip()
|
void tst_ChangeSet::singleFlip()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.flip(0, 2, 3, 6));
|
QVERIFY(cs.flip(0, 2, 3, 6));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("defcab"));
|
QCOMPARE(test, QLatin1String("defcab"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.flip(1, 3, 3, 4));
|
QVERIFY(cs.flip(1, 3, 3, 4));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("adbcef"));
|
QCOMPARE(test, QLatin1String("adbcef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.flip(3, 3, 4, 4));
|
QVERIFY(cs.flip(3, 3, 4, 4));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdef"));
|
QCOMPARE(test, QLatin1String("abcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.flip(3, 3, 4, 5));
|
QVERIFY(cs.flip(3, 3, 4, 5));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcedf"));
|
QCOMPARE(test, QLatin1String("abcedf"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.flip(0, 6, 6, 12));
|
QVERIFY(cs.flip(0, 6, 6, 12));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdef"));
|
QCOMPARE(test, QLatin1String("abcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.flip(0, 6, 7, 10));
|
QVERIFY(cs.flip(0, 6, 7, 10));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
@@ -247,29 +249,29 @@ void tst_ChangeSet::singleFlip()
|
|||||||
QCOMPARE(test, QLatin1String(""));
|
QCOMPARE(test, QLatin1String(""));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QCOMPARE(cs.flip(0, 3, 1, 4), false);
|
QCOMPARE(cs.flip(0, 3, 1, 4), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QCOMPARE(cs.flip(0, 3, 2, 5), false);
|
QCOMPARE(cs.flip(0, 3, 2, 5), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.flip(0, 3, 0, 0));
|
QVERIFY(cs.flip(0, 3, 0, 0));
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdef"));
|
QCOMPARE(test, QLatin1String("abcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.flip(0, 0, 0, 3));
|
QVERIFY(cs.flip(0, 0, 0, 3));
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdef"));
|
QCOMPARE(test, QLatin1String("abcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.flip(0, 3, 3, 3));
|
QVERIFY(cs.flip(0, 3, 3, 3));
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
@@ -280,35 +282,35 @@ void tst_ChangeSet::singleFlip()
|
|||||||
void tst_ChangeSet::singleCopy()
|
void tst_ChangeSet::singleCopy()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.copy(0, 2, 4));
|
QVERIFY(cs.copy(0, 2, 4));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdabef"));
|
QCOMPARE(test, QLatin1String("abcdabef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.copy(1, 3, 3));
|
QVERIFY(cs.copy(1, 3, 3));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcbcdef"));
|
QCOMPARE(test, QLatin1String("abcbcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.copy(3, 3, 4));
|
QVERIFY(cs.copy(3, 3, 4));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdef"));
|
QCOMPARE(test, QLatin1String("abcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.copy(0, 6, 6));
|
QVERIFY(cs.copy(0, 6, 6));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcdefabcdef"));
|
QCOMPARE(test, QLatin1String("abcdefabcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
QVERIFY(cs.copy(0, 6, 7));
|
QVERIFY(cs.copy(0, 6, 7));
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
@@ -316,22 +318,22 @@ void tst_ChangeSet::singleCopy()
|
|||||||
QCOMPARE(test, QLatin1String("abcdef"));
|
QCOMPARE(test, QLatin1String("abcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QCOMPARE(cs.copy(0, 3, 1), false);
|
QCOMPARE(cs.copy(0, 3, 1), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QCOMPARE(cs.copy(0, 3, 2), false);
|
QCOMPARE(cs.copy(0, 3, 2), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.copy(0, 3, 0));
|
QVERIFY(cs.copy(0, 3, 0));
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
QCOMPARE(test, QLatin1String("abcabcdef"));
|
QCOMPARE(test, QLatin1String("abcabcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.copy(0, 3, 3));
|
QVERIFY(cs.copy(0, 3, 3));
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
cs.apply(&test);
|
cs.apply(&test);
|
||||||
@@ -342,7 +344,7 @@ void tst_ChangeSet::singleCopy()
|
|||||||
void tst_ChangeSet::doubleInsert()
|
void tst_ChangeSet::doubleInsert()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.insert(1, "01"));
|
QVERIFY(cs.insert(1, "01"));
|
||||||
QVERIFY(cs.insert(1, "234"));
|
QVERIFY(cs.insert(1, "234"));
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
@@ -350,7 +352,7 @@ void tst_ChangeSet::doubleInsert()
|
|||||||
QCOMPARE(test, QLatin1String("a01234bcdef"));
|
QCOMPARE(test, QLatin1String("a01234bcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.insert(1, "234"));
|
QVERIFY(cs.insert(1, "234"));
|
||||||
QVERIFY(cs.insert(1, "01"));
|
QVERIFY(cs.insert(1, "01"));
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
@@ -358,7 +360,7 @@ void tst_ChangeSet::doubleInsert()
|
|||||||
QCOMPARE(test, QLatin1String("a23401bcdef"));
|
QCOMPARE(test, QLatin1String("a23401bcdef"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.insert(1, "01"));
|
QVERIFY(cs.insert(1, "01"));
|
||||||
QVERIFY(cs.remove(1, 2));
|
QVERIFY(cs.remove(1, 2));
|
||||||
QVERIFY(cs.insert(2, "234"));
|
QVERIFY(cs.insert(2, "234"));
|
||||||
@@ -371,48 +373,48 @@ void tst_ChangeSet::doubleInsert()
|
|||||||
void tst_ChangeSet::conflicts()
|
void tst_ChangeSet::conflicts()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QCOMPARE(cs.replace(0, 2, "abc"), false);
|
QCOMPARE(cs.replace(0, 2, "abc"), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QCOMPARE(cs.replace(1, 4, "abc"), false);
|
QCOMPARE(cs.replace(1, 4, "abc"), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QCOMPARE(cs.replace(1, 2, "abc"), false);
|
QCOMPARE(cs.replace(1, 2, "abc"), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QCOMPARE(cs.replace(2, 2, "abc"), false);
|
QCOMPARE(cs.replace(2, 2, "abc"), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QCOMPARE(cs.replace(2, 3, "abc"), false);
|
QCOMPARE(cs.replace(2, 3, "abc"), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QCOMPARE(cs.replace(3, 3, "abc"), false);
|
QCOMPARE(cs.replace(3, 3, "abc"), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QCOMPARE(cs.replace(3, 4, "abc"), false);
|
QCOMPARE(cs.replace(3, 4, "abc"), false);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QCOMPARE(cs.replace(4, 6, "abc"), false);
|
QCOMPARE(cs.replace(4, 6, "abc"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QVERIFY(cs.replace(0, 1, "bla"));
|
QVERIFY(cs.replace(0, 1, "bla"));
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
@@ -420,7 +422,7 @@ void tst_ChangeSet::conflicts()
|
|||||||
QCOMPARE(test, QLatin1String("blaebcdf"));
|
QCOMPARE(test, QLatin1String("blaebcdf"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QVERIFY(cs.replace(4, 5, "bla"));
|
QVERIFY(cs.replace(4, 5, "bla"));
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
@@ -428,7 +430,7 @@ void tst_ChangeSet::conflicts()
|
|||||||
QCOMPARE(test, QLatin1String("ablabcdf"));
|
QCOMPARE(test, QLatin1String("ablabcdf"));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
Utils::ChangeSet cs;
|
ChangeSet cs;
|
||||||
QVERIFY(cs.move(1, 4, 5));
|
QVERIFY(cs.move(1, 4, 5));
|
||||||
QVERIFY(cs.replace(5, 6, "bla"));
|
QVERIFY(cs.replace(5, 6, "bla"));
|
||||||
QString test("abcdef");
|
QString test("abcdef");
|
||||||
|
|||||||
Reference in New Issue
Block a user