Search in sources :

Example 36 with MalformedTreeException

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

the class TextEditTests method testOverlap2.

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

Example 37 with MalformedTreeException

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

Example 38 with MalformedTreeException

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

the class TextEditTests method testOverlap4.

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

Example 39 with MalformedTreeException

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

Example 40 with MalformedTreeException

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

the class TextEditTests method testOverlap3.

@Test
public void testOverlap3() throws Exception {
    // [ [ ]]
    fRoot.addChild(new ReplaceEdit(0, 2, "01"));
    boolean exception = false;
    try {
        fRoot.addChild(new ReplaceEdit(1, 1, "1"));
    } catch (MalformedTreeException e) {
        exception = true;
    }
    assertTrue(exception);
}
Also used : ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) MalformedTreeException(org.eclipse.text.edits.MalformedTreeException) 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