use of org.eclipse.text.edits.CopyTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testNestedCopySource.
@Test
public void testNestedCopySource() throws Exception {
CopySourceEdit s1 = new CopySourceEdit(1, 5);
CopySourceEdit s2 = new CopySourceEdit(2, 3);
CopySourceEdit s3 = new CopySourceEdit(3, 1);
s1.addChild(s2);
s2.addChild(s3);
CopyTargetEdit t1 = new CopyTargetEdit(9, s1);
CopyTargetEdit t2 = new CopyTargetEdit(8, s2);
CopyTargetEdit t3 = new CopyTargetEdit(7, s3);
fRoot.addChild(s1);
fRoot.addChild(t1);
fRoot.addChild(t2);
fRoot.addChild(t3);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(s1, 1, 5);
assertEquals(s2, 2, 3);
assertEquals(s3, 3, 1);
assertEquals(t1, 13, 5);
assertEquals(t2, 9, 3);
assertEquals(t3, 7, 1);
String result = "0123456372348123459";
Assert.assertEquals("Buffer content", result, fDocument.get());
doUndoRedo(undo, result);
}
use of org.eclipse.text.edits.CopyTargetEdit 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.CopyTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testDoubleCopy.
@Test
public void testDoubleCopy() throws Exception {
CopySourceEdit s1 = new CopySourceEdit(5, 2);
CopyTargetEdit t1 = new CopyTargetEdit(8, s1);
CopySourceEdit s2 = new CopySourceEdit(5, 2);
CopyTargetEdit t2 = new CopyTargetEdit(2, s2);
s1.addChild(s2);
fRoot.addChild(s1);
fRoot.addChild(t1);
fRoot.addChild(t2);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(s1, 7, 2);
assertEquals(t1, 10, 2);
assertEquals(s2, 7, 2);
assertEquals(t2, 2, 2);
String result = "01562345675689";
Assert.assertEquals("Buffer content", result, fDocument.get());
doUndoRedo(undo, result);
}
use of org.eclipse.text.edits.CopyTargetEdit 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());
}
use of org.eclipse.text.edits.CopyTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testCopyDown.
@Test
public void testCopyDown() throws Exception {
CopySourceEdit s1 = new CopySourceEdit(2, 3);
CopyTargetEdit t1 = new CopyTargetEdit(8, s1);
fRoot.addChild(s1);
fRoot.addChild(t1);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(s1, 2, 3);
assertEquals(t1, 8, 3);
String result = "0123456723489";
Assert.assertEquals("Buffer content", result, fDocument.get());
doUndoRedo(undo, result);
}
Aggregations