Search in sources :

Example 11 with MoveTargetEdit

use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.

the class TextEditTests method testNestedMoveTarget.

@Test
public void testNestedMoveTarget() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(1, 2);
    MoveSourceEdit s2 = new MoveSourceEdit(5, 3);
    MoveTargetEdit t1 = new MoveTargetEdit(6, s1);
    MoveTargetEdit t2 = new MoveTargetEdit(9, s2);
    s2.addChild(t1);
    fRoot.addChild(s1);
    fRoot.addChild(s2);
    fRoot.addChild(t2);
    UndoEdit undo = fRoot.apply(fDocument);
    assertEquals(s1, 1, 0);
    assertEquals(s2, 3, 0);
    assertEquals(t1, 5, 2);
    assertEquals(t2, 4, 5);
    String result = "0348512679";
    Assert.assertEquals("Buffer content", result, fDocument.get());
    doUndoRedo(undo, result);
}
Also used : MoveTargetEdit(org.eclipse.text.edits.MoveTargetEdit) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Example 12 with MoveTargetEdit

use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.

the class TextEditTests method testMove8.

@Test
public void testMove8() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(5, 3);
    MoveTargetEdit t1 = new MoveTargetEdit(1, s1);
    TextEdit e2 = new ReplaceEdit(6, 1, "x");
    s1.addChild(e2);
    fRoot.addChild(s1);
    fRoot.addChild(t1);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "05x7123489", fDocument.get());
    assertEquals(s1, 8, 0);
    assertEquals(t1, 1, 3);
    assertEquals(e2, 2, 1);
    doUndoRedo(undo, "05x7123489");
}
Also used : MoveTargetEdit(org.eclipse.text.edits.MoveTargetEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Example 13 with MoveTargetEdit

use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.

the class TextEditTests method testOverlap8.

@Test
public void testOverlap8() throws Exception {
    MoveSourceEdit source = new MoveSourceEdit(2, 5);
    MoveTargetEdit target = new MoveTargetEdit(6, source);
    fRoot.addChild(source);
    boolean exception = false;
    try {
        fRoot.addChild(target);
    } catch (MalformedTreeException e) {
        exception = true;
    }
    assertTrue(exception);
}
Also used : MoveTargetEdit(org.eclipse.text.edits.MoveTargetEdit) MalformedTreeException(org.eclipse.text.edits.MalformedTreeException) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit) Test(org.junit.Test)

Example 14 with MoveTargetEdit

use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.

the class TextEditTests method testMove10.

@Test
public void testMove10() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(2, 2);
    MoveTargetEdit t1 = new MoveTargetEdit(8, s1);
    MoveSourceEdit s2 = new MoveSourceEdit(5, 2);
    MoveTargetEdit t2 = new MoveTargetEdit(1, s2);
    fRoot.addChild(s1);
    fRoot.addChild(t1);
    fRoot.addChild(s2);
    fRoot.addChild(t2);
    UndoEdit undo = fRoot.apply(fDocument);
    assertEquals(s1, 4, 0);
    assertEquals(t1, 6, 2);
    assertEquals(s2, 5, 0);
    assertEquals(t2, 1, 2);
    Assert.assertEquals("Buffer content", "0561472389", fDocument.get());
    doUndoRedo(undo, "0561472389");
}
Also used : MoveTargetEdit(org.eclipse.text.edits.MoveTargetEdit) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Example 15 with MoveTargetEdit

use of org.eclipse.text.edits.MoveTargetEdit in project eclipse.platform.text by eclipse.

the class TextEditTests method testMove3.

@Test
public void testMove3() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(2, 2);
    MoveTargetEdit t1 = new MoveTargetEdit(7, s1);
    TextEdit e2 = new ReplaceEdit(4, 1, "x");
    fRoot.addChild(s1);
    fRoot.addChild(t1);
    fRoot.addChild(e2);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "01x5623789", fDocument.get());
    assertEquals(s1, 2, 0);
    assertEquals(t1, 5, 2);
    assertEquals(e2, 2, 1);
    doUndoRedo(undo, "01x5623789");
}
Also used : MoveTargetEdit(org.eclipse.text.edits.MoveTargetEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Aggregations

MoveSourceEdit (org.eclipse.text.edits.MoveSourceEdit)32 MoveTargetEdit (org.eclipse.text.edits.MoveTargetEdit)32 Test (org.junit.Test)30 UndoEdit (org.eclipse.text.edits.UndoEdit)23 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)15 TextEdit (org.eclipse.text.edits.TextEdit)15 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)13 RangeMarker (org.eclipse.text.edits.RangeMarker)11 DeleteEdit (org.eclipse.text.edits.DeleteEdit)6 ISourceModifier (org.eclipse.text.edits.ISourceModifier)4 InsertEdit (org.eclipse.text.edits.InsertEdit)4 MalformedTreeException (org.eclipse.text.edits.MalformedTreeException)3 CopySourceEdit (org.eclipse.text.edits.CopySourceEdit)2 CopyTargetEdit (org.eclipse.text.edits.CopyTargetEdit)2