use of org.eclipse.text.edits.CopyTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method compare.
private static void compare(List<TextEdit> org, List<TextEdit> copy) {
assertTrue("Same length", org.size() == copy.size());
for (Iterator<TextEdit> iter = copy.iterator(); iter.hasNext(); ) {
TextEdit edit = iter.next();
assertTrue("Original is part of copy list", !org.contains(edit));
if (edit instanceof MoveSourceEdit) {
MoveSourceEdit source = (MoveSourceEdit) edit;
assertTrue("Target edit isn't a copy", copy.contains(source.getTargetEdit()));
assertTrue("Traget edit is a original", !org.contains(source.getTargetEdit()));
} else if (edit instanceof MoveTargetEdit) {
MoveTargetEdit target = (MoveTargetEdit) edit;
assertTrue("Source edit isn't a copy", copy.contains(target.getSourceEdit()));
assertTrue("Source edit is a original", !org.contains(target.getSourceEdit()));
} else if (edit instanceof CopySourceEdit) {
CopySourceEdit source = (CopySourceEdit) edit;
assertTrue("Target edit isn't a copy", copy.contains(source.getTargetEdit()));
assertTrue("Traget edit is a original", !org.contains(source.getTargetEdit()));
} else if (edit instanceof CopyTargetEdit) {
CopyTargetEdit target = (CopyTargetEdit) edit;
assertTrue("Source edit isn't a copy", copy.contains(target.getSourceEdit()));
assertTrue("Source edit is a original", !org.contains(target.getSourceEdit()));
}
}
}
use of org.eclipse.text.edits.CopyTargetEdit in project eclipse.platform.text by eclipse.
the class TextEditTests method testCopyUp.
@Test
public void testCopyUp() throws Exception {
CopySourceEdit s1 = new CopySourceEdit(7, 2);
CopyTargetEdit t1 = new CopyTargetEdit(3, s1);
fRoot.addChild(s1);
fRoot.addChild(t1);
UndoEdit undo = fRoot.apply(fDocument);
assertEquals(s1, 9, 2);
assertEquals(t1, 3, 2);
String result = "012783456789";
Assert.assertEquals("Buffer content", result, fDocument.get());
doUndoRedo(undo, result);
}
Aggregations