use of org.eclipse.text.edits.InsertEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testCovers1.
@Test
public void testCovers1() throws Exception {
InsertEdit insert = new InsertEdit(1, "");
DeleteEdit delete = new DeleteEdit(2, 2);
Assert.assertEquals(false, insert.covers(delete));
}
use of org.eclipse.text.edits.InsertEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testNestedMoveSourceWithInsert.
@Test
public void testNestedMoveSourceWithInsert() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(1, 5);
MoveSourceEdit s2 = new MoveSourceEdit(2, 3);
MoveSourceEdit s3 = new MoveSourceEdit(3, 1);
InsertEdit i1 = new InsertEdit(4, "x");
s1.addChild(s2);
s2.addChild(s3);
s3.addChild(i1);
MoveTargetEdit t1 = new MoveTargetEdit(9, s1);
MoveTargetEdit t2 = new MoveTargetEdit(8, s2);
MoveTargetEdit t3 = new MoveTargetEdit(7, s3);
fRoot.addChild(s1);
fRoot.addChild(t1);
fRoot.addChild(t2);
fRoot.addChild(t3);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(s1, 1, 0);
assertEquals(s2, 9, 0);
assertEquals(s3, 6, 0);
assertEquals(i1, 3, 1);
assertEquals(t1, 8, 2);
assertEquals(t2, 5, 2);
assertEquals(t3, 2, 2);
String result = "063x7248159";
Assert.assertEquals("Buffer content", result, fDocument.get());
doUndoRedo(undo, result);
}
use of org.eclipse.text.edits.InsertEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testUndefinedMultiEdit1.
@Test
public void testUndefinedMultiEdit1() throws Exception {
MultiTextEdit m1 = new MultiTextEdit();
m1.addChild(new InsertEdit(0, ""));
fRoot.addChild(m1);
MultiTextEdit m2 = new MultiTextEdit();
m2.addChild(new InsertEdit(2, ""));
fRoot.addChild(m2);
}
use of org.eclipse.text.edits.InsertEdit 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.InsertEdit 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);
}
Aggregations