private void processInjectAnnotatedField(VariableElement fieldElement, Map<TypeElement, List<FieldInjectionTarget>> mapTypeElementToMemberInjectorTargetList) { TypeElement enclosingElement = (TypeElement) fieldElement.getEnclosingElement(); // Verify common generated code restrictions. if (!isValidInjectAnnotatedFieldOrParameter(fieldElement)) { return; } List<FieldInjectionTarget> fieldInjectionTargetList = mapTypeElementToMemberInjectorTargetList.get(enclosingElement); if (fieldInjectionTargetList == null) { fieldInjectionTargetList = new ArrayList<>(); mapTypeElementToMemberInjectorTargetList.put(enclosingElement, fieldInjectionTargetList); } mapTypeToMostDirectSuperTypeThatNeedsInjection(enclosingElement); fieldInjectionTargetList.add(createFieldOrParamInjectionTarget(fieldElement)); }
private void processInjectAnnotatedMethod(ExecutableElement methodElement, Map<TypeElement, List<MethodInjectionTarget>> mapTypeElementToMemberInjectorTargetList) { TypeElement enclosingElement = (TypeElement) methodElement.getEnclosingElement(); // Verify common generated code restrictions. if (!isValidInjectAnnotatedMethod(methodElement)) { return; } List<MethodInjectionTarget> methodInjectionTargetList = mapTypeElementToMemberInjectorTargetList.get(enclosingElement); if (methodInjectionTargetList == null) { methodInjectionTargetList = new ArrayList<>(); mapTypeElementToMemberInjectorTargetList.put(enclosingElement, methodInjectionTargetList); } mapTypeToMostDirectSuperTypeThatNeedsInjection(enclosingElement); methodInjectionTargetList.add(createMethodInjectionTarget(methodElement)); }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (hasAlreadyRun()) { return false; wasRun(); readCommonProcessorOptions(); readOptionCrashWhenMethodIsNotPackageProtected(); findAndParseTargets(roundEnv); boolean success = writeToFile(memberInjectorGenerator, fileDescription, typeElement); if (success) { elementsWithMemberInjectorCreated.add(typeElement); writeToFile(new RegistryGenerator(registryInjectionTarget, typeUtils), fileDescription, allTypes);
protected void processInjectAnnotatedMethods(RoundEnvironment roundEnv) { for (ExecutableElement element : ElementFilter.methodsIn(roundEnv.getElementsAnnotatedWith(Inject.class))) { if (!isExcludedByFilters((TypeElement) element.getEnclosingElement())) { processInjectAnnotatedMethod(element, mapTypeElementToMethodInjectorTargetList); } } }
private MethodInjectionTarget createMethodInjectionTarget(ExecutableElement methodElement) { TypeElement enclosingElement = (TypeElement) methodElement.getEnclosingElement(); final String methodName = methodElement.getSimpleName().toString(); boolean isOverride = isOverride(enclosingElement, methodElement); MethodInjectionTarget methodInjectionTarget = new MethodInjectionTarget(enclosingElement, methodName, isOverride); methodInjectionTarget.parameters.addAll(getParamInjectionTargetList(methodElement)); return methodInjectionTarget; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { readCommonProcessorOptions(); readOptionCrashWhenMethodIsNotPackageProtected(); mapTypeElementToFieldInjectorTargetList = new LinkedHashMap<>(); mapTypeElementToMethodInjectorTargetList = new LinkedHashMap<>(); mapTypeElementToSuperTypeElementThatNeedsInjection = new LinkedHashMap<>(); findAndParseTargets(roundEnv); // Generate member scopes Set<TypeElement> elementWithInjectionSet = new HashSet<>(); elementWithInjectionSet.addAll(mapTypeElementToFieldInjectorTargetList.keySet()); elementWithInjectionSet.addAll(mapTypeElementToMethodInjectorTargetList.keySet()); for (TypeElement typeElement : elementWithInjectionSet) { List<FieldInjectionTarget> fieldInjectionTargetList = mapTypeElementToFieldInjectorTargetList.get(typeElement); List<MethodInjectionTarget> methodInjectionTargetList = mapTypeElementToMethodInjectorTargetList.get(typeElement); TypeElement superClassThatNeedsInjection = mapTypeElementToSuperTypeElementThatNeedsInjection.get(typeElement); MemberInjectorGenerator memberInjectorGenerator = new MemberInjectorGenerator(typeElement, // superClassThatNeedsInjection, // fieldInjectionTargetList, // methodInjectionTargetList, // typeUtils); String fileDescription = String.format("MemberInjector for type %s", typeElement); writeToFile(memberInjectorGenerator, fileDescription, typeElement); allRoundsGeneratedToTypeElement.put(memberInjectorGenerator.getFqcn(), typeElement); } return false; }
protected void processInjectAnnotatedFields(RoundEnvironment roundEnv) { for (VariableElement element : ElementFilter.fieldsIn(roundEnv.getElementsAnnotatedWith(Inject.class))) { if (!isExcludedByFilters((TypeElement) element.getEnclosingElement())) { processInjectAnnotatedField(element, mapTypeElementToFieldInjectorTargetList); } } }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { readProcessorOptions(); findAndParseTargets(roundEnv); new MemberInjectorGenerator(typeElement, superClassThatNeedsInjection, fieldInjectionTargetList, methodInjectionTargetList); String fileDescription = String.format("MemberInjector for type %s", typeElement); boolean success = writeToFile(memberInjectorGenerator, fileDescription, typeElement); if (success) { elementsWithMemberInjectorCreated.add(typeElement); writeToFile(registryGenerator, fileDescription, allTypes);
private void mapTypeToMostDirectSuperTypeThatNeedsInjection(TypeElement typeElement) { TypeElement superClassWithInjectedMembers = getMostDirectSuperClassWithInjectedMembers(typeElement, true); mapTypeElementToSuperTypeElementThatNeedsInjection.put(typeElement, superClassWithInjectedMembers); }
protected void processInjectAnnotatedFields(RoundEnvironment roundEnv) { for (VariableElement element : ElementFilter.fieldsIn(roundEnv.getElementsAnnotatedWith(Inject.class))) { if (!isExcludedByFilters((TypeElement) element.getEnclosingElement())) { processInjectAnnotatedField(element, mapTypeElementToFieldInjectorTargetList); } } }
protected void processInjectAnnotatedMethods(RoundEnvironment roundEnv) { for (ExecutableElement element : ElementFilter.methodsIn(roundEnv.getElementsAnnotatedWith(Inject.class))) { if (!isExcludedByFilters((TypeElement) element.getEnclosingElement())) { processInjectAnnotatedMethod(element, mapTypeElementToMethodInjectorTargetList); } } }
private MethodInjectionTarget createMethodInjectionTarget(ExecutableElement methodElement) { TypeElement enclosingElement = (TypeElement) methodElement.getEnclosingElement(); final String methodName = methodElement.getSimpleName().toString(); boolean isOverride = isOverride(enclosingElement, methodElement); MethodInjectionTarget methodInjectionTarget = new MethodInjectionTarget(enclosingElement, methodName, isOverride); methodInjectionTarget.parameters.addAll(getParamInjectionTargetList(methodElement)); return methodInjectionTarget; }
private void mapTypeToMostDirectSuperTypeThatNeedsInjection(TypeElement typeElement) { TypeElement superClassWithInjectedMembers = getMostDirectSuperClassWithInjectedMembers(typeElement, true); mapTypeElementToSuperTypeElementThatNeedsInjection.put(typeElement, superClassWithInjectedMembers); }
private void processInjectAnnotatedField(VariableElement fieldElement, Map<TypeElement, List<FieldInjectionTarget>> mapTypeElementToMemberInjectorTargetList) { TypeElement enclosingElement = (TypeElement) fieldElement.getEnclosingElement(); // Verify common generated code restrictions. if (!isValidInjectAnnotatedFieldOrParameter(fieldElement)) { return; } List<FieldInjectionTarget> fieldInjectionTargetList = mapTypeElementToMemberInjectorTargetList.get(enclosingElement); if (fieldInjectionTargetList == null) { fieldInjectionTargetList = new ArrayList<>(); mapTypeElementToMemberInjectorTargetList.put(enclosingElement, fieldInjectionTargetList); } mapTypeToMostDirectSuperTypeThatNeedsInjection(enclosingElement); fieldInjectionTargetList.add(createFieldOrParamInjectionTarget(fieldElement)); }
private void processInjectAnnotatedMethod(ExecutableElement methodElement, Map<TypeElement, List<MethodInjectionTarget>> mapTypeElementToMemberInjectorTargetList) { TypeElement enclosingElement = (TypeElement) methodElement.getEnclosingElement(); // Verify common generated code restrictions. if (!isValidInjectAnnotatedMethod(methodElement)) { return; } List<MethodInjectionTarget> methodInjectionTargetList = mapTypeElementToMemberInjectorTargetList.get(enclosingElement); if (methodInjectionTargetList == null) { methodInjectionTargetList = new ArrayList<>(); mapTypeElementToMemberInjectorTargetList.put(enclosingElement, methodInjectionTargetList); } mapTypeToMostDirectSuperTypeThatNeedsInjection(enclosingElement); methodInjectionTargetList.add(createMethodInjectionTarget(methodElement)); }
protected void processInjectAnnotatedFields(RoundEnvironment roundEnv) { for (VariableElement element : ElementFilter.fieldsIn(roundEnv.getElementsAnnotatedWith(Inject.class))) { if (!isExcludedByFilters((TypeElement) element.getEnclosingElement())) { processInjectAnnotatedField(element, mapTypeElementToFieldInjectorTargetList); } } }
protected void processInjectAnnotatedMethods(RoundEnvironment roundEnv) { for (ExecutableElement element : ElementFilter.methodsIn(roundEnv.getElementsAnnotatedWith(Inject.class))) { if (!isExcludedByFilters((TypeElement) element.getEnclosingElement())) { processInjectAnnotatedMethod(element, mapTypeElementToMethodInjectorTargetList); } } }
private MethodInjectionTarget createMethodInjectionTarget(ExecutableElement methodElement) { TypeElement enclosingElement = (TypeElement) methodElement.getEnclosingElement(); final String methodName = methodElement.getSimpleName().toString(); boolean isOverride = isOverride(enclosingElement, methodElement); MethodInjectionTarget methodInjectionTarget = new MethodInjectionTarget(enclosingElement, methodName, isOverride); methodInjectionTarget.parameters.addAll(getParamInjectionTargetList(methodElement)); return methodInjectionTarget; }
private void mapTypeToMostDirectSuperTypeThatNeedsInjection(TypeElement typeElement) { TypeElement superClassWithInjectedMembers = getMostDirectSuperClassWithInjectedMembers(typeElement, true); mapTypeElementToSuperTypeElementThatNeedsInjection.put(typeElement, superClassWithInjectedMembers); }
private void processInjectAnnotatedField(VariableElement fieldElement, Map<TypeElement, List<FieldInjectionTarget>> mapTypeElementToMemberInjectorTargetList) { TypeElement enclosingElement = (TypeElement) fieldElement.getEnclosingElement(); // Verify common generated code restrictions. if (!isValidInjectAnnotatedFieldOrParameter(fieldElement)) { return; } List<FieldInjectionTarget> fieldInjectionTargetList = mapTypeElementToMemberInjectorTargetList.get(enclosingElement); if (fieldInjectionTargetList == null) { fieldInjectionTargetList = new ArrayList<>(); mapTypeElementToMemberInjectorTargetList.put(enclosingElement, fieldInjectionTargetList); } mapTypeToMostDirectSuperTypeThatNeedsInjection(enclosingElement); fieldInjectionTargetList.add(createFieldOrParamInjectionTarget(fieldElement)); }