use of org.eclipse.text.edits.ReplaceEdit 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");
}
use of org.eclipse.text.edits.ReplaceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMoveTree4.
@Test
public void testMoveTree4() {
boolean exception = false;
try {
TextEdit root = new MultiTextEdit();
TextEdit e1 = new ReplaceEdit(0, 1, "");
root.addChild(e1);
e1.moveTree(1);
} catch (Exception e) {
exception = true;
}
assertTrue(exception);
}
use of org.eclipse.text.edits.ReplaceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testOverlap2.
@Test
public void testOverlap2() throws Exception {
// [[ ] ]
fRoot.addChild(new ReplaceEdit(0, 2, "01"));
boolean exception = false;
try {
fRoot.addChild(new ReplaceEdit(0, 1, "0"));
} catch (MalformedTreeException e) {
exception = true;
}
assertTrue(exception);
}
use of org.eclipse.text.edits.ReplaceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMove6.
@Test
public void testMove6() throws Exception {
// Move onto itself
MoveSourceEdit s1 = new MoveSourceEdit(2, 1);
MoveTargetEdit t1 = new MoveTargetEdit(2, s1);
TextEdit e2 = new ReplaceEdit(2, 1, "x");
s1.addChild(e2);
fRoot.addChild(s1);
fRoot.addChild(t1);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(s1, 3, 0);
assertEquals(t1, 2, 1);
assertEquals(e2, 2, 1);
Assert.assertEquals("Buffer content", "01x3456789", fDocument.get());
doUndoRedo(undo, "01x3456789");
}
use of org.eclipse.text.edits.ReplaceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testOverlap4.
@Test
public void testOverlap4() throws Exception {
// [ [ ] ]
fRoot.addChild(new ReplaceEdit(0, 3, "012"));
boolean exception = false;
try {
fRoot.addChild(new ReplaceEdit(1, 1, "1"));
} catch (MalformedTreeException e) {
exception = true;
}
assertTrue(exception);
}
Aggregations