Search in sources :

Example 46 with MultiTextEdit

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

the class TextEditTests method testMoveTree4.

@Test
public void testMoveTree4() {
    boolean exception = false;
    try {
        TextEdit root = new MultiTextEdit();
        TextEdit e1 = new ReplaceEdit(0, 1, "");
        root.addChild(e1);
        e1.moveTree(1);
    } catch (Exception e) {
        exception = true;
    }
    assertTrue(exception);
}
Also used : MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) MalformedTreeException(org.eclipse.text.edits.MalformedTreeException) Test(org.junit.Test)

Example 47 with MultiTextEdit

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

the class TextEditTests method testCopy2.

@Test
public void testCopy2() throws Exception {
    MultiTextEdit root = new MultiTextEdit();
    CopySourceEdit s1 = new CopySourceEdit(5, 2);
    CopyTargetEdit t1 = new CopyTargetEdit(8, s1);
    CopySourceEdit s2 = new CopySourceEdit(5, 2);
    CopyTargetEdit t2 = new CopyTargetEdit(2, s2);
    s1.addChild(s2);
    root.addChild(s1);
    root.addChild(t1);
    root.addChild(t2);
    List<TextEdit> org = flatten(root);
    TextEditCopier copier = new TextEditCopier(root);
    List<TextEdit> copy = flatten(copier.perform());
    compare(org, copy);
}
Also used : TextEditCopier(org.eclipse.text.edits.TextEditCopier) CopySourceEdit(org.eclipse.text.edits.CopySourceEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) CopyTargetEdit(org.eclipse.text.edits.CopyTargetEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) Test(org.junit.Test)

Example 48 with MultiTextEdit

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

the class TextEditTests method testCovers2.

@Test
public void testCovers2() throws Exception {
    MultiTextEdit multi = new MultiTextEdit(0, 0);
    MultiTextEdit child = new MultiTextEdit(0, 0);
    Assert.assertEquals(true, multi.covers(child));
}
Also used : MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) Test(org.junit.Test)

Example 49 with MultiTextEdit

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

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

the class TextEditTests method testBufferLength.

@Test
public void testBufferLength() throws Exception {
    MultiTextEdit edit = new MultiTextEdit(0, fDocument.getLength() + 1);
    boolean exception = false;
    try {
        fRoot.addChild(edit);
        fRoot.apply(fDocument);
    } catch (MalformedTreeException e) {
        exception = true;
        assertTrue(exception);
    }
}
Also used : MalformedTreeException(org.eclipse.text.edits.MalformedTreeException) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) Test(org.junit.Test)

Aggregations

MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)51 TextEdit (org.eclipse.text.edits.TextEdit)33 Test (org.junit.Test)18 IDocument (org.eclipse.jface.text.IDocument)13 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)13 Document (org.eclipse.jface.text.Document)11 TextEditGroup (org.eclipse.text.edits.TextEditGroup)10 CompilationUnitChange (org.eclipse.jdt.core.refactoring.CompilationUnitChange)9 DeleteEdit (org.eclipse.text.edits.DeleteEdit)7 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)6 ArrayList (java.util.ArrayList)5 MalformedTreeException (org.eclipse.text.edits.MalformedTreeException)5 HashSet (java.util.HashSet)4 List (java.util.List)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)4 ASTNode (org.eclipse.jdt.core.dom.ASTNode)4 TextChange (org.eclipse.ltk.core.refactoring.TextChange)4 CopySourceEdit (org.eclipse.text.edits.CopySourceEdit)4 TextEditCopier (org.eclipse.text.edits.TextEditCopier)4