Search in sources :

Example 26 with MultiTextEdit

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

the class TextEditTests method setUp.

@Before
public void setUp() {
    fDocument = new Document("0123456789");
    fRoot = new MultiTextEdit();
}
Also used : Document(org.eclipse.jface.text.Document) IDocument(org.eclipse.jface.text.IDocument) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) Before(org.junit.Before)

Example 27 with MultiTextEdit

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

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

the class TextEditTests method testUndefinedMultiEdit6.

@Test
public void testUndefinedMultiEdit6() throws Exception {
    DeleteEdit d1 = new DeleteEdit(1, 3);
    MultiTextEdit m2 = new MultiTextEdit();
    assertTrue(d1.covers(m2));
}
Also used : DeleteEdit(org.eclipse.text.edits.DeleteEdit) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) Test(org.junit.Test)

Example 29 with MultiTextEdit

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

the class TextEditTests method testUndefinedMultiEdit2.

@Test
public void testUndefinedMultiEdit2() throws Exception {
    MultiTextEdit m1 = new MultiTextEdit();
    MultiTextEdit m2 = new MultiTextEdit();
    assertTrue(m1.covers(m2));
    assertTrue(m2.covers(m1));
}
Also used : MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) Test(org.junit.Test)

Example 30 with MultiTextEdit

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

the class TextEditTests method testTreeUpdate1.

@Test
public void testTreeUpdate1() throws Exception {
    MultiTextEdit m1 = new MultiTextEdit();
    TextEdit e1 = new InsertEdit(2, "aa");
    TextEdit e2 = new InsertEdit(4, "bb");
    m1.addChild(e1);
    m1.addChild(e2);
    MultiTextEdit m2 = new MultiTextEdit();
    TextEdit e3 = new InsertEdit(6, "cc");
    TextEdit e4 = new InsertEdit(8, "dd");
    m2.addChild(e3);
    m2.addChild(e4);
    fRoot.addChild(m1);
    fRoot.addChild(m2);
    assertEquals(m1, 2, 2);
    assertEquals(m2, 6, 2);
    UndoEdit undo = fRoot.apply(fDocument);
    Assert.assertEquals("Buffer content", "01aa23bb45cc67dd89", fDocument.get());
    assertEquals(e1, 2, 2);
    assertEquals(e2, 6, 2);
    assertEquals(e3, 10, 2);
    assertEquals(e4, 14, 2);
    assertEquals(m1, 2, 6);
    assertEquals(m2, 10, 6);
    assertEquals(fRoot, 2, 14);
    doUndoRedo(undo, "01aa23bb45cc67dd89");
}
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) 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