Search in sources :

Example 6 with DeleteEdit

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

the class TextEditTests method testMoveUp.

@Test
public void testMoveUp() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(7, 2);
    MoveTargetEdit t1 = new MoveTargetEdit(2, s1);
    TextEdit i1 = new InsertEdit(5, "x");
    TextEdit d1 = new DeleteEdit(9, 1);
    RangeMarker m1 = new RangeMarker(7, 2);
    s1.addChild(m1);
    fRoot.addChild(s1);
    fRoot.addChild(i1);
    fRoot.addChild(t1);
    fRoot.addChild(d1);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "0178234x56", fDocument.get());
    assertEquals(s1, 10, 0);
    assertEquals(i1, 7, 1);
    assertEquals(t1, 2, 2);
    assertEquals(m1, 2, 2);
    assertEquals(d1, 10, 0);
    doUndoRedo(undo, "0178234x56");
}
Also used : MoveTargetEdit(org.eclipse.text.edits.MoveTargetEdit) InsertEdit(org.eclipse.text.edits.InsertEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit) RangeMarker(org.eclipse.text.edits.RangeMarker) DeleteEdit(org.eclipse.text.edits.DeleteEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Example 7 with DeleteEdit

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

the class TextEditTests method testDeleteWithChildren.

@Test
public void testDeleteWithChildren() throws Exception {
    TextEdit e1 = new DeleteEdit(2, 6);
    MultiTextEdit e2 = new MultiTextEdit(3, 3);
    e1.addChild(e2);
    TextEdit e3 = new ReplaceEdit(3, 1, "xx");
    TextEdit e4 = new ReplaceEdit(5, 1, "yy");
    e2.addChild(e3);
    e2.addChild(e4);
    fRoot.addChild(e1);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "0189", fDocument.get());
    assertEquals(fRoot, 2, 0);
    assertEquals(e1, 2, 0);
    assertTrue(e2.isDeleted());
    assertTrue(e3.isDeleted());
    assertTrue(e4.isDeleted());
    doUndoRedo(undo, "0189");
}
Also used : MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) DeleteEdit(org.eclipse.text.edits.DeleteEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) Test(org.junit.Test)

Example 8 with DeleteEdit

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

the class TextEditTests method testMoveDown.

@Test
public void testMoveDown() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(2, 2);
    TextEdit i1 = new InsertEdit(5, "x");
    MoveTargetEdit t1 = new MoveTargetEdit(7, s1);
    TextEdit d1 = new DeleteEdit(9, 1);
    RangeMarker m1 = new RangeMarker(2, 2);
    s1.addChild(m1);
    fRoot.addChild(s1);
    fRoot.addChild(i1);
    fRoot.addChild(t1);
    fRoot.addChild(d1);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "014x562378", fDocument.get());
    assertEquals(s1, 2, 0);
    assertEquals(i1, 3, 1);
    assertEquals(t1, 6, 2);
    assertEquals(m1, 6, 2);
    assertEquals(d1, 10, 0);
    doUndoRedo(undo, "014x562378");
}
Also used : InsertEdit(org.eclipse.text.edits.InsertEdit) MoveTargetEdit(org.eclipse.text.edits.MoveTargetEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit) RangeMarker(org.eclipse.text.edits.RangeMarker) DeleteEdit(org.eclipse.text.edits.DeleteEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Example 9 with DeleteEdit

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

the class TextEditTests method testMoveDownWithSourceDelete.

@Test
public void testMoveDownWithSourceDelete() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(2, 2);
    MoveTargetEdit t1 = new MoveTargetEdit(7, s1);
    TextEdit d1 = new DeleteEdit(2, 2);
    d1.addChild(s1);
    RangeMarker m1 = new RangeMarker(2, 2);
    s1.addChild(m1);
    fRoot.addChild(t1);
    fRoot.addChild(d1);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "0145623789", fDocument.get());
    assertEquals(d1, 2, 0);
    assertTrue(s1.isDeleted());
    assertEquals(t1, 5, 2);
    assertEquals(m1, 5, 2);
    doUndoRedo(undo, "0145623789");
}
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) RangeMarker(org.eclipse.text.edits.RangeMarker) DeleteEdit(org.eclipse.text.edits.DeleteEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Example 10 with DeleteEdit

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

the class TextEditTests method testMoveUpWithSourceDelete.

@Test
public void testMoveUpWithSourceDelete() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(5, 2);
    MoveTargetEdit t1 = new MoveTargetEdit(2, s1);
    TextEdit d1 = new DeleteEdit(5, 2);
    d1.addChild(s1);
    RangeMarker marker = new RangeMarker(5, 2);
    s1.addChild(marker);
    fRoot.addChild(d1);
    fRoot.addChild(t1);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "0156234789", fDocument.get());
    assertEquals(t1, 2, 2);
    assertEquals(marker, 2, 2);
    assertTrue(s1.isDeleted());
    assertEquals(d1, 7, 0);
    doUndoRedo(undo, "0156234789");
}
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) RangeMarker(org.eclipse.text.edits.RangeMarker) DeleteEdit(org.eclipse.text.edits.DeleteEdit) UndoEdit(org.eclipse.text.edits.UndoEdit) Test(org.junit.Test)

Aggregations

DeleteEdit (org.eclipse.text.edits.DeleteEdit)40 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)26 InsertEdit (org.eclipse.text.edits.InsertEdit)20 TextEdit (org.eclipse.text.edits.TextEdit)17 Test (org.junit.Test)15 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)11 UndoEdit (org.eclipse.text.edits.UndoEdit)10 IRegion (org.eclipse.jface.text.IRegion)6 MoveSourceEdit (org.eclipse.text.edits.MoveSourceEdit)6 MoveTargetEdit (org.eclipse.text.edits.MoveTargetEdit)6 ArrayList (java.util.ArrayList)5 IDocument (org.eclipse.jface.text.IDocument)5 HashSet (java.util.HashSet)4 BadLocationException (org.eclipse.jface.text.BadLocationException)4 RangeMarker (org.eclipse.text.edits.RangeMarker)4 Location (org.eclipse.titan.designer.AST.Location)4 Module (org.eclipse.titan.designer.AST.Module)4 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)3 Document (org.eclipse.jface.text.Document)3 MalformedTreeException (org.eclipse.text.edits.MalformedTreeException)3