Search in sources :

Example 6 with MalformedTreeException

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

the class TextEditTests method testUnconnected1.

@Test
public void testUnconnected1() throws Exception {
    MoveSourceEdit s1 = new MoveSourceEdit(3, 1);
    boolean exception = false;
    try {
        fRoot.addChild(s1);
        fRoot.apply(fDocument);
    } catch (MalformedTreeException e) {
        exception = true;
    }
    assertTrue(exception);
}
Also used : MalformedTreeException(org.eclipse.text.edits.MalformedTreeException) MoveSourceEdit(org.eclipse.text.edits.MoveSourceEdit) Test(org.junit.Test)

Example 7 with MalformedTreeException

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

the class TextEditTests method testOverlap7.

@Test
public void testOverlap7() throws Exception {
    MoveSourceEdit source = new MoveSourceEdit(2, 5);
    MoveTargetEdit target = new MoveTargetEdit(3, source);
    fRoot.addChild(source);
    boolean exception = false;
    try {
        fRoot.addChild(target);
    } 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 8 with MalformedTreeException

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

the class TextEditTests method testOverlap8.

@Test
public void testOverlap8() throws Exception {
    MoveSourceEdit source = new MoveSourceEdit(2, 5);
    MoveTargetEdit target = new MoveTargetEdit(6, source);
    fRoot.addChild(source);
    boolean exception = false;
    try {
        fRoot.addChild(target);
    } 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 9 with MalformedTreeException

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

the class TextEditTests method testOverlap6.

@Test
public void testOverlap6() throws Exception {
    // [  [] ]
    fRoot.addChild(new ReplaceEdit(0, 3, "012"));
    boolean exception = false;
    try {
        fRoot.addChild(new InsertEdit(2, "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)

Example 10 with MalformedTreeException

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

Aggregations

MalformedTreeException (org.eclipse.text.edits.MalformedTreeException)52 BadLocationException (org.eclipse.jface.text.BadLocationException)38 IDocument (org.eclipse.jface.text.IDocument)25 TextEdit (org.eclipse.text.edits.TextEdit)19 CoreException (org.eclipse.core.runtime.CoreException)12 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)12 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)11 ASTRewrite (org.eclipse.jdt.core.dom.rewrite.ASTRewrite)11 Document (org.eclipse.jface.text.Document)11 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)11 Test (org.junit.Test)11 ITextFileBufferManager (org.eclipse.core.filebuffers.ITextFileBufferManager)10 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)10 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)9 ListRewrite (org.eclipse.jdt.core.dom.rewrite.ListRewrite)9 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)8 InsertEdit (org.eclipse.text.edits.InsertEdit)8 IPath (org.eclipse.core.runtime.IPath)7 ASTNode (org.eclipse.jdt.core.dom.ASTNode)7 ArrayList (java.util.ArrayList)6