use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-eclipse by eclipse.
the class TypeResourceUnloaderTest method testRenameClass.
@Test
public void testRenameClass() throws BadLocationException, JavaModelException, InterruptedException {
waitForEvent(new Procedure0() {
@Override
public void apply() {
int idx = document.get().indexOf("NestedTypes");
assertNull("event is null before the document was modified", event);
try {
document.replace(idx, "NestedTypes".length(), "FooBar");
} catch (BadLocationException e) {
fail(e.getMessage());
}
}
});
String foobar = "org.eclipse.xtext.common.types.testSetups.FooBar";
assertNotNull(event);
assertTrue(subsequentEvents.toString(), subsequentEvents.isEmpty());
assertEquals("" + event.getDeltas(), 6, event.getDeltas().size());
IResourceDescription.Delta delta = event.getDeltas().get(0);
assertEquals("java:/Objects/" + foobar, event.getDeltas().get(0).getUri().toString());
assertEquals("java:/Objects/" + foobar, event.getDeltas().get(1).getUri().toString());
assertEquals("java:/Objects/" + foobar, event.getDeltas().get(2).getUri().toString());
assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(3).getUri().toString());
assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(4).getUri().toString());
assertEquals("java:/Objects/" + NESTED_TYPES, event.getDeltas().get(5).getUri().toString());
Collection<String> allNames = getNames(delta);
// FooBar
addNames(event.getDeltas().get(0).getNew(), allNames);
// FooBar$Outer
addNames(event.getDeltas().get(1).getNew(), allNames);
// FooBar$Outer$Inner
addNames(event.getDeltas().get(2).getNew(), allNames);
// NestedTypes
addNames(event.getDeltas().get(3).getOld(), allNames);
// NestedTypes$Outer
addNames(event.getDeltas().get(4).getOld(), allNames);
// NestedTypes$Outer$Inner
addNames(event.getDeltas().get(5).getOld(), allNames);
assertTrue(allNames.toString(), allNames.contains(foobar));
assertTrue(allNames.toString(), allNames.contains(foobar + "$Outer"));
assertTrue(allNames.toString(), allNames.contains(foobar + "$Outer$Inner"));
assertTrue(allNames.toString(), allNames.contains(NESTED_TYPES));
assertTrue(allNames.toString(), allNames.contains(NESTED_TYPES + "$Outer"));
assertTrue(allNames.toString(), allNames.contains(NESTED_TYPES + "$Outer$Inner"));
assertEquals("" + allNames, 6, allNames.size());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project smarthome by eclipse.
the class TimerExecutionJob method execute.
/**
* Runs the configured closure of this job
*
* @param context the execution context of the job
*/
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
logger.debug("Executing timer '{}'", context.getJobDetail().getKey().toString());
Procedure0 procedure = (Procedure0) context.getJobDetail().getJobDataMap().get("procedure");
Procedure1<Object> procedure1 = (Procedure1<Object>) context.getJobDetail().getJobDataMap().get("procedure1");
TimerImpl timer = (TimerImpl) context.getJobDetail().getJobDataMap().get("timer");
Object argument1 = context.getJobDetail().getJobDataMap().get("argument1");
if (argument1 != null) {
procedure1.apply(argument1);
} else {
procedure.apply();
}
timer.setTerminated(true);
}
Aggregations