@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { // check if process was done on previous round if (OcelotProcessor.isDone() || roundEnv.processingOver()) { // Returns true if types generated by this round will not be // subject to a subsequent round of annotation processing; returns // false otherwise. return true; // if is it : stop } // Create provider of ocelot-services.js String js = createJSServicesProvider(); // Create file ocelot-services.js try { FileObject resource = filer.createResource(StandardLocation.CLASS_OUTPUT, "", js); try (Writer writer = resource.openWriter()) { ElementVisitor visitor = new DataServiceVisitor(processingEnv); for (Element element : roundEnv.getElementsAnnotatedWith(DataService.class)) { messager.printMessage( Diagnostic.Kind.MANDATORY_WARNING, " javascript generation class : " + element); element.accept(visitor, writer); } } } catch (IOException e) { messager.printMessage(Diagnostic.Kind.ERROR, e.getMessage()); } OcelotProcessor.setDone(true); return true; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { // System.out.println("supported options: "+ // Arrays.toString(getSupportedOptions().toArray())); if (!roundEnv.processingOver()) { for (TypeElement currAnno : annotations) { // System.out.println("Found " + currAnno.getQualifiedName()); if (currAnno.getQualifiedName().contentEquals(GENERATE_POJO_BUILDER_CLASS.getName())) { Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(currAnno); // System.out.println("[GenerateBuilder] annotatedElements="+ // Arrays.toString(annotatedElements.toArray())); for (Element elem : annotatedElements) { if (elem.getKind() == ElementKind.CLASS) { TypeElement typeElem = (TypeElement) elem; GeneratePojoBuilder annotation = typeElem.getAnnotation(GENERATE_POJO_BUILDER_CLASS); generatePojoBuilderProcessor.process(typeElem, annotation); } else if (elem.getKind() == ElementKind.METHOD) { ExecutableElement execElem = (ExecutableElement) elem; GeneratePojoBuilder annotation = execElem.getAnnotation(GENERATE_POJO_BUILDER_CLASS); generatePojoBuilderProcessor.process(execElem, annotation); } } } } } return false; }
/** {@inheritDoc} */ @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) return false; // We have: A sorted set of all priority levels: 'priorityLevels' // Step 1: Take all CUs which aren't already in the map. Give them the first priority level. for (Element element : roundEnv.getRootElements()) { JCCompilationUnit unit = toUnit(element); if (unit == null) continue; if (roots.containsKey(unit)) continue; roots.put(unit, priorityLevels[0]); } while (true) { // Step 2: For all CUs (in the map, not the roundEnv!), run them across all handlers at their // current prio level. for (long prio : priorityLevels) { List<JCCompilationUnit> cusForThisRound = new ArrayList<JCCompilationUnit>(); for (Map.Entry<JCCompilationUnit, Long> entry : roots.entrySet()) { Long prioOfCu = entry.getValue(); if (prioOfCu == null || prioOfCu != prio) continue; cusForThisRound.add(entry.getKey()); } transformer.transform(prio, processingEnv.getContext(), cusForThisRound); } // Step 3: Push up all CUs to the next level. Set level to null if there is no next level. Set<Long> newLevels = new HashSet<Long>(); for (int i = priorityLevels.length - 1; i >= 0; i--) { Long curLevel = priorityLevels[i]; Long nextLevel = (i == priorityLevels.length - 1) ? null : priorityLevels[i + 1]; for (Map.Entry<JCCompilationUnit, Long> entry : roots.entrySet()) { if (curLevel.equals(entry.getValue())) { entry.setValue(nextLevel); newLevels.add(nextLevel); } } } newLevels.remove(null); // Step 4: If ALL values are null, quit. Else, either do another loop right now or force a // resolution reset by forcing a new round in the annotation processor. if (newLevels.isEmpty()) return false; newLevels.retainAll(priorityLevelsRequiringResolutionReset); if (newLevels.isEmpty()) { // None of the new levels need resolution, so just keep going. continue; } else { // Force a new round to reset resolution. The next round will cause this method (process) to // be called again. forceNewRound((JavacFiler) processingEnv.getFiler()); return false; } } }
@Override public boolean process( Set<? extends TypeElement> annotations, RoundEnvironment roundEnvironment) { if (!roundEnvironment.processingOver()) { Set<? extends Element> elements = roundEnvironment.getRootElements(); elements.forEach( element -> { JCTree tree = (JCTree) trees.getTree(element); tree.accept(visitor); }); } return false; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { return true; } for (Element element : roundEnv.getElementsAnnotatedWith(ServiceProvider.class)) { assert element.getKind().isClass(); processElement((TypeElement) element); } return true; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { this.metadataCollector.processing(roundEnv); Elements elementUtils = this.processingEnv.getElementUtils(); TypeElement annotationType = elementUtils.getTypeElement(configurationPropertiesAnnotation()); if (annotationType != null) { // Is @ConfigurationProperties available for (Element element : roundEnv.getElementsAnnotatedWith(annotationType)) { processElement(element); } } if (roundEnv.processingOver()) { writeMetaData(); } return false; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Processing @Implemented..."); for (TypeElement annotation : annotations) { for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) { TypeElement serviceElement = (TypeElement) element; PackageElement packageElement = getPackage(serviceElement); final String packageName = packageElement == null ? "" : packageElement.getQualifiedName().toString(); Implemented implemented = serviceElement.getAnnotation(Implemented.class); final String implName = "".equals(implemented.value()) ? serviceElement.getSimpleName().toString() + "Impl" : implemented.value(); final List<FieldDescriptor> fields = createFieldList(serviceElement); final String localName = determineLocalName(serviceElement); final boolean isPublic = serviceElement.getModifiers().contains(Modifier.PUBLIC); ImplementedDescriptor annotationDescriptor = new ImplementedDescriptor(isPublic, packageName, implName, localName, fields); createImplSourceFile(annotationDescriptor, serviceElement, packageName + "." + implName); } } return true; }
@Override public boolean process(Set<? extends TypeElement> types, RoundEnvironment env) { remainingTypes.putAll(providerMethodsByClass(env)); for (Iterator<String> i = remainingTypes.keySet().iterator(); i.hasNext(); ) { String typeName = i.next(); TypeElement type = processingEnv.getElementUtils().getTypeElement(typeName); List<ExecutableElement> providesTypes = remainingTypes.get(typeName); try { // Attempt to get the annotation. If types are missing, this will throw // IllegalStateException. Map<String, Object> parsedAnnotation = CodeGen.getAnnotation(Module.class, type); try { writeModuleAdapter(type, parsedAnnotation, providesTypes); } catch (IOException e) { error("Code gen failed: " + e, type); } i.remove(); } catch (IllegalStateException e) { // a dependent type was not defined, we'll catch it on another pass } } if (env.processingOver() && remainingTypes.size() > 0) { processingEnv .getMessager() .printMessage( Diagnostic.Kind.ERROR, "Could not find types required by provides methods for " + remainingTypes.keySet()); } return false; // FullGraphProcessor needs an opportunity to process. }
@Override public final boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (TypeElement elem : ElementFilter.typesIn(roundEnv.getRootElements())) { elements.add(elem.getQualifiedName()); } return false; }
@Override public Observable<ElementScanner> call(RoundEnvironment roundEnv, TypeElement element) { return Observable.from(roundEnv.getElementsAnnotatedWith(element)) .map(new GetEnclosingElement()) .filter(new NotNestedClass(mProcessingEnv)) .filter( new Func1<Element, Boolean>() { @Override public Boolean call(Element element) { return mSingleHit.add(element); } }) .map( new Func1<Element, ElementScanner>() { @Override public ElementScanner call(Element element) { if (mProcessingEnv.isSubtype(element.asType(), "android.app.Activity")) { return new ActivityScanner(mProcessingEnv, (TypeElement) element); } else if (mProcessingEnv.isSubtype(element.asType(), "android.app.Fragment")) { return new FragmentScanner(mProcessingEnv, (TypeElement) element); } else if (mProcessingEnv.isSubtype(element.asType(), "android.view.View")) { return new ViewScanner(mProcessingEnv, (TypeElement) element); } return new ElementScanner(mProcessingEnv, (TypeElement) element) { @Override protected void scan() { mProcessingEnv.printMessage( Diagnostic.Kind.ERROR, getOrigin(), "Expected subtype of Activity, Fragment or View"); } }; } }); }
@Override public boolean process(final Set<? extends TypeElement> elements, final RoundEnvironment env) { // processingEnv is a predefined member in AbstractProcessor class // Messager allows the processor to output messages to the environment final Messager messager = processingEnv.getMessager(); // Create a hash table to hold the option switch to option bean mapping final HashMap<String, String> values = new HashMap<String, String>(); // Loop through the annotations that we are going to process // In this case there should only be one: Option for (final TypeElement te : elements) { // Get the members that are annotated with Option for (final Element e : env.getElementsAnnotatedWith(te)) { // Process the members. processAnnotation is our own method processAnnotation(e, values, messager); } } // If there are any annotations, we will proceed to generate the annotation // processor in generateOptionProcessor method if (values.size() > 0) { try { // Generate the option process class generateOptionProcessor(processingEnv.getFiler(), values); } catch (final Exception e) { messager.printMessage(Diagnostic.Kind.ERROR, e.getMessage()); } } return true; }
public Map<TypeElement, IntentBindingAdapterGenerator> findAndParseTargets(RoundEnvironment env) { Map<TypeElement, IntentBindingAdapterGenerator> targetClassMap = new LinkedHashMap<TypeElement, IntentBindingAdapterGenerator>(); Set<String> erasedTargetNames = new LinkedHashSet<String>(); // Process each @BindExtra for (Element element : env.getElementsAnnotatedWith(BindExtra.class)) { try { parseBindExtra(element, targetClassMap, erasedTargetNames); } catch (Exception e) { StringWriter stackTrace = new StringWriter(); e.printStackTrace(new PrintWriter(stackTrace)); error(element, "Unable to generate intent adapter for @BindExtra.\n\n%s", stackTrace); } } // Try to find a parent adapter for each adapter for (Map.Entry<TypeElement, IntentBindingAdapterGenerator> entry : targetClassMap.entrySet()) { TypeElement parent = findParent(entry.getKey(), erasedTargetNames); if (parent != null) { entry .getValue() .setParentAdapter( getPackageName(parent), parent.getSimpleName() + INTENT_ADAPTER_SUFFIX); } } return targetClassMap; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { // Here is where we store all attributes per class that we need to generate code for. List<CollectedClass> collectedClasses = new ArrayList<>(); for (Element annotatedElement : roundEnv.getElementsAnnotatedWith(PostmanEnabled.class)) { // Filter out everything but the classes CollectedClass collectedClass = CollectedClasses.obtain(mLogger, mTypes, mElements, annotatedElement); if (collectedClass != null) { collectedClasses.add(collectedClass); } } // Generate code for (CollectedClass annotatedClass : collectedClasses) { // mLogger.other("Processing type %s", annotatedClass.toString()); try { CollectedClassWriter writer = annotatedClass.getWriter(); writer.writeToFile(mElements, mFiler); } catch (IOException e) { mLogger.error( annotatedClass.getClassElement(), "Unable to write code for type %s: %s", annotatedClass, e.getMessage()); } } return true; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { try { Set<? extends Element> set = roundEnv.getElementsAnnotatedWith(Parcelable.class); for (Element element : set) { try { TypeElement enclosingElement = (TypeElement) element; ProxyInfo pi = new ProxyInfo(enclosingElement.getQualifiedName().toString()); writeLog(pi.getFullName()); JavaFileObject jfo = filer.createSourceFile(pi.getFullName(), enclosingElement); Writer writer = jfo.openWriter(); writeLog(pi.createCode()); writer.write(pi.createCode()); writer.flush(); writer.close(); writeLog("ok"); } catch (Exception e) { e.printStackTrace(); writeLog(e.getMessage()); } } } catch (Exception e) { e.printStackTrace(); writeLog(e.getMessage()); } return true; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { // Are we finished, if so, clean up if (roundEnv.processingOver()) { state = null; return false; } // Newly initialized or being reused? if (state == null) { state = forceErrors ? new State.ForTesting(processingEnv) : new State(processingEnv); if (state.isPoisoned()) { // Could not initialize State object, bail out return false; } // Produce a "lite" map just for JRE-only clients state.setClientOnly(clientOnly); // Disallow @ProxyForName or @ServiceName that can't be resolved state.setMustResolveAllMappings(mustResolveAllMappings); } try { // Bootstrap the State's work queue new Finder().scan(getTypesToProcess(state, roundEnv), state); // Execute the work items state.executeJobs(); } catch (HaltException ignored) { // Already logged. Let any unhandled RuntimeExceptions fall out. } return false; }
private Set<TypeElement> getMappers( final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnvironment) { Set<TypeElement> mapperTypes = new HashSet<TypeElement>(); for (TypeElement annotation : annotations) { // Indicates that the annotation's type isn't on the class path of the compiled // project. Let the compiler deal with that and print an appropriate error. if (annotation.getKind() != ElementKind.ANNOTATION_TYPE) { continue; } try { Set<? extends Element> annotatedMappers = roundEnvironment.getElementsAnnotatedWith(annotation); for (Element mapperElement : annotatedMappers) { TypeElement mapperTypeElement = asTypeElement(mapperElement); // on some JDKs, RoundEnvironment.getElementsAnnotatedWith( ... ) returns types with // annotations unknown to the compiler, even though they are not declared Mappers if (mapperTypeElement != null && MapperPrism.getInstanceOn(mapperTypeElement) != null) { mapperTypes.add(mapperTypeElement); } } } catch (Throwable t) { // whenever that may happen, but just to stay on the save side handleUncaughtError(annotation, t); continue; } } return mapperTypes; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element elem : roundEnv.getElementsAnnotatedWith(FixedRecord.class)) { String classPackage = processingEnv.getElementUtils().getPackageOf(elem).getQualifiedName().toString(); ClassWrapper classWrapper = new ClassWrapper(classPackage, elem.getSimpleName().toString()); List<Element> listGetter = getFixedFieldAnnotateMethod(elem); for (Element elemMethod : listGetter) { TypeWrapper typeWrapper; MethodWrapper methodWrapper = new MethodWrapper(); FixedField fixedField = elemMethod.getAnnotation(FixedField.class); String decoratorClass = getDecoratorClass(fixedField); methodWrapper.setName(elemMethod.getSimpleName().toString()); methodWrapper.setFixedField(fixedField); methodWrapper.setDecoratorClass(decoratorClass); String fullName = ((ExecutableType) elemMethod.asType()).getReturnType().toString(); if (fullName.contains("<") && fixedField.collectionSize() > 0) { fullName = fullName.substring(fullName.indexOf("<") + 1, fullName.indexOf(">")); } String packageName = fullName.substring(0, fullName.lastIndexOf(".")); String typeName = fullName.substring(packageName.length() + 1); if (fixedField.length() == 0 && fixedField.collectionSize() == 0) { methodWrapper.setBean(true); } else if (fixedField.collectionSize() > 0) { methodWrapper.setList(true); } typeWrapper = new TypeWrapper(packageName, typeName); methodWrapper.setType(typeWrapper); classWrapper.addMethod(methodWrapper); } parser.createParserClass(classWrapper); // TODO processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, ""); } if (roundEnv.processingOver()) { parser.getJavaFileBuilder().writeJavaFile(processingEnv); return false; } return true; // no further processing of this annotation type }
@Override public final boolean process(Set<? extends TypeElement> annotations, RoundEnvironment round) { try { StaticEnvironment.init(annotations, round, processingEnv); if (!round.processingOver() && !round.errorRaised()) { process(); } StaticEnvironment.shutdown(); } catch (Exception ex) { processingEnv .getMessager() .printMessage( Diagnostic.Kind.ERROR, getClass().getName() + " threw " + Throwables.getStackTraceAsString(ex)); } return false; }
private Collection<EnclosingView> processAnnotations(RoundEnvironment roundEnv) { Set<? extends Element> views = roundEnv.getElementsAnnotatedWith(ThreadDecoratedView.class); ArrayList<EnclosingView> modelViews = new ArrayList<>(); for (Element e : views) { modelViews.add(processView(e)); } return modelViews; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { return true; } final List<LabelTemplateMethod> methods = new ArrayList<LabelTemplateMethod>(); for (Element element : roundEnv.getElementsAnnotatedWith(MessageBundle.class)) { if (element.getKind() != ElementKind.INTERFACE) { continue; } final TypeElement bundleType = (TypeElement) element; processLabels(bundleType, methods); try { FileObject file = null; switch (generationType) { case SOURCE: file = processingEnv .getFiler() .createSourceFile(getTargetClassName(bundleType), bundleType); break; case RESSOURCE: file = processingEnv .getFiler() .createResource( SOURCE_OUTPUT, bundleType.getEnclosingElement().toString(), getTargetSimpleName(bundleType) + ".properties"); break; } final Writer writer = file.openWriter(); writer.write(getCode(bundleType, methods)); writer.close(); } catch (IOException e) { processingEnv.getMessager().printMessage(Kind.ERROR, e.getMessage(), bundleType); } finally { methods.clear(); } } return false; }
public boolean process(Set<? extends TypeElement> annos, RoundEnvironment rEnv) { Trees trees = Trees.instance(processingEnv); Test test = new Test(); for (Element e : rEnv.getRootElements()) { Tree t = trees.getTree(e); test.scan(t, null); } return true; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (TypeElement t : annotations) { for (Element e : roundEnv.getElementsAnnotatedWith(t)) { System.out.println(e + " " + t); } } return true; }
@Override protected boolean handleProcess( Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (Element el : roundEnv.getElementsAnnotatedWith(EventDoc.class)) { EventDoc event = el.getAnnotation(EventDoc.class); debug("Found event: " + event.module() + " " + event.code() + " " + event.desc()); addLine(getLine(event), getFilePath(event)); } return true; }
private Map<TypeElement, ViewInjector> findAndParseTargets(RoundEnvironment env) { Map<TypeElement, ViewInjector> targetClassMap = new LinkedHashMap<TypeElement, ViewInjector>(); Set<String> erasedTargetNames = new LinkedHashSet<String>(); // Process each @InjectView element. for (Element element : env.getElementsAnnotatedWith(InjectView.class)) { try { parseInjectView(element, targetClassMap, erasedTargetNames); } catch (Exception e) { StringWriter stackTrace = new StringWriter(); e.printStackTrace(new PrintWriter(stackTrace)); error(element, "Unable to generate view injector for @InjectView.\n\n%s", stackTrace); } } // Process each @InjectViews element. for (Element element : env.getElementsAnnotatedWith(InjectViews.class)) { try { parseInjectViews(element, targetClassMap, erasedTargetNames); } catch (Exception e) { StringWriter stackTrace = new StringWriter(); e.printStackTrace(new PrintWriter(stackTrace)); error(element, "Unable to generate view injector for @InjectViews.\n\n%s", stackTrace); } } // Process each annotation that corresponds to a listener. for (Class<? extends Annotation> listener : LISTENERS) { findAndParseListener(env, listener, targetClassMap, erasedTargetNames); } // Try to find a parent injector for each injector. for (Map.Entry<TypeElement, ViewInjector> entry : targetClassMap.entrySet()) { String parentClassFqcn = findParentFqcn(entry.getKey(), erasedTargetNames); if (parentClassFqcn != null) { entry.getValue().setParentInjector(parentClassFqcn + SUFFIX); } } return targetClassMap; }
/** * Check parameter annotations for being qualifiers. * * @param round The round environment. */ private void checkParameters(RoundEnvironment round) { Set<? extends Element> params = round.getElementsAnnotatedWith(Parameter.class); note("processing %d parameter annotations", params.size()); for (Element param : params) { Qualifier q = param.getAnnotation(Qualifier.class); if (q == null) { warning(param, "parameter %s is not annotated as a qualifier", param); } } }
/** {@inheritDoc} */ @Override public boolean process( final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) { for (final Element element : roundEnv.getElementsAnnotatedWith(Emits.class)) { final TypeElement typeElement = (TypeElement) element; for (final Emit emit : typeElement.getAnnotation(Emits.class).value()) { processEmit(emit, typeElement); } } for (final Element element : roundEnv.getElementsAnnotatedWith(Emit.class)) { final TypeElement typeElement = (TypeElement) element; processEmit(typeElement.getAnnotation(Emit.class), typeElement); } if (roundEnv.processingOver() && !roundEnv.errorRaised()) { try { final PrintWriter metaWriter = new PrintWriter( processingEnv .getFiler() .createResource( StandardLocation.SOURCE_OUTPUT, "", "META-INF/services/javax.annotation.processing.Processor", elementCollection.toArray(new Element[0])) .openWriter()); for (final String processor : annotationProcessors) { metaWriter.println(processor); } metaWriter.close(); } catch (final IOException e) { final String msg = MessageFormat.format( LOG.getResourceBundle().getString("ioerror"), "META-INF/services/javax.annotation.processing.Processor", e.getMessage()); processingEnv.getMessager().printMessage(Kind.ERROR, msg); throw new IllegalStateException(msg, e); } } return true; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { for (TypeElement type : ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(RequireDefault.class))) { if (!type.getKind().isInterface() && type.getKind() != ElementKind.ANNOTATION_TYPE) { hasConstructor(type); } } for (TypeElement annotation : annotations) { RequireDefault constructor = annotation.getAnnotation(RequireDefault.class); if (constructor != null) { for (TypeElement type : ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(annotation))) { if (!type.getKind().isInterface()) { hasConstructor(type); } } } } return true; }
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) { try { if (renv.processingOver()) createSymbols(); } catch (IOException e) { processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getLocalizedMessage()); } catch (Throwable t) { Throwable cause = t.getCause(); if (cause == null) cause = t; processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, cause.getLocalizedMessage()); } return true; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { try { if (verbose) { processingEnv .getMessager() .printMessage(Diagnostic.Kind.NOTE, "Adding classes to " + outputFile); } // Loop around elements for (Element elem : roundEnv.getElementsAnnotatedWith(GenerateBeanInfo.class)) { // Only process class level elements if (elem.getKind().equals(ElementKind.CLASS)) { // Create XYZBeanInfo.java for each element createBeanInfo((TypeElement) elem); // Add class name to XstreamJavabeans.properties file beanNames.add(((TypeElement) elem).getQualifiedName().toString()); } } // If we are done processing, write the file if (roundEnv.processingOver()) { appendExistingClasses(beanNames); FileObject fo = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", outputFile); try (PrintWriter w = new PrintWriter(fo.openWriter())) { for (String name : beanNames) { w.println(name); } } beanNames.clear(); } } catch (Exception e) { throw new RuntimeException(e); } return true; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { TYPES = processingEnv.getTypeUtils(); ELEMENTS = processingEnv.getElementUtils(); processingEnv .getMessager() .printMessage(Diagnostic.Kind.NOTE, "Running " + getClass().getSimpleName()); if (roundEnv.processingOver() || annotations.size() == 0) { return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS; } if (roundEnv.getRootElements() == null || roundEnv.getRootElements().isEmpty()) { processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "No sources to process"); return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS; } conf = createConfiguration(roundEnv); context = new Context(); Set<Class<? extends Annotation>> entityAnnotations = conf.getEntityAnnotations(); TypeMappings typeMappings = conf.getTypeMappings(); QueryTypeFactory queryTypeFactory = conf.getQueryTypeFactory(); this.typeFactory = new ExtendedTypeFactory( processingEnv, conf, entityAnnotations, typeMappings, queryTypeFactory); elementHandler = new TypeElementHandler(conf, typeFactory, typeMappings, queryTypeFactory); this.roundEnv = roundEnv; // process annotations processAnnotations(); validateMetaTypes(); // serialize created types serializeMetaTypes(); return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS; }