Search in sources :

Example 31 with MoveTargetEdit

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

the class TextEditTests method testMoveWithRangeMarker.

@Test
public void testMoveWithRangeMarker() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(2, 2);
    MoveTargetEdit t1 = new MoveTargetEdit(5, s1);
    RangeMarker marker = new RangeMarker(2, 2);
    s1.addChild(marker);
    fRoot.addChild(s1);
    fRoot.addChild(t1);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "0142356789", fDocument.get());
    assertEquals(s1, 2, 0);
    assertEquals(t1, 3, 2);
    assertEquals(marker, 3, 2);
    doUndoRedo(undo, "0142356789");
}
Also used : MoveTargetEdit(org.eclipse.text.edits.MoveTargetEdit) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit) RangeMarker(org.eclipse.text.edits.RangeMarker) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Example 32 with MoveTargetEdit

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

the class TextEditTests method testMove4.

@Test
public void testMove4() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(7, 2);
    MoveTargetEdit t1 = new MoveTargetEdit(2, s1);
    TextEdit e2 = new ReplaceEdit(5, 1, "x");
    fRoot.addChild(s1);
    fRoot.addChild(t1);
    fRoot.addChild(e2);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "0178234x69", fDocument.get());
    assertEquals(s1, 9, 0);
    assertEquals(t1, 2, 2);
    assertEquals(e2, 7, 1);
    doUndoRedo(undo, "0178234x69");
}
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