Java Code Examples for javax.annotation.processing.ProcessingEnvironment#getElementUtils()

The following examples show how to use javax.annotation.processing.ProcessingEnvironment#getElementUtils() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeGeneration.java    From requery with Apache License 2.0 6 votes vote down vote up
static void addGeneratedAnnotation(ProcessingEnvironment processingEnvironment,
                                   TypeSpec.Builder builder) {
    Elements elements = processingEnvironment.getElementUtils();
    SourceVersion sourceVersion = processingEnvironment.getSourceVersion();
    AnnotationSpec.Builder annotationBuilder = null;
    if (sourceVersion.compareTo(SourceVersion.RELEASE_8) > 0) {
        ClassName name = ClassName.bestGuess("javax.annotation.processing.Generated");
        annotationBuilder = AnnotationSpec.builder(name);
    } else {
        if (elements.getTypeElement(Generated.class.getCanonicalName()) != null) {
            annotationBuilder = AnnotationSpec.builder(Generated.class);
        }
    }

    if (annotationBuilder != null) {
        builder.addAnnotation(annotationBuilder
                .addMember("value", "$S",
                        EntityProcessor.class.getCanonicalName()).build());
    }
}
 
Example 2
Source File: Processor.java    From pandroid with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    mProcessingEnvironment = processingEnv;
    mElementsUtils = processingEnv.getElementUtils();
    mTypesUtils = processingEnv.getTypeUtils();


    processors = new ArrayList<BaseProcessor>();
    processors.add(new EventBusProcessor(mElementsUtils, mTypesUtils));
    processors.add(new LifecycleDelegateProcessor(mElementsUtils, mTypesUtils));
    processors.add(new RxWrapperProcessor(mElementsUtils, mTypesUtils));
    processors.add(new GeneratedClassMapperProcessor(mElementsUtils, mTypesUtils));

    duration = 0;

}
 
Example 3
Source File: BarberProcessor.java    From barber with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    instance = this;
    typeUtils = processingEnv.getTypeUtils();
    elementUtils = processingEnv.getElementUtils();
    filer = processingEnv.getFiler();
    messager = processingEnv.getMessager();
}
 
Example 4
Source File: CustomExtendedTypeFactory.java    From infobip-spring-data-querydsl with Apache License 2.0 5 votes vote down vote up
public CustomExtendedTypeFactory(
        ProcessingEnvironment env,
        Set<Class<? extends Annotation>> annotations,
        TypeMappings typeMappings,
        QueryTypeFactory queryTypeFactory,
        Function<EntityType, String> variableNameFunction) {
    super(env, annotations, typeMappings, queryTypeFactory, variableNameFunction);
    this.elements = env.getElementUtils();
}
 
Example 5
Source File: FabridgeProcess.java    From FABridge with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv)
{
    super.init(processingEnv);

    typeUtils = processingEnv.getTypeUtils();
    elementUtils = processingEnv.getElementUtils();
    messager = processingEnv.getMessager();
}
 
Example 6
Source File: BaseProcessor.java    From WMRouter with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
    super.init(processingEnvironment);
    filer = processingEnvironment.getFiler();
    types = processingEnvironment.getTypeUtils();
    elements = processingEnvironment.getElementUtils();
}
 
Example 7
Source File: DeepLinkInjectProcessor.java    From OkDeepLink with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    logger = new Logger(processingEnv.getMessager());
    filer = processingEnv.getFiler();
    elements = processingEnv.getElementUtils();
    types = processingEnv.getTypeUtils();
}
 
Example 8
Source File: FastModelProcessor.java    From FastAdapter with MIT License 5 votes vote down vote up
@Override
public synchronized void init(final ProcessingEnvironment pProcessingEnvironment) {
  super.init(pProcessingEnvironment);
  mMessager = pProcessingEnvironment.getMessager();
  mFiler = pProcessingEnvironment.getFiler();
  mElements = pProcessingEnvironment.getElementUtils();
}
 
Example 9
Source File: DataLoaderProcessor.java    From DataLoader with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnvironment) {
    super.init(processingEnvironment);
    filer = processingEnvironment.getFiler();
    types = processingEnvironment.getTypeUtils();
    elements = processingEnvironment.getElementUtils();
}
 
Example 10
Source File: EntityPartGenerator.java    From requery with Apache License 2.0 5 votes vote down vote up
EntityPartGenerator(ProcessingEnvironment processingEnv,
                    EntityGraph graph,
                    EntityDescriptor entity) {
    this.processingEnv = processingEnv;
    this.graph = graph;
    this.entity = entity;
    this.elements = processingEnv.getElementUtils();
    this.types = processingEnv.getTypeUtils();
    nameResolver = new EntityNameResolver(graph);
    typeElement = entity.element();
    typeName = nameResolver.typeNameOf(entity);
}
 
Example 11
Source File: BaseProcess.java    From EasyRouter with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    typeUtils = processingEnv.getTypeUtils();
    elementUtils = processingEnv.getElementUtils();
    filer = processingEnv.getFiler();
    messager = processingEnv.getMessager();
}
 
Example 12
Source File: KratosProcessor.java    From Kratos with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment env) {
    super.init(env);
    elementUtils = env.getElementUtils();
    typeUtils = env.getTypeUtils();
    filer = env.getFiler();
}
 
Example 13
Source File: EnumModel.java    From vertx-codegen with Apache License 2.0 5 votes vote down vote up
public EnumModel(ProcessingEnvironment env, TypeElement modelElt) {
  this.typeUtils = env.getTypeUtils();
  this.elementUtils = env.getElementUtils();
  this.typeMirrorFactory = new TypeMirrorFactory(elementUtils, typeUtils);
  this.docFactory = new Doc.Factory(env.getMessager(), elementUtils, typeUtils, typeMirrorFactory, modelElt);
  this.modelElt = modelElt;
  this.annotationValueInfoFactory = new AnnotationValueInfoFactory(typeMirrorFactory);
  this.deprecated = modelElt.getAnnotation(Deprecated.class) != null;
}
 
Example 14
Source File: BuilderSpec.java    From RetroFacebook with Apache License 2.0 5 votes vote down vote up
BuilderSpec(
    TypeElement autoValueClass,
    ProcessingEnvironment processingEnv,
    ErrorReporter errorReporter) {
  this.autoValueClass = autoValueClass;
  this.elementUtils = processingEnv.getElementUtils();
  this.errorReporter = errorReporter;
}
 
Example 15
Source File: Introspection.java    From immutables with Apache License 2.0 4 votes vote down vote up
Introspection(ProcessingEnvironment environment) {
  this.environment = environment;
  this.elements = environment.getElementUtils();
  this.types = environment.getTypeUtils();
  this.inEclipseCompiler = environment.getClass().getName().startsWith("org.eclipse.jdt");
}
 
Example 16
Source File: Analyser.java    From FreeBuilder with Apache License 2.0 4 votes vote down vote up
Analyser(ProcessingEnvironment env, Messager messager) {
  this.env = env;
  this.elements = env.getElementUtils();
  this.messager = messager;
  this.types = env.getTypeUtils();
}
 
Example 17
Source File: ContentHeaderAnnotationValidator.java    From qpid-broker-j with Apache License 2.0 4 votes vote down vote up
private static TypeMirror getErasure(ProcessingEnvironment processingEnv, final String className)
{
    final Types typeUtils = processingEnv.getTypeUtils();
    final Elements elementUtils = processingEnv.getElementUtils();
    return typeUtils.erasure(elementUtils.getTypeElement(className).asType());
}
 
Example 18
Source File: OperationAnnotationValidator.java    From qpid-broker-j with Apache License 2.0 4 votes vote down vote up
private static TypeMirror getErasure(ProcessingEnvironment processingEnv, final String className)
{
    final Types typeUtils = processingEnv.getTypeUtils();
    final Elements elementUtils = processingEnv.getElementUtils();
    return typeUtils.erasure(elementUtils.getTypeElement(className).asType());
}
 
Example 19
Source File: T6468404.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    elements = processingEnv.getElementUtils();
}
 
Example 20
Source File: EcjMultilineProcessor.java    From datafu with Apache License 2.0 4 votes vote down vote up
@Override
public void init(final ProcessingEnvironment procEnv) {
  super.init(procEnv);
  this.elementUtils = procEnv.getElementUtils();
}