Search in sources :

Example 41 with InsertEdit

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

the class TextEditTests method testCovers1.

@Test
public void testCovers1() throws Exception {
    InsertEdit insert = new InsertEdit(1, "");
    DeleteEdit delete = new DeleteEdit(2, 2);
    Assert.assertEquals(false, insert.covers(delete));
}
Also used : InsertEdit(org.eclipse.text.edits.InsertEdit) DeleteEdit(org.eclipse.text.edits.DeleteEdit) Test(org.junit.Test)

Example 42 with InsertEdit

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

the class TextEditTests method testNestedMoveSourceWithInsert.

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

Example 43 with InsertEdit

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

the class TextEditTests method testUndefinedMultiEdit1.

@Test
public void testUndefinedMultiEdit1() throws Exception {
    MultiTextEdit m1 = new MultiTextEdit();
    m1.addChild(new InsertEdit(0, ""));
    fRoot.addChild(m1);
    MultiTextEdit m2 = new MultiTextEdit();
    m2.addChild(new InsertEdit(2, ""));
    fRoot.addChild(m2);
}
Also used : InsertEdit(org.eclipse.text.edits.InsertEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) Test(org.junit.Test)

Example 44 with InsertEdit

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

the class TextEditTests method testInsert4.

@Test
public void testInsert4() throws Exception {
    TextEdit e1 = new InsertEdit(0, "xx");
    fRoot.addChild(e1);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer length", 12, fDocument.getLength());
    assertEquals(fRoot, 0, 2);
    assertEquals(e1, 0, 2);
    Assert.assertEquals("Buffer content", "xx0123456789", fDocument.get());
    doUndoRedo(undo, "xx0123456789");
}
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 45 with InsertEdit

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

the class TextEditTests method testOverlap5.

@Test
public void testOverlap5() throws Exception {
    // [ []  ]
    fRoot.addChild(new ReplaceEdit(0, 3, "012"));
    boolean exception = false;
    try {
        fRoot.addChild(new InsertEdit(1, "xx"));
    } catch (MalformedTreeException e) {
        exception = true;
    }
    assertTrue(exception);
}
Also used : InsertEdit(org.eclipse.text.edits.InsertEdit) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) MalformedTreeException(org.eclipse.text.edits.MalformedTreeException) Test(org.junit.Test)

Aggregations

InsertEdit (org.eclipse.text.edits.InsertEdit)73 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)33 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)25 TextEdit (org.eclipse.text.edits.TextEdit)24 DeleteEdit (org.eclipse.text.edits.DeleteEdit)22 Test (org.junit.Test)22 BadLocationException (org.eclipse.jface.text.BadLocationException)13 UndoEdit (org.eclipse.text.edits.UndoEdit)13 ArrayList (java.util.ArrayList)12 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)10 MalformedTreeException (org.eclipse.text.edits.MalformedTreeException)10 IDocument (org.eclipse.jface.text.IDocument)8 TextFileChange (org.eclipse.ltk.core.refactoring.TextFileChange)8 Location (org.eclipse.titan.designer.AST.Location)8 Module (org.eclipse.titan.designer.AST.Module)7 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)7 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)5 CoreException (org.eclipse.core.runtime.CoreException)5 IFile (org.eclipse.core.resources.IFile)4 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)4