Search in sources :

Example 1 with MockChange

use of org.eclipse.xtext.ui.tests.refactoring.MockRefactoringDocument.MockChange in project xtext-eclipse by eclipse.

the class UpdateAcceptorTest method testAddTextEdit.

@Test
public void testAddTextEdit() throws Exception {
    updateAcceptor.accept(resourceURI0, new ReplaceEdit(0, 1, "foo"));
    updateAcceptor.accept(resourceURI1, new ReplaceEdit(1, 2, "bar"));
    updateAcceptor.accept(resourceURI0, new ReplaceEdit(3, 4, "baz"));
    Change change = updateAcceptor.createCompositeChange(CHANGE_NAME, new NullProgressMonitor());
    assertTrue(change instanceof CompositeChange);
    Change[] children = ((CompositeChange) change).getChildren();
    assertEquals(2, children.length);
    assertTrue(children[0] instanceof MockChange);
    MockChange change0 = (MockChange) children[0];
    assertEquals(CHANGE_NAME, change0.getName());
    assertTrue(children[1] instanceof MockChange);
    MockChange change1 = (MockChange) children[1];
    assertEquals(CHANGE_NAME, change1.getName());
    assertTrue(change0.getTextEdit() instanceof MultiTextEdit);
    assertTrue(change1.getTextEdit() instanceof MultiTextEdit);
    assertEquals(3, ((MultiTextEdit) change0.getTextEdit()).getChildrenSize() + ((MultiTextEdit) change1.getTextEdit()).getChildrenSize());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MockChange(org.eclipse.xtext.ui.tests.refactoring.MockRefactoringDocument.MockChange) ReplaceEdit(org.eclipse.text.edits.ReplaceEdit) MockChange(org.eclipse.xtext.ui.tests.refactoring.MockRefactoringDocument.MockChange) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) Change(org.eclipse.ltk.core.refactoring.Change) CompositeChange(org.eclipse.ltk.core.refactoring.CompositeChange) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) Test(org.junit.Test)

Aggregations

NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Change (org.eclipse.ltk.core.refactoring.Change)1 CompositeChange (org.eclipse.ltk.core.refactoring.CompositeChange)1 MultiTextEdit (org.eclipse.text.edits.MultiTextEdit)1 ReplaceEdit (org.eclipse.text.edits.ReplaceEdit)1 MockChange (org.eclipse.xtext.ui.tests.refactoring.MockRefactoringDocument.MockChange)1 Test (org.junit.Test)1