use of org.eclipse.text.edits.MultiTextEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testUndefinedMultiEdit4.
@Test
public void testUndefinedMultiEdit4() throws Exception {
MultiTextEdit m2 = new MultiTextEdit();
m2.addChild(new DeleteEdit(1, 3));
m2.addChild(new DeleteEdit(4, 2));
Assert.assertEquals(1, m2.getOffset());
Assert.assertEquals(5, m2.getLength());
}
use of org.eclipse.text.edits.MultiTextEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testUndefinedMultiEdit3.
@Test
public void testUndefinedMultiEdit3() throws Exception {
MultiTextEdit m2 = new MultiTextEdit();
Assert.assertEquals(0, m2.getOffset());
Assert.assertEquals(0, m2.getLength());
m2.addChild(new DeleteEdit(1, 3));
Assert.assertEquals(1, m2.getOffset());
Assert.assertEquals(3, m2.getLength());
}
use of org.eclipse.text.edits.MultiTextEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMoveTree2.
@Test
public void testMoveTree2() {
TextEdit root = new MultiTextEdit();
TextEdit e1 = new ReplaceEdit(3, 1, "");
root.addChild(e1);
TextEdit e2 = new ReplaceEdit(5, 2, "");
root.addChild(e2);
root.moveTree(-3);
Assert.assertEquals(0, root.getOffset());
Assert.assertEquals(4, root.getLength());
Assert.assertEquals(0, e1.getOffset());
Assert.assertEquals(1, e1.getLength());
Assert.assertEquals(2, e2.getOffset());
Assert.assertEquals(2, e2.getLength());
}
use of org.eclipse.text.edits.MultiTextEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testSwap1.
@Test
public void testSwap1() throws Exception {
IDocument document = new Document("foo(1, 2), 3");
MultiTextEdit root = new MultiTextEdit();
{
CopySourceEdit innerRoot = new CopySourceEdit(0, 9);
TextEdit e1 = new ReplaceEdit(0, 9, "");
e1.addChild(innerRoot);
CopyTargetEdit t1 = new CopyTargetEdit(11, innerRoot);
TextEdit e2 = new ReplaceEdit(11, 1, "");
CopySourceEdit s2 = new CopySourceEdit(11, 1);
e2.addChild(s2);
CopyTargetEdit t2 = new CopyTargetEdit(0, s2);
root.addChild(e1);
root.addChild(t2);
root.addChild(e2);
root.addChild(t1);
}
root.apply(document);
String result = "3, foo(1, 2)";
Assert.assertEquals("Buffer content", result, document.get());
}
use of org.eclipse.text.edits.MultiTextEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testSwap2.
@Test
public void testSwap2() throws Exception {
IDocument document = new Document("foo(1, 2), 3");
MultiTextEdit root = new MultiTextEdit();
{
TextEdit e1 = new ReplaceEdit(4, 1, "");
CopySourceEdit s1 = new CopySourceEdit(4, 1);
e1.addChild(s1);
CopyTargetEdit t1 = new CopyTargetEdit(7, s1);
TextEdit e2 = new ReplaceEdit(7, 1, "");
CopySourceEdit s2 = new CopySourceEdit(7, 1);
e2.addChild(s2);
CopyTargetEdit t2 = new CopyTargetEdit(4, s2);
root.addChild(e1);
root.addChild(t2);
root.addChild(e2);
root.addChild(t1);
}
root.apply(document);
String result = "foo(2, 1), 3";
Assert.assertEquals("Buffer content", result, document.get());
}
Aggregations