use of org.eclipse.ceylon.compiler.java.loader.CeylonModelLoader in project ceylon by eclipse.
the class ModelLoaderTests method verifyCompilerClassLoading.
protected void verifyCompilerClassLoading(String ceylon, final RunnableTest test, List<String> options) {
// now compile the ceylon usage file
JavacTaskImpl task2 = getCompilerTask(options, ceylon);
// get the context to grab the declarations
final Context context2 = task2.getContext();
// declarations from the jar anymore because we've overridden the jar and the javac jar index is corrupted
class Listener implements TaskListener {
@Override
public void started(TaskEvent e) {
}
@Override
public void finished(TaskEvent e) {
if (e.getKind() == Kind.ENTER) {
CeylonModelLoader modelLoader = (CeylonModelLoader) CeylonModelLoader.instance(context2);
test.test(modelLoader);
}
}
}
Listener listener = new Listener();
task2.setTaskListener(listener);
try {
Boolean success = task2.call();
Assert.assertTrue("Compilation failed", success);
} catch (AssertionError x) {
throw x;
} catch (Throwable x) {
// make sure we unwrap it
while (x.getCause() != null) x = x.getCause();
if (x instanceof Error)
throw (Error) x;
if (x instanceof RuntimeException)
throw (RuntimeException) x;
throw new RuntimeException(x);
}
}
Aggregations