Example usage for javax.annotation.processing ProcessingEnvironment getTypeUtils

List of usage examples for javax.annotation.processing ProcessingEnvironment getTypeUtils

Introduction

In this page you can find the example usage for javax.annotation.processing ProcessingEnvironment getTypeUtils.

Prototype

Types getTypeUtils();

Source Link

Document

Returns an implementation of some utility methods for operating on types.

Usage

From source file:org.mule.module.extension.internal.capability.xml.schema.AnnotationProcessorUtils.java

/**
 * Extracts the documentation of the parameters
 * in a group described by {@code groupElement}.
 * The obtained docs are added to {@code parameterDocs}
 *
 * @param groupElement          a {@link TypeElement} representing the parameter group
 * @param parameterDocs         a {@link Map} which keys are attribute names and values are their documentation
 * @param processingEnvironment the current {@link ProcessingEnvironment}
 *//*w w  w .j a  v a  2 s  .c  o  m*/
private static void getOperationParameterGroupDocumentation(TypeElement groupElement,
        final Map<String, String> parameterDocs, ProcessingEnvironment processingEnvironment) {
    for (final Map.Entry<String, VariableElement> field : getFieldsAnnotatedWith(groupElement, Parameter.class)
            .entrySet()) {
        parseJavaDoc(processingEnvironment, field.getValue(), new JavadocParseHandler() {
            @Override
            void onParam(String param) {
            }

            @Override
            void onBodyLine(String bodyLine) {
                parameterDocs.put(field.getKey(), bodyLine);
            }
        });
    }

    for (VariableElement field : getFieldsAnnotatedWith(groupElement, ParameterGroup.class).values()) {

        getOperationParameterGroupDocumentation(
                (TypeElement) processingEnvironment.getTypeUtils().asElement(field.asType()), parameterDocs,
                processingEnvironment);
    }
}

From source file:org.mule.module.extension.internal.capability.xml.schema.AnnotationProcessorUtils.java

/**
 * Traverses the arguments of {@code methodElement} and for each
 * argument annotated with {@link ParameterGroup} it invokes
 * {@link #getOperationParameterGroupDocumentation(TypeElement, Map, ProcessingEnvironment)}
 *
 * @param processingEnv the current {@link ProcessingEnvironment}
 * @param methodElement the operation method being processed
 * @param parameterDocs a {@link Map} which keys are attribute names and values are their documentation
 *//*from www.  jav  a2  s.  c o  m*/
private static void parseOperationParameterGroups(ProcessingEnvironment processingEnv,
        MethodSymbol methodElement, Map<String, String> parameterDocs) {
    for (VarSymbol parameterSymbol : methodElement.getParameters()) {
        for (Attribute.Compound compound : parameterSymbol.getAnnotationMirrors()) {
            DeclaredType annotationType = compound.getAnnotationType();
            if (annotationType != null) {
                Class<? extends Annotation> annotationClass = classFor(
                        (TypeElement) compound.getAnnotationType().asElement(), processingEnv);
                if (ParameterGroup.class.isAssignableFrom(annotationClass)) {
                    try {
                        getOperationParameterGroupDocumentation(
                                (TypeElement) processingEnv.getTypeUtils().asElement(parameterSymbol.asType()),
                                parameterDocs, processingEnv);
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
    }
}

From source file:android.databinding.tool.store.SetterStore.java

private static TypeMirror eraseType(ProcessingEnvironment processingEnv, TypeMirror typeMirror) {
    if (hasTypeVar(typeMirror)) {
        return processingEnv.getTypeUtils().erasure(typeMirror);
    } else {// w w  w.j  av a2  s  .c  om
        return typeMirror;
    }
}

From source file:uniol.apt.compiler.AbstractServiceProcessor.java

@Override
public synchronized void init(ProcessingEnvironment procEnv) {
    super.init(procEnv);
    this.elements = procEnv.getElementUtils();
    this.types = procEnv.getTypeUtils();
    this.filer = processingEnv.getFiler();
    this.messager = processingEnv.getMessager();
    this.finished = false;
}

From source file:info.archinnov.achilles.internals.apt.processors.meta.AchillesProcessor.java

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);

    aptUtils = new AptUtils(processingEnv.getElementUtils(), processingEnv.getTypeUtils(),
            processingEnv.getMessager(), processingEnv.getFiler());
    entityParser = new EntityParser(aptUtils);
}

From source file:com.github.pellaton.springconfigvalidation.SpringConfigurationValidationProcessor.java

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);

    this.messager = processingEnv.getMessager();
    this.typeUtils = processingEnv.getTypeUtils();
    this.elementUtils = processingEnv.getElementUtils();

    this.autowiredTypeElement = this.elementUtils
            .getTypeElement("org.springframework.beans.factory.annotation.Autowired");
    this.beanTypeElement = this.elementUtils.getTypeElement("org.springframework.context.annotation.Bean");
    this.bfppTypeElement = this.elementUtils
            .getTypeElement("org.springframework.beans.factory.config.BeanFactoryPostProcessor");
    this.configurationTypeElement = this.elementUtils
            .getTypeElement("org.springframework.context.annotation.Configuration");
}

From source file:com.rgeldmacher.leash.LeashAnnotationProcessor.java

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    filer = processingEnv.getFiler();//from   w  w w  .jav  a  2s .  c  o m
    types = processingEnv.getTypeUtils();
    elements = processingEnv.getElementUtils();
}

From source file:com.contentful.vault.compiler.Processor.java

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    elementUtils = processingEnv.getElementUtils();
    typeUtils = processingEnv.getTypeUtils();
    filer = processingEnv.getFiler();//  ww w. j  a v  a  2s. c  o m
}

From source file:easymvp.compiler.EasyMVPProcessor.java

@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    elementUtils = processingEnv.getElementUtils();
    filer = processingEnv.getFiler();/*  ww w. j ava 2  s  . c o m*/
    messager = processingEnv.getMessager();
    typeUtils = processingEnv.getTypeUtils();
}

From source file:org.jannocessor.processor.JannocessorProcessorBase.java

@Override
public synchronized void init(ProcessingEnvironment env) {
    // overwrite the class loader set by the Maven plugin
    Thread.currentThread().setContextClassLoader(JannocessorEngine.class.getClassLoader());

    super.init(env);

    try {/*from  ww w.ja v  a 2 s .c o m*/
        messager = env.getMessager();
        JannocessorLogger.messager = messager;

        elementUtils = env.getElementUtils();
        typeUtils = env.getTypeUtils();
        filer = env.getFiler();
        options = new Config(env.getOptions());
        injector = createInjector();

        processOptions();

        logger.info("Initializing services...");

        engine = injector.getInstance(JannocessorEngine.class);
        engine.configure(engine.getTemplatesPath(), true);

        // recompileProcessors();

        Class<?> hotConfig = Jannocessor.reloadClass("org.jannocessor.config.Processors",
                Power.emptyList(String.class));
        processorsConfig = new ProcessorsConfiguration(hotConfig);

        showConfiguration();

        logger.info("Initialization finished.");
    } catch (Exception e) {
        logger.error("Initialization failed!");
        valid = false;
        throw new RuntimeException(e);
    }
}