Search in sources :

Example 51 with UndoEdit

use of org.eclipse.text.edits.UndoEdit 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 52 with UndoEdit

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

the class TextEditTests method testInsert2.

@Test
public void testInsert2() throws Exception {
    // [][]
    TextEdit e1 = new InsertEdit(2, "yy");
    TextEdit e2 = new InsertEdit(2, "xx");
    fRoot.addChild(e1);
    fRoot.addChild(e2);
    UndoEdit undo = fRoot.apply(fDocument);
    assertEquals(fRoot, 2, 4);
    assertEquals(e1, 2, 2);
    assertEquals(e2, 4, 2);
    Assert.assertEquals("Buffer content", "01yyxx23456789", fDocument.get());
    doUndoRedo(undo, "01yyxx23456789");
}
Also used : InsertEdit(org.eclipse.text.edits.InsertEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Example 53 with UndoEdit

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

UndoEdit (org.eclipse.text.edits.UndoEdit)53 Test (org.junit.Test)40 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)25 TextEdit (org.eclipse.text.edits.TextEdit)25 MoveSourceEdit (org.eclipse.text.edits.MoveSourceEdit)23 MoveTargetEdit (org.eclipse.text.edits.MoveTargetEdit)23 InsertEdit (org.eclipse.text.edits.InsertEdit)12 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)12 BadLocationException (org.eclipse.jface.text.BadLocationException)10 DeleteEdit (org.eclipse.text.edits.DeleteEdit)9 RangeMarker (org.eclipse.text.edits.RangeMarker)8 ITextFileBufferManager (org.eclipse.core.filebuffers.ITextFileBufferManager)6 CopySourceEdit (org.eclipse.text.edits.CopySourceEdit)6 CopyTargetEdit (org.eclipse.text.edits.CopyTargetEdit)6 MalformedTreeException (org.eclipse.text.edits.MalformedTreeException)5 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)4 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)4 IDocument (org.eclipse.jface.text.IDocument)4 Lock (org.eclipse.ltk.internal.core.refactoring.Lock)3 LinkedList (java.util.LinkedList)2