use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testSourceTranformationSplit2.
@Test
public void testSourceTranformationSplit2() 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(2, 2, "aa") };
}
});
fRoot.apply(fDocument);
String result = "0167823aa9";
Assert.assertEquals("Buffer content", result, fDocument.get());
assertEquals(r1, 6, 3);
}
use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testOverlap7.
@Test
public void testOverlap7() throws Exception {
MoveSourceEdit source = new MoveSourceEdit(2, 5);
MoveTargetEdit target = new MoveTargetEdit(3, source);
fRoot.addChild(source);
boolean exception = false;
try {
fRoot.addChild(target);
} catch (MalformedTreeException e) {
exception = true;
}
assertTrue(exception);
}
use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testMoveUp.
@Test
public void testMoveUp() throws Exception {
MoveSourceEdit s1 = new MoveSourceEdit(7, 2);
MoveTargetEdit t1 = new MoveTargetEdit(2, s1);
TextEdit i1 = new InsertEdit(5, "x");
TextEdit d1 = new DeleteEdit(9, 1);
RangeMarker m1 = new RangeMarker(7, 2);
s1.addChild(m1);
fRoot.addChild(s1);
fRoot.addChild(i1);
fRoot.addChild(t1);
fRoot.addChild(d1);
UndoEdit undo = fRoot.apply(fDocument);
Assert.assertEquals("Buffer content", "0178234x56", fDocument.get());
assertEquals(s1, 10, 0);
assertEquals(i1, 7, 1);
assertEquals(t1, 2, 2);
assertEquals(m1, 2, 2);
assertEquals(d1, 10, 0);
doUndoRedo(undo, "0178234x56");
}
use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testSourceTranformationMultipleCovers.
// Regression test for 108672 [quick fix] Exception when applying Convert to enhanced for loop
@Test
public void testSourceTranformationMultipleCovers() 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, 0);
ms.addChild(r1);
RangeMarker r2 = new RangeMarker(3, 0);
ms.addChild(r2);
RangeMarker r3 = new RangeMarker(4, 2);
ms.addChild(r3);
ms.setSourceModifier(new ISourceModifier() {
@Override
public ISourceModifier copy() {
return this;
}
@Override
public ReplaceEdit[] getModifications(String source) {
return new ReplaceEdit[] { new ReplaceEdit(0, 2, "aa") };
}
});
fRoot.apply(fDocument);
String result = "01678aa459";
Assert.assertEquals("Buffer content", result, fDocument.get());
assertTrue(r1.isDeleted());
assertTrue(r2.isDeleted());
assertEquals(r3, 7, 2);
}
use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testSourceTranformationSplit1.
@Test
public void testSourceTranformationSplit1() 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(0, 2, "aa") };
}
});
fRoot.apply(fDocument);
String result = "01678aa459";
Assert.assertEquals("Buffer content", result, fDocument.get());
assertEquals(r1, 7, 1);
}
Aggregations