Search in sources :

Example 11 with CopyTargetEdit

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()));
        }
    }
}
Also used : MoveTargetEdit(org.eclipse.text.edits.MoveTargetEdit) CopySourceEdit(org.eclipse.text.edits.CopySourceEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) CopyTargetEdit(org.eclipse.text.edits.CopyTargetEdit) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit)

Example 12 with CopyTargetEdit

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);
}
Also used : CopySourceEdit(org.eclipse.text.edits.CopySourceEdit) CopyTargetEdit(org.eclipse.text.edits.CopyTargetEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Aggregations

CopySourceEdit (org.eclipse.text.edits.CopySourceEdit)12 CopyTargetEdit (org.eclipse.text.edits.CopyTargetEdit)12 Test (org.junit.Test)10 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)6 TextEdit (org.eclipse.text.edits.TextEdit)6 UndoEdit (org.eclipse.text.edits.UndoEdit)6 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)4 Document (org.eclipse.jface.text.Document)3 IDocument (org.eclipse.jface.text.IDocument)3 InsertEdit (org.eclipse.text.edits.InsertEdit)2 MoveSourceEdit (org.eclipse.text.edits.MoveSourceEdit)2 MoveTargetEdit (org.eclipse.text.edits.MoveTargetEdit)2 DeleteEdit (org.eclipse.text.edits.DeleteEdit)1 TextEditCopier (org.eclipse.text.edits.TextEditCopier)1