@Override public void callback(TypeElement template) { for (AnnotationProcessor<?> generator : generators) { Class<? extends Annotation> annotationType = generator.getParser().getAnnotationType(); if (annotationType != null) { Annotation annotation = template.getAnnotation(annotationType); if (annotation != null) { processElement(generator, template, true); } } } }
private static void processElement(AnnotationProcessor<?> generator, Element e, boolean callback) { try { generator.process(e, callback); } catch (Throwable e1) { handleThrowable(generator, e1, e); } }
private List<AnnotationProcessor<?>> getGenerators() { if (generators == null && processingEnv != null) { generators = new ArrayList<>(); generators.add(new AnnotationProcessor<>(new TypeSystemParser(), new TypeSystemCodeGenerator())); generators.add(new AnnotationProcessor<>(new NodeParser(), new NodeCodeGenerator())); } return generators; }
private List<AnnotationProcessor<?>> getGenerators() { if (generators == null && processingEnv != null) { generators = new ArrayList<>(); generators.add(new AnnotationProcessor<>(new TypeSystemParser(), new TypeSystemCodeGenerator())); generators.add(new AnnotationProcessor<>(new NodeParser(), new NodeCodeGenerator())); } return generators; }
@Override public void callback(TypeElement template) { for (AnnotationProcessor<?> generator : generators) { Class<? extends Annotation> annotationType = generator.getParser().getAnnotationType(); if (annotationType != null) { Annotation annotation = template.getAnnotation(annotationType); if (annotation != null) { processElement(generator, template, true); } } } }
private static void processElement(AnnotationProcessor<?> generator, Element e, boolean callback) { try { generator.process(e, callback); } catch (Throwable e1) { handleThrowable(generator, e1, e); } }
private void processImpl(RoundEnvironment env) { // TODO run verifications that other annotations are not processed out of scope of the // operation or type lattice. try { ProcessorContext.setThreadLocalInstance(new ProcessorContext(processingEnv, this)); for (AnnotationProcessor<?> generator : getGenerators()) { AbstractParser<?> parser = generator.getParser(); if (parser.getAnnotationType() != null) { for (Element e : env.getElementsAnnotatedWith(parser.getAnnotationType())) { processElement(generator, e, false); } } for (Class<? extends Annotation> annotationType : parser.getTypeDelegatedAnnotationTypes()) { for (Element e : env.getElementsAnnotatedWith(annotationType)) { TypeElement processedType; if (parser.isDelegateToRootDeclaredType()) { processedType = ElementUtils.findRootEnclosingType(e); } else { processedType = ElementUtils.findNearestEnclosingType(e); } processElement(generator, processedType, false); } } } } finally { ProcessorContext.setThreadLocalInstance(null); } }
private void processImpl(RoundEnvironment env) { // TODO run verifications that other annotations are not processed out of scope of the // operation or typelattice. try { ProcessorContext.setThreadLocalInstance(new ProcessorContext(processingEnv, this)); for (AnnotationProcessor<?> generator : getGenerators()) { AbstractParser<?> parser = generator.getParser(); if (parser.getAnnotationType() != null) { for (Element e : env.getElementsAnnotatedWith(parser.getAnnotationType())) { processElement(generator, e, false); } } for (Class<? extends Annotation> annotationType : parser.getTypeDelegatedAnnotationTypes()) { for (Element e : env.getElementsAnnotatedWith(annotationType)) { TypeElement processedType; if (parser.isDelegateToRootDeclaredType()) { processedType = ElementUtils.findRootEnclosingType(e); } else { processedType = ElementUtils.findNearestEnclosingType(e); } processElement(generator, processedType, false); } } } } finally { ProcessorContext.setThreadLocalInstance(null); } }