Search in sources :

Example 16 with MoveSourceEdit

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

Example 17 with MoveSourceEdit

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

the class TextEditTests method testMoveUpWithInnerMark.

@Test
public void testMoveUpWithInnerMark() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(7, 2);
    MoveTargetEdit t1 = new MoveTargetEdit(2, s1);
    TextEdit m = new ReplaceEdit(4, 1, "yy");
    fRoot.addChild(t1);
    fRoot.addChild(m);
    fRoot.addChild(s1);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "017823yy569", fDocument.get());
    assertEquals(s1, 10, 0);
    assertEquals(t1, 2, 2);
    assertEquals(m, 6, 2);
    doUndoRedo(undo, "017823yy569");
}
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 18 with MoveSourceEdit

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

the class TextEditTests method testMoveWithTargetDelete.

@Test
public void testMoveWithTargetDelete() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(2, 3);
    MoveTargetEdit t1 = new MoveTargetEdit(7, s1);
    TextEdit e2 = new DeleteEdit(6, 2);
    e2.addChild(t1);
    fRoot.addChild(s1);
    fRoot.addChild(e2);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "01589", fDocument.get());
    assertEquals(s1, 2, 0);
    assertTrue(t1.isDeleted());
    assertEquals(e2, 3, 0);
    doUndoRedo(undo, "01589");
}
Also used : MoveTargetEdit(org.eclipse.text.edits.MoveTargetEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit) DeleteEdit(org.eclipse.text.edits.DeleteEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Example 19 with MoveSourceEdit

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

the class TextEditTests method testOverlap9.

@Test
public void testOverlap9() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(3, 1);
    MoveTargetEdit t1 = new MoveTargetEdit(7, s1);
    MoveSourceEdit s2 = new MoveSourceEdit(2, 3);
    MoveTargetEdit t2 = new MoveTargetEdit(8, s2);
    fRoot.addChild(s1);
    fRoot.addChild(t1);
    boolean exception = false;
    try {
        fRoot.addChild(s2);
        fRoot.addChild(t2);
    } 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 20 with MoveSourceEdit

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

the class TextEditTests method testMove5.

@Test
public void testMove5() throws Exception {
    // Move onto itself
    MoveSourceEdit s1 = new MoveSourceEdit(2, 1);
    MoveTargetEdit t1 = new MoveTargetEdit(3, s1);
    TextEdit e2 = new ReplaceEdit(2, 1, "x");
    s1.addChild(e2);
    fRoot.addChild(s1);
    fRoot.addChild(t1);
    UndoEdit undo = fRoot.apply(fDocument);
    assertEquals(s1, 2, 0);
    assertEquals(t1, 2, 1);
    assertEquals(e2, 2, 1);
    Assert.assertEquals("Buffer content", "01x3456789", fDocument.get());
    doUndoRedo(undo, "01x3456789");
}
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)31 Test (org.junit.Test)31 UndoEdit (org.eclipse.text.edits.UndoEdit)23 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)14 TextEdit (org.eclipse.text.edits.TextEdit)14 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)12 RangeMarker (org.eclipse.text.edits.RangeMarker)11 DeleteEdit (org.eclipse.text.edits.DeleteEdit)5 ISourceModifier (org.eclipse.text.edits.ISourceModifier)4 MalformedTreeException (org.eclipse.text.edits.MalformedTreeException)4 InsertEdit (org.eclipse.text.edits.InsertEdit)3 CopySourceEdit (org.eclipse.text.edits.CopySourceEdit)1 CopyTargetEdit (org.eclipse.text.edits.CopyTargetEdit)1