use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testCloseAndReopenEditor.
@Test
public void testCloseAndReopenEditor() throws InterruptedException, PartInitException, JavaModelException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editor, false);
try {
editor = JavaUI.openInEditor(compilationUnit);
} catch (PartInitException e) {
fail(e.getMessage());
} catch (JavaModelException e) {
fail(e.getMessage());
}
}
});
assertNull(event);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testAddNestedClass.
@Test
public void testAddNestedClass() throws BadLocationException, JavaModelException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
int idx = document.get().indexOf("public abstract class Inner");
assertNull("event is null before the document was modified", event);
try {
int closing = document.get().substring(idx).indexOf("\t}");
document.replace(idx + closing, 0, " public abstract class InnerSibling {} ");
} catch (BadLocationException e) {
fail(e.getMessage());
}
}
});
assertNotNull(event);
assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty());
assertEquals("" + event.getDeltas(), 4, event.getDeltas().size());
assertNull(event.getDeltas().get(3).getOld());
assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(0).getUri().toString());
assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(1).getUri().toString());
assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(2).getUri().toString());
assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(3).getUri().toString());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testTypeParameterAdded.
@Test
public void testTypeParameterAdded() throws BadLocationException, JavaModelException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
String lookup = "NestedTypes";
int idx = document.get().indexOf(lookup) + "NestedTypes".length();
assertNull("event is null before the document was modified", event);
try {
document.replace(idx, 0, "<Abc>");
} catch (BadLocationException e) {
fail(e.getMessage());
}
}
});
assertNotNull(event);
assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty());
assertEquals("" + event.getDeltas(), 3, event.getDeltas().size());
IResourceDescription.Delta delta = event.getDeltas().get(0);
assertNotNull(delta.getNew());
assertNotNull(delta.getOld());
assertEquals("java:/Objects/" + NESTED_TYPES, delta.getUri().toString());
Collection<String> allNames = getNames(event.getDeltas());
assertOriginalValues(allNames);
assertEquals("" + allNames, 3, allNames.size());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testRenameInnerMethod.
@Test
public void testRenameInnerMethod() throws BadLocationException, JavaModelException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
int idx = document.get().indexOf("method(");
assertNull("event is null before the document was modified", event);
try {
document.replace(idx + "method".length(), 0, "2");
} catch (BadLocationException e) {
fail(e.getMessage());
}
}
});
assertNotNull(event);
assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty());
assertEquals("" + event.getDeltas(), 3, event.getDeltas().size());
Collection<String> allNames = getNames(event.getDeltas());
assertOriginalValues(allNames);
assertEquals("" + allNames, 3, allNames.size());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testRemoveMethod.
@Test
public void testRemoveMethod() throws BadLocationException, JavaModelException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
String lookup = "abstract boolean method();";
int idx = document.get().lastIndexOf(lookup);
assertNull("event is null before the document was modified", event);
try {
document.replace(idx, lookup.length(), "");
} catch (BadLocationException e) {
fail(e.getMessage());
}
}
});
assertNotNull(event);
assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty());
assertEquals("" + event.getDeltas(), 3, event.getDeltas().size());
IResourceDescription.Delta delta = event.getDeltas().get(0);
assertNotNull(delta.getNew());
assertNotNull(delta.getOld());
assertEquals("java:/Objects/" + NESTED_TYPES, delta.getUri().toString());
Collection<String> allNames = getNames(event.getDeltas());
assertOriginalValues(allNames);
assertEquals("" + allNames, 3, allNames.size());
}
Aggregations