summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorweijiaxu <weijiaxu@google.com>2018-06-01 12:05:52 -0700
committerCopybara-Service <copybara-piper@google.com>2018-06-01 18:21:21 -0700
commit836b75d30853816739a0db0b69a34d03fd850b6b (patch)
tree7d6a06bc3a8f9beccbb86b4f938704131fb2b152 /java
parenta4f2caec2538c6992dd126190a5d20c4920a5a9f (diff)
Remove @GenerateTestDaggerApp from RCG.
Test: tap presubmit. PiperOrigin-RevId: 198907001 Change-Id: Ida32182c4d6a45334cb120e1e2183abae3af2a54
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/inject/DialerRootComponent.java2
-rw-r--r--java/com/android/dialer/rootcomponentgenerator/RootComponentGeneratingStep.java28
2 files changed, 14 insertions, 16 deletions
diff --git a/java/com/android/dialer/inject/DialerRootComponent.java b/java/com/android/dialer/inject/DialerRootComponent.java
index 11dbf962e..e508e17b6 100644
--- a/java/com/android/dialer/inject/DialerRootComponent.java
+++ b/java/com/android/dialer/inject/DialerRootComponent.java
@@ -41,4 +41,6 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
public @interface DialerRootComponent {
DialerVariant variant();
+
+ Class<?> injectClass() default Object.class;
}
diff --git a/java/com/android/dialer/rootcomponentgenerator/RootComponentGeneratingStep.java b/java/com/android/dialer/rootcomponentgenerator/RootComponentGeneratingStep.java
index 5321849ec..06b994ff7 100644
--- a/java/com/android/dialer/rootcomponentgenerator/RootComponentGeneratingStep.java
+++ b/java/com/android/dialer/rootcomponentgenerator/RootComponentGeneratingStep.java
@@ -26,7 +26,6 @@ import com.android.dialer.inject.DialerVariant;
import com.android.dialer.inject.IncludeInDialerRoot;
import com.android.dialer.inject.InstallIn;
import com.android.dialer.inject.RootComponentGeneratorMetadata;
-import com.android.dialer.inject.testing.GenerateTestDaggerApp;
import com.google.auto.common.BasicAnnotationProcessor.ProcessingStep;
import com.google.auto.common.MoreElements;
import com.google.common.base.Optional;
@@ -81,27 +80,18 @@ final class RootComponentGeneratingStep implements ProcessingStep {
private final ProcessingEnvironment processingEnv;
- private TypeElement annotatedTest;
-
public RootComponentGeneratingStep(ProcessingEnvironment processingEnv) {
this.processingEnv = processingEnv;
}
@Override
public Set<? extends Class<? extends Annotation>> annotations() {
- return ImmutableSet.of(
- DialerRootComponent.class,
- InstallIn.class,
- IncludeInDialerRoot.class,
- GenerateTestDaggerApp.class);
+ return ImmutableSet.of(DialerRootComponent.class, InstallIn.class, IncludeInDialerRoot.class);
}
@Override
public Set<? extends Element> process(
SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) {
- for (Element element : elementsByAnnotation.get(GenerateTestDaggerApp.class)) {
- annotatedTest = MoreElements.asType(element);
- }
for (Element element : elementsByAnnotation.get(DialerRootComponent.class)) {
// defer root components to the next round in case where the current build target contains
// elements annotated with @InstallIn. Annotation processor cannot detect metadata files
@@ -144,9 +134,15 @@ final class RootComponentGeneratingStep implements ProcessingStep {
componentAnnotation.addMember("modules", "$T.class", annotatedElement.asType());
}
rootComponentClassBuilder.addAnnotation(componentAnnotation.build());
- if (annotatedTest != null) {
- rootComponentClassBuilder.addMethod(generateInjectMethod());
- }
+
+ AnnotationMirror dialerRootComponentMirror =
+ getAnnotationMirror(rootElement, DialerRootComponent.class).get();
+
+ TypeMirror annotatedTestClass =
+ (TypeMirror) getAnnotationValue(dialerRootComponentMirror, "injectClass").getValue();
+
+ rootComponentClassBuilder.addMethod(generateInjectMethod(annotatedTestClass));
+
TypeSpec rootComponentClass = rootComponentClassBuilder.build();
RootComponentUtils.writeJavaFile(
processingEnv, ClassName.get(rootElement).packageName(), rootComponentClass);
@@ -200,11 +196,11 @@ final class RootComponentGeneratingStep implements ProcessingStep {
}
}
- private MethodSpec generateInjectMethod() {
+ private MethodSpec generateInjectMethod(TypeMirror testClassTypeMirror) {
return MethodSpec.methodBuilder("inject")
.addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
.returns(void.class)
- .addParameter(ClassName.get(annotatedTest), "test")
+ .addParameter(ClassName.get(testClassTypeMirror), "clazz")
.build();
}