Search in sources :

Example 11 with JavacFileManager

use of org.eclipse.ceylon.langtools.tools.javac.file.JavacFileManager in project ceylon by eclipse.

the class CeylonDocToolTests method compileJavaModule.

private void compileJavaModule(String pathname, String... fileNames) throws Exception {
    CeyloncTool compiler = new CeyloncTool();
    List<String> options = Arrays.asList("-src", pathname, "-out", "build/ceylon-cars", "-sysrep", "../dist/dist/repo", "-cp", CompilerTests.getClassPathAsPath());
    JavacFileManager fileManager = compiler.getStandardFileManager(null, null, null);
    List<String> qualifiedNames = new ArrayList<String>(fileNames.length);
    for (String name : fileNames) {
        qualifiedNames.add(pathname + File.separator + name);
    }
    Iterable<? extends JavaFileObject> fileObjects = fileManager.getJavaFileObjectsFromStrings(qualifiedNames);
    JavacTask task = compiler.getTask(null, null, null, options, null, fileObjects);
    Boolean ret = task.call();
    Assert.assertEquals("Compilation failed", Boolean.TRUE, ret);
}
Also used : JavacFileManager(org.eclipse.ceylon.langtools.tools.javac.file.JavacFileManager) CeyloncTool(org.eclipse.ceylon.compiler.java.tools.CeyloncTool) ArrayList(java.util.ArrayList) JavacTask(org.eclipse.ceylon.langtools.source.util.JavacTask)

Example 12 with JavacFileManager

use of org.eclipse.ceylon.langtools.tools.javac.file.JavacFileManager 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

JavacFileManager (org.eclipse.ceylon.langtools.tools.javac.file.JavacFileManager)12 File (java.io.File)7 VirtualFile (org.eclipse.ceylon.compiler.typechecker.io.VirtualFile)5 JavaFileObject (org.eclipse.ceylon.javax.tools.JavaFileObject)4 IOException (java.io.IOException)3 PrintWriter (java.io.PrintWriter)3 JavaFileManager (org.eclipse.ceylon.javax.tools.JavaFileManager)3 CeyloncTool (org.eclipse.ceylon.compiler.java.tools.CeyloncTool)2 JavacTask (org.eclipse.ceylon.langtools.source.util.JavacTask)2 AnnotationProcessingError (org.eclipse.ceylon.langtools.tools.javac.processing.AnnotationProcessingError)2 Context (org.eclipse.ceylon.langtools.tools.javac.util.Context)2 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Overrides (org.eclipse.ceylon.cmr.api.Overrides)1 ExitState (org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)1 CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)1 org.eclipse.ceylon.javax.lang.model.util (org.eclipse.ceylon.javax.lang.model.util)1