use of org.eclipse.text.edits.TextEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testInsert5.
@Test
public void testInsert5() throws Exception {
TextEdit e1 = new InsertEdit(10, "xx");
fRoot.addChild(e1);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer length", 12, fDocument.getLength());
assertEquals(fRoot, 10, 2);
assertEquals(e1, 10, 2);
Assert.assertEquals("Buffer content", "0123456789xx", fDocument.get());
doUndoRedo(undo, "0123456789xx");
}
use of org.eclipse.text.edits.TextEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMoveUpWithSourceDelete.
@Test
public void testMoveUpWithSourceDelete() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(5, 2);
MoveTargetEdit t1 = new MoveTargetEdit(2, s1);
TextEdit d1 = new DeleteEdit(5, 2);
d1.addChild(s1);
RangeMarker marker = new RangeMarker(5, 2);
s1.addChild(marker);
fRoot.addChild(d1);
fRoot.addChild(t1);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer content", "0156234789", fDocument.get());
assertEquals(t1, 2, 2);
assertEquals(marker, 2, 2);
assertTrue(s1.isDeleted());
assertEquals(d1, 7, 0);
doUndoRedo(undo, "0156234789");
}
use of org.eclipse.text.edits.TextEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMove8.
@Test
public void testMove8() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(5, 3);
MoveTargetEdit t1 = new MoveTargetEdit(1, s1);
TextEdit e2 = new ReplaceEdit(6, 1, "x");
s1.addChild(e2);
fRoot.addChild(s1);
fRoot.addChild(t1);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer content", "05x7123489", fDocument.get());
assertEquals(s1, 8, 0);
assertEquals(t1, 1, 3);
assertEquals(e2, 2, 1);
doUndoRedo(undo, "05x7123489");
}
use of org.eclipse.text.edits.TextEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testDelete3.
@Test
public void testDelete3() throws Exception {
TextEdit e1 = new InsertEdit(3, "x");
TextEdit e2 = new DeleteEdit(3, 1);
fRoot.addChild(e1);
fRoot.addChild(e2);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(fRoot, 3, 1);
assertEquals(e1, 3, 1);
assertEquals(e2, 4, 0);
Assert.assertEquals("Buffer content", "012x456789", fDocument.get());
doUndoRedo(undo, "012x456789");
}
use of org.eclipse.text.edits.TextEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMove3.
@Test
public void testMove3() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(2, 2);
MoveTargetEdit t1 = new MoveTargetEdit(7, s1);
TextEdit e2 = new ReplaceEdit(4, 1, "x");
fRoot.addChild(s1);
fRoot.addChild(t1);
fRoot.addChild(e2);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer content", "01x5623789", fDocument.get());
assertEquals(s1, 2, 0);
assertEquals(t1, 5, 2);
assertEquals(e2, 2, 1);
doUndoRedo(undo, "01x5623789");
}
Aggregations