use of org.eclipse.text.edits.UndoEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMove2.
@Test
public void testMove2() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(5, 2);
MoveTargetEdit t1 = new MoveTargetEdit(2, s1);
fRoot.addChild(s1);
fRoot.addChild(t1);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer content", "0156234789", fDocument.get());
assertEquals(s1, 7, 0);
assertEquals(t1, 2, 2);
doUndoRedo(undo, "0156234789");
}
use of org.eclipse.text.edits.UndoEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMove1.
@Test
public void testMove1() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(2, 2);
MoveTargetEdit t1 = new MoveTargetEdit(5, s1);
fRoot.addChild(s1);
fRoot.addChild(t1);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer content", "0142356789", fDocument.get());
assertEquals(s1, 2, 0);
assertEquals(t1, 3, 2);
doUndoRedo(undo, "0142356789");
}
use of org.eclipse.text.edits.UndoEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testInsert4.
@Test
public void testInsert4() throws Exception {
TextEdit e1 = new InsertEdit(0, "xx");
fRoot.addChild(e1);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer length", 12, fDocument.getLength());
assertEquals(fRoot, 0, 2);
assertEquals(e1, 0, 2);
Assert.assertEquals("Buffer content", "xx0123456789", fDocument.get());
doUndoRedo(undo, "xx0123456789");
}
use of org.eclipse.text.edits.UndoEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testCopyUp.
@Test
public void testCopyUp() throws Exception {
CopySourceEdit s1 = new CopySourceEdit(7, 2);
CopyTargetEdit t1 = new CopyTargetEdit(3, s1);
fRoot.addChild(s1);
fRoot.addChild(t1);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(s1, 9, 2);
assertEquals(t1, 3, 2);
String result = "012783456789";
Assert.assertEquals("Buffer content", result, fDocument.get());
doUndoRedo(undo, result);
}
use of org.eclipse.text.edits.UndoEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method doUndoRedo.
private void doUndoRedo(UndoEdit undo, String redoResult) throws Exception {
UndoEdit redo = undo.apply(fDocument);
assertBufferContent();
undo = redo.apply(fDocument);
Assert.assertEquals("Buffer content redo", redoResult, fDocument.get());
undo.apply(fDocument);
assertBufferContent();
}
Aggregations