private void validateProvides(Element element) { if (element.getAnnotation(Provides.class) != null && Util.getAnnotation(Module.class, element.getEnclosingElement()) == null) { error("@Provides methods must be declared in modules: " + elementToString(element), element); } }
@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 // CodeGenerationIncompleteException. Map<String, Object> parsedAnnotation = getAnnotation(Module.class, type); if (parsedAnnotation == null) { error(type + " has @Provides methods but no @Module annotation", type); continue; } JavaFile javaFile = generateModuleAdapter(type, parsedAnnotation, providesTypes); javaFile.writeTo(processingEnv.getFiler()); } catch (CodeGenerationIncompleteException e) { continue; // A dependent type was not defined, we'll try to catch it on another pass. } catch (IOException e) { error("Code gen failed: " + e, type); } i.remove(); } 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. }
void collectIncludesRecursively( TypeElement module, Map<String, TypeElement> result, Deque<String> path) { Map<String, Object> annotation = getAnnotation(Module.class, module); if (annotation == null) {
Map<String, Object> annotation = null; try { annotation = getAnnotation(Module.class, element); } catch (CodeGenerationIncompleteException e) { continue; // skip this element. An up-stream compiler error is in play.
Map<String, Object> annotation = getAnnotation(Module.class, module); boolean overrides = (Boolean) annotation.get("overrides"); boolean library = (Boolean) annotation.get("library");