Search in sources :

Example 1 with BasicJavacTask

use of org.eclipse.ceylon.langtools.tools.javac.api.BasicJavacTask in project ceylon by eclipse.

the class JavacTask method instance.

/**
 * Get the {@code JavacTask} for a {@code ProcessingEnvironment}.
 * If the compiler is being invoked using a
 * {@link org.eclipse.ceylon.javax.tools.JavaCompiler.CompilationTask CompilationTask},
 * then that task will be returned.
 * @param processingEnvironment the processing environment
 * @return the {@code JavacTask} for a {@code ProcessingEnvironment}
 * @since 1.8
 */
public static JavacTask instance(ProcessingEnvironment processingEnvironment) {
    if (!processingEnvironment.getClass().getName().equals("org.eclipse.ceylon.langtools.tools.javac.processing.JavacProcessingEnvironment"))
        throw new IllegalArgumentException();
    Context c = ((JavacProcessingEnvironment) processingEnvironment).getContext();
    JavacTask t = c.get(JavacTask.class);
    return (t != null) ? t : new BasicJavacTask(c, true);
}
Also used : Context(org.eclipse.ceylon.langtools.tools.javac.util.Context) BasicJavacTask(org.eclipse.ceylon.langtools.tools.javac.api.BasicJavacTask) JavacProcessingEnvironment(org.eclipse.ceylon.langtools.tools.javac.processing.JavacProcessingEnvironment) BasicJavacTask(org.eclipse.ceylon.langtools.tools.javac.api.BasicJavacTask)

Aggregations

BasicJavacTask (org.eclipse.ceylon.langtools.tools.javac.api.BasicJavacTask)1 JavacProcessingEnvironment (org.eclipse.ceylon.langtools.tools.javac.processing.JavacProcessingEnvironment)1 Context (org.eclipse.ceylon.langtools.tools.javac.util.Context)1