use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMove9.
@Test
public void testMove9() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(1, 3);
MoveTargetEdit t1 = new MoveTargetEdit(5, s1);
MoveSourceEdit s2 = new MoveSourceEdit(1, 1);
MoveTargetEdit t2 = new MoveTargetEdit(3, s2);
s1.addChild(s2);
s1.addChild(t2);
fRoot.addChild(s1);
fRoot.addChild(t1);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(s1, 1, 0);
assertEquals(t1, 2, 3);
assertEquals(s2, 2, 0);
assertEquals(t2, 3, 1);
Assert.assertEquals("Buffer content", "0421356789", fDocument.get());
doUndoRedo(undo, "0421356789");
}
use of org.eclipse.text.edits.MoveTargetEdit 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");
}
use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMoveUpWithParentMark.
@Test
public void testMoveUpWithParentMark() throws Exception {
RangeMarker m = new RangeMarker(2, 6);
MoveSourceEdit s1 = new MoveSourceEdit(4, 2);
MoveTargetEdit t1 = new MoveTargetEdit(3, s1);
m.addChild(s1);
m.addChild(t1);
fRoot.addChild(m);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer content", "0124536789", fDocument.get());
assertEquals(m, 2, 6);
assertEquals(t1, 3, 2);
assertEquals(s1, 6, 0);
doUndoRedo(undo, "0124536789");
}
use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testNestedMoveSource.
@Test
public void testNestedMoveSource() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(1, 5);
MoveSourceEdit s2 = new MoveSourceEdit(2, 3);
MoveSourceEdit s3 = new MoveSourceEdit(3, 1);
s1.addChild(s2);
s2.addChild(s3);
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, 8, 0);
assertEquals(s3, 5, 0);
assertEquals(t1, 7, 2);
assertEquals(t2, 4, 2);
assertEquals(t3, 2, 1);
String result = "0637248159";
Assert.assertEquals("Buffer content", result, fDocument.get());
doUndoRedo(undo, result);
}
use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testSourceTransformationIncludes.
@Test
public void testSourceTransformationIncludes() throws Exception {
MoveSourceEdit ms = new MoveSourceEdit(2, 4);
MoveTargetEdit mt = new MoveTargetEdit(9, ms);
fRoot.addChild(ms);
fRoot.addChild(mt);
RangeMarker r1 = new RangeMarker(3, 2);
ms.addChild(r1);
ms.setSourceModifier(new ISourceModifier() {
@Override
public ISourceModifier copy() {
return this;
}
@Override
public ReplaceEdit[] getModifications(String source) {
return new ReplaceEdit[] { new ReplaceEdit(1, 1, "aa") };
}
});
fRoot.apply(fDocument);
String result = "016782aa459";
Assert.assertEquals("Buffer content", result, fDocument.get());
assertEquals(r1, 6, 3);
}
Aggregations