Search in sources :

Example 1 with JavaFileManager

use of org.eclipse.ceylon.javax.tools.JavaFileManager in project ceylon by eclipse.

the class JavacProcessingEnvironment method initProcessorClassLoader.

private void initProcessorClassLoader() {
    JavaFileManager fileManager = context.get(JavaFileManager.class);
    try {
        // If processorpath is not explicitly set, use the classpath.
        processorClassLoader = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH) ? fileManager.getClassLoader(ANNOTATION_PROCESSOR_PATH) : fileManager.getClassLoader(CLASS_PATH);
        if (processorClassLoader != null && processorClassLoader instanceof Closeable) {
            JavaCompiler compiler = JavaCompiler.instance(context);
            compiler.closeables = compiler.closeables.prepend((Closeable) processorClassLoader);
        }
    } catch (SecurityException e) {
        processorClassLoaderException = e;
    }
}
Also used : JavaFileManager(org.eclipse.ceylon.javax.tools.JavaFileManager) StandardJavaFileManager(org.eclipse.ceylon.javax.tools.StandardJavaFileManager) Closeable(java.io.Closeable) JavaCompiler(org.eclipse.ceylon.langtools.tools.javac.main.JavaCompiler)

Example 2 with JavaFileManager

use of org.eclipse.ceylon.javax.tools.JavaFileManager in project ceylon by eclipse.

the class JavacProcessingEnvironment method handleServiceLoaderUnavailability.

/**
 * Returns an empty processor iterator if no processors are on the
 * relevant path, otherwise if processors are present, logs an
 * error.  Called when a service loader is unavailable for some
 * reason, either because a service loader class cannot be found
 * or because a security policy prevents class loaders from being
 * created.
 *
 * @param key The resource key to use to log an error message
 * @param e   If non-null, pass this exception to Abort
 */
private Iterator<Processor> handleServiceLoaderUnavailability(String key, Exception e) {
    JavaFileManager fileManager = context.get(JavaFileManager.class);
    if (fileManager instanceof JavacFileManager) {
        StandardJavaFileManager standardFileManager = (JavacFileManager) fileManager;
        Iterable<? extends File> workingPath = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH) ? standardFileManager.getLocation(ANNOTATION_PROCESSOR_PATH) : standardFileManager.getLocation(CLASS_PATH);
        if (needClassLoader(options.get(PROCESSOR), workingPath))
            handleException(key, e);
    } else {
        handleException(key, e);
    }
    java.util.List<Processor> pl = Collections.emptyList();
    return pl.iterator();
}
Also used : JavacFileManager(org.eclipse.ceylon.langtools.tools.javac.file.JavacFileManager) org.eclipse.ceylon.javax.lang.model.util(org.eclipse.ceylon.javax.lang.model.util) java.util(java.util) JavaFileManager(org.eclipse.ceylon.javax.tools.JavaFileManager) StandardJavaFileManager(org.eclipse.ceylon.javax.tools.StandardJavaFileManager) StandardJavaFileManager(org.eclipse.ceylon.javax.tools.StandardJavaFileManager)

Aggregations

JavaFileManager (org.eclipse.ceylon.javax.tools.JavaFileManager)2 StandardJavaFileManager (org.eclipse.ceylon.javax.tools.StandardJavaFileManager)2 Closeable (java.io.Closeable)1 java.util (java.util)1 org.eclipse.ceylon.javax.lang.model.util (org.eclipse.ceylon.javax.lang.model.util)1 JavacFileManager (org.eclipse.ceylon.langtools.tools.javac.file.JavacFileManager)1 JavaCompiler (org.eclipse.ceylon.langtools.tools.javac.main.JavaCompiler)1