Search in sources :

Example 31 with JavaCompiler

use of com.sun.tools.javac.main.JavaCompiler in project ceylon-compiler by ceylon.

the class T6400303 method main.

public static void main(String... args) {
    javax.tools.JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
    JavacTaskImpl task = (JavacTaskImpl) tool.getTask(null, null, null, null, null, null);
    JavaCompiler compiler = JavaCompiler.instance(task.getContext());
    try {
        compiler.resolveIdent("Test$1").complete();
    } catch (CompletionFailure ex) {
        System.err.println("Got expected completion failure: " + ex.getLocalizedMessage());
        return;
    }
    throw new AssertionError("No error reported");
}
Also used : JavacTaskImpl(com.sun.tools.javac.api.JavacTaskImpl) CompletionFailure(com.sun.tools.javac.code.Symbol.CompletionFailure) JavaCompiler(com.sun.tools.javac.main.JavaCompiler)

Example 32 with JavaCompiler

use of com.sun.tools.javac.main.JavaCompiler in project ceylon-compiler by ceylon.

the class LanguageCompiler method instance.

/**
 * Get the JavaCompiler instance for this context.
 */
public static JavaCompiler instance(Context context) {
    Options options = Options.instance(context);
    options.put("-Xprefer", "source");
    // make sure it's registered
    CeylonLog.instance(context);
    CeylonEnter.instance(context);
    CeylonClassWriter.instance(context);
    JavaCompiler instance = context.get(compilerKey);
    if (instance == null)
        instance = new LanguageCompiler(context);
    return instance;
}
Also used : Options(com.sun.tools.javac.util.Options) JavaCompiler(com.sun.tools.javac.main.JavaCompiler)

Aggregations

JavaCompiler (com.sun.tools.javac.main.JavaCompiler)32 JavacTaskImpl (com.sun.tools.javac.api.JavacTaskImpl)8 Context (com.sun.tools.javac.util.Context)7 Field (java.lang.reflect.Field)6 JavaFileObject (javax.tools.JavaFileObject)6 JavaFileManager (javax.tools.JavaFileManager)5 JavacFileManager (com.sun.tools.javac.file.JavacFileManager)4 BadClassFile (com.sun.tools.javac.jvm.ClassReader.BadClassFile)4 CompletionFailure (com.sun.tools.javac.code.Symbol.CompletionFailure)3 JavacProcessingEnvironment (com.sun.tools.javac.processing.JavacProcessingEnvironment)3 OutputStream (java.io.OutputStream)3 PrintStream (java.io.PrintStream)3 CompilationUnitTree (com.sun.source.tree.CompilationUnitTree)2 MethodTree (com.sun.source.tree.MethodTree)2 TreePathScanner (com.sun.source.util.TreePathScanner)2 Options (com.sun.tools.javac.util.Options)2 File (java.io.File)2 IOException (java.io.IOException)2 EnvironmentException (com.redhat.ceylon.compiler.EnvironmentException)1 RepositoryException (com.redhat.ceylon.model.cmr.RepositoryException)1