use of org.eclipse.text.edits.ISourceModifier 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.ISourceModifier 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.ISourceModifier 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);
}
use of org.eclipse.text.edits.ISourceModifier 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