Search in sources :

Example 11 with ExitState

use of org.eclipse.ceylon.compiler.java.launcher.Main.ExitState in project ceylon by eclipse.

the class JavaCompilerImpl method compile.

@SuppressWarnings("deprecation")
@Override
public boolean compile(CompilerOptions options, CompilationListener listener) {
    CeyloncTool compiler = new CeyloncTool();
    CompilationListenerAdapter diagnosticListener = new CompilationListenerAdapter(listener);
    Writer writer = options.getOutWriter();
    if (!options.isVerbose() && writer == null) {
        // make the tool shut the hell up
        writer = new NullWriter();
    }
    JavacFileManager fileManager = compiler.getStandardFileManager(writer, diagnosticListener, null, null);
    Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromFiles(options.getFiles());
    CeyloncTaskImpl compilerTask = compiler.getTask(null, fileManager, diagnosticListener, translateOptions(options), options.getModules(), compilationUnits);
    compilerTask.setTaskListener(diagnosticListener);
    ExitState state = compilerTask.call2();
    // print any helpful info if required
    if (options.isVerbose() && state.abortingException != null)
        state.abortingException.printStackTrace();
    return state.ceylonState == CeylonState.OK;
}
Also used : JavacFileManager(org.eclipse.ceylon.langtools.tools.javac.file.JavacFileManager) ExitState(org.eclipse.ceylon.compiler.java.launcher.Main.ExitState) CeyloncTool(org.eclipse.ceylon.compiler.java.tools.CeyloncTool) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) Writer(java.io.Writer)

Aggregations

ExitState (org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)11 CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)7 Test (org.junit.Test)5 ErrorCollector (org.eclipse.ceylon.compiler.java.test.ErrorCollector)4 File (java.io.File)2 ZipFile (java.util.zip.ZipFile)2 JavaPositionsRetriever (org.eclipse.ceylon.compiler.java.codegen.JavaPositionsRetriever)2 CompilerError (org.eclipse.ceylon.compiler.java.test.CompilerError)2 DiagnosticListener (org.eclipse.ceylon.javax.tools.DiagnosticListener)2 TaskEvent (org.eclipse.ceylon.langtools.source.util.TaskEvent)2 TaskListener (org.eclipse.ceylon.langtools.source.util.TaskListener)2 JCCompilationUnit (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCCompilationUnit)2 Writer (java.io.Writer)1 TreeSet (java.util.TreeSet)1 CeyloncTool (org.eclipse.ceylon.compiler.java.tools.CeyloncTool)1 JavacFileManager (org.eclipse.ceylon.langtools.tools.javac.file.JavacFileManager)1