Source:
private Map<String, List<ExecutableElement>> providerMethodsByClass(RoundEnvironment env) { Map<String, List<ExecutableElement>> result = new HashMap<String, List<ExecutableElement>>(); for (Element providerMethod : providesMethods(env)) { TypeElement type = (TypeElement) providerMethod.getEnclosingElement(); Set<Modifier> typeModifiers = type.getModifiers(); if (type.getKind() != ElementKind.CLASS) { error("Unexpected @Provides on " + providerMethod, providerMethod); continue; } if (typeModifiers.contains(Modifier.PRIVATE) || typeModifiers.contains(Modifier.ABSTRACT)) { error("Classes declaring @Provides methods must not be private or abstract: " + type.getQualifiedName(), type); continue; } Set<Modifier> methodModifiers = providerMethod.getModifiers(); if (methodModifiers.contains(Modifier.PRIVATE) || methodModifiers.contains(Modifier.ABSTRACT) || methodModifiers.contains(Modifier.STATIC)) { error("@Provides methods must not be private, abstract or static: " + type.getQualifiedName() + "." + providerMethod, providerMethod); continue; } ExecutableElement providerMethodAsExecutable = (ExecutableElement) providerMethod; if (!providerMethodAsExecutable.getThrownTypes().isEmpty()) { error("@Provides methods must not have a throws clause: " + type.getQualifiedName() + "." + providerMethod, providerMethod); continue; } List<ExecutableElement> methods = result.get(type.getQualifiedName().toString()); if (methods == null) { methods = new ArrayList<ExecutableElement>(); result.put(type.getQualifiedName().toString(), methods); } methods.add(providerMethodAsExecutable); } Elements elementUtils = processingEnv.getElementUtils(); TypeMirror objectType = elementUtils.getTypeElement("java.lang.Object").asType(); for (Element module : env.getElementsAnnotatedWith(Module.class)) { if (module.getKind().equals(ElementKind.CLASS)) { TypeElement moduleType = (TypeElement) module; if (moduleType.getSuperclass().equals(objectType)) { error("Modules may not extend from other classes: " + moduleType, moduleType); } String moduleName = moduleType.getQualifiedName().toString(); if (result.containsKey(moduleName)) continue; result.put(moduleName, new ArrayList<ExecutableElement>()); } else { throw new AssertionError(); } } return result; }

Target:
private Map<String, List<ExecutableElement>> providerMethodsByClass(RoundEnvironment env) { Map<String, List<ExecutableElement>> result = new HashMap<String, List<ExecutableElement>>(); for (Element providerMethod : providesMethods(env)) { TypeElement type = (TypeElement) providerMethod.getEnclosingElement(); Set<Modifier> typeModifiers = type.getModifiers(); if (type.getKind() != ElementKind.CLASS) { error("Unexpected @Provides on " + providerMethod, providerMethod); continue; } if (typeModifiers.contains(Modifier.PRIVATE) || typeModifiers.contains(Modifier.ABSTRACT)) { error("Classes declaring @Provides methods must not be private or abstract: " + type.getQualifiedName(), type); continue; } Set<Modifier> methodModifiers = providerMethod.getModifiers(); if (methodModifiers.contains(Modifier.PRIVATE) || methodModifiers.contains(Modifier.ABSTRACT) || methodModifiers.contains(Modifier.STATIC)) { error("@Provides methods must not be private, abstract or static: " + type.getQualifiedName() + "." + providerMethod, providerMethod); continue; } ExecutableElement providerMethodAsExecutable = (ExecutableElement) providerMethod; if (!providerMethodAsExecutable.getThrownTypes().isEmpty()) { error("@Provides methods must not have a throws clause: " + type.getQualifiedName() + "." + providerMethod, providerMethod); continue; } List<ExecutableElement> methods = result.get(type.getQualifiedName().toString()); if (methods == null) { methods = new ArrayList<ExecutableElement>(); result.put(type.getQualifiedName().toString(), methods); } methods.add(providerMethodAsExecutable); } Elements elementUtils = processingEnv.getElementUtils(); TypeMirror objectType = elementUtils.getTypeElement("java.lang.Object").asType(); for (Element module : env.getElementsAnnotatedWith(Module.class)) { if (!module.getKind().equals(ElementKind.CLASS)) { error("Modules must be classes: " + module, module); continue; } TypeElement moduleType = (TypeElement) module; if (!moduleType.getSuperclass().equals(objectType)) { error("Modules must not extend from other classes: " + module, module); } String moduleName = moduleType.getQualifiedName().toString(); if (result.containsKey(moduleName)) continue; result.put(moduleName, new ArrayList<ExecutableElement>()); } return result; }