Search in sources :

Example 1 with CeylonModelLoader

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);
    }
}
Also used : Context(org.eclipse.ceylon.langtools.tools.javac.util.Context) JavacTaskImpl(org.eclipse.ceylon.langtools.tools.javac.api.JavacTaskImpl) CeylonModelLoader(org.eclipse.ceylon.compiler.java.loader.CeylonModelLoader) TaskListener(org.eclipse.ceylon.langtools.source.util.TaskListener) TaskEvent(org.eclipse.ceylon.langtools.source.util.TaskEvent) TaskListener(org.eclipse.ceylon.langtools.source.util.TaskListener) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError)

Aggregations

CeylonModelLoader (org.eclipse.ceylon.compiler.java.loader.CeylonModelLoader)1 CompilerError (org.eclipse.ceylon.compiler.java.test.CompilerError)1 TaskEvent (org.eclipse.ceylon.langtools.source.util.TaskEvent)1 TaskListener (org.eclipse.ceylon.langtools.source.util.TaskListener)1 JavacTaskImpl (org.eclipse.ceylon.langtools.tools.javac.api.JavacTaskImpl)1 Context (org.eclipse.ceylon.langtools.tools.javac.util.Context)1