use of org.eclipse.text.edits.MoveSourceEdit 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");
}
use of org.eclipse.text.edits.MoveSourceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMoveUpWithInnerMark.
@Test
public void testMoveUpWithInnerMark() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(7, 2);
MoveTargetEdit t1 = new MoveTargetEdit(2, s1);
TextEdit m = new ReplaceEdit(4, 1, "yy");
fRoot.addChild(t1);
fRoot.addChild(m);
fRoot.addChild(s1);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer content", "017823yy569", fDocument.get());
assertEquals(s1, 10, 0);
assertEquals(t1, 2, 2);
assertEquals(m, 6, 2);
doUndoRedo(undo, "017823yy569");
}
use of org.eclipse.text.edits.MoveSourceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMoveWithTargetDelete.
@Test
public void testMoveWithTargetDelete() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(2, 3);
MoveTargetEdit t1 = new MoveTargetEdit(7, s1);
TextEdit e2 = new DeleteEdit(6, 2);
e2.addChild(t1);
fRoot.addChild(s1);
fRoot.addChild(e2);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer content", "01589", fDocument.get());
assertEquals(s1, 2, 0);
assertTrue(t1.isDeleted());
assertEquals(e2, 3, 0);
doUndoRedo(undo, "01589");
}
use of org.eclipse.text.edits.MoveSourceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testOverlap9.
@Test
public void testOverlap9() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(3, 1);
MoveTargetEdit t1 = new MoveTargetEdit(7, s1);
MoveSourceEdit s2 = new MoveSourceEdit(2, 3);
MoveTargetEdit t2 = new MoveTargetEdit(8, s2);
fRoot.addChild(s1);
fRoot.addChild(t1);
boolean exception = false;
try {
fRoot.addChild(s2);
fRoot.addChild(t2);
} catch (MalformedTreeException e) {
exception = true;
}
assertTrue(exception);
}
use of org.eclipse.text.edits.MoveSourceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMove5.
@Test
public void testMove5() throws Exception {
// Move onto itself
MoveSourceEdit s1 = new MoveSourceEdit(2, 1);
MoveTargetEdit t1 = new MoveTargetEdit(3, s1);
TextEdit e2 = new ReplaceEdit(2, 1, "x");
s1.addChild(e2);
fRoot.addChild(s1);
fRoot.addChild(t1);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(s1, 2, 0);
assertEquals(t1, 2, 1);
assertEquals(e2, 2, 1);
Assert.assertEquals("Buffer content", "01x3456789", fDocument.get());
doUndoRedo(undo, "01x3456789");
}
Aggregations