Skip to content

Commit

Permalink
Migrate Processors.java and clients to XProcessing
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 525116305
  • Loading branch information
kuanyingchou authored and Dagger Team committed Apr 18, 2023
1 parent 284bb54 commit 4ee57b2
Show file tree
Hide file tree
Showing 17 changed files with 171 additions and 659 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import static java.util.Comparator.comparing;

import androidx.room.compiler.processing.JavaPoetExtKt;
import androidx.room.compiler.processing.XFiler.Mode;
import androidx.room.compiler.processing.XProcessingEnv;
import com.google.common.collect.ImmutableSet;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.CodeBlock;
Expand All @@ -40,7 +42,6 @@
import dagger.multibindings.IntoMap;
import dagger.multibindings.IntoSet;
import java.io.IOException;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Modifier;

/**
Expand All @@ -49,12 +50,12 @@
final class BindValueGenerator {
private static final String SUFFIX = "_BindValueModule";

private final ProcessingEnvironment env;
private final XProcessingEnv env;
private final BindValueMetadata metadata;
private final ClassName testClassName;
private final ClassName className;

BindValueGenerator(ProcessingEnvironment env, BindValueMetadata metadata) {
BindValueGenerator(XProcessingEnv env, BindValueMetadata metadata) {
this.env = env;
this.metadata = metadata;
testClassName = metadata.testElement().getClassName();
Expand Down Expand Up @@ -83,9 +84,8 @@ void generate() throws IOException {
.sorted(comparing(MethodSpec::toString))
.forEachOrdered(builder::addMethod);

JavaFile.builder(className.packageName(), builder.build())
.build()
.writeTo(env.getFiler());
env.getFiler()
.write(JavaFile.builder(className.packageName(), builder.build()).build(), Mode.Isolating);
}

// @Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void postRoundProcess(XRoundEnv roundEnv) throws Exception {
// Generate a module for each testing class with a @BindValue field.
for (Map.Entry<XTypeElement, Collection<XElement>> e : testRootMap.asMap().entrySet()) {
BindValueMetadata metadata = BindValueMetadata.create(e.getKey(), e.getValue());
new BindValueGenerator(getProcessingEnv(), metadata).generate();
new BindValueGenerator(processingEnv(), metadata).generate();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static ImmutableSet<XTypeElement> unwrapProxies(

private static XTypeElement unwrapProxy(XTypeElement element) {
return element.hasAnnotation(ClassNames.AGGREGATED_ELEMENT_PROXY)
? Processors.getAnnotationClassValue(
? XAnnotations.getAsTypeElement(
element.getAnnotation(ClassNames.AGGREGATED_ELEMENT_PROXY), "value")
: element;
}
Expand Down
Loading

0 comments on commit 4ee57b2

Please sign in to comment.