use of org.eclipse.text.edits.ReplaceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testOverlap5.
@Test
public void testOverlap5() throws Exception {
// [ [] ]
fRoot.addChild(new ReplaceEdit(0, 3, "012"));
boolean exception = false;
try {
fRoot.addChild(new InsertEdit(1, "xx"));
} 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 testMoveTree1.
@Test
public void testMoveTree1() {
TextEdit root = new MultiTextEdit();
TextEdit e1 = new ReplaceEdit(0, 1, "");
root.addChild(e1);
TextEdit e2 = new ReplaceEdit(2, 2, "");
root.addChild(e2);
root.moveTree(3);
Assert.assertEquals(3, root.getOffset());
Assert.assertEquals(4, root.getLength());
Assert.assertEquals(3, e1.getOffset());
Assert.assertEquals(1, e1.getLength());
Assert.assertEquals(5, e2.getOffset());
Assert.assertEquals(2, e2.getLength());
}
use of org.eclipse.text.edits.ReplaceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testInsert3.
@Test
public void testInsert3() throws Exception {
// [ ][][ ]
TextEdit e1 = new ReplaceEdit(0, 2, "011");
TextEdit e2 = new InsertEdit(2, "xx");
TextEdit e3 = new ReplaceEdit(2, 2, "2");
fRoot.addChild(e1);
fRoot.addChild(e2);
fRoot.addChild(e3);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(fRoot, 0, 6);
assertEquals(e1, 0, 3);
assertEquals(e2, 3, 2);
assertEquals(e3, 5, 1);
Assert.assertEquals("Buffer content", "011xx2456789", fDocument.get());
doUndoRedo(undo, "011xx2456789");
}
use of org.eclipse.text.edits.ReplaceEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testOverlap3.
@Test
public void testOverlap3() throws Exception {
// [ [ ]]
fRoot.addChild(new ReplaceEdit(0, 2, "01"));
boolean exception = false;
try {
fRoot.addChild(new ReplaceEdit(1, 1, "1"));
} 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 testMoveDownWithInnerMark.
@Test
public void testMoveDownWithInnerMark() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(2, 2);
MoveTargetEdit t1 = new MoveTargetEdit(7, 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", "01yy5623789", fDocument.get());
assertEquals(s1, 2, 0);
assertEquals(t1, 6, 2);
assertEquals(m, 2, 2);
doUndoRedo(undo, "01yy5623789");
}
Aggregations