Skip to content

Commit

Permalink
Refactor Dagger ComponentProcessor to use @Component.Factory
Browse files Browse the repository at this point in the history
It's a slight improvement to remove some of the boiler-plate of @Component.Builder.

RELNOTES=N/A

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=299978182
  • Loading branch information
bcorso authored and netdpb committed Mar 10, 2020
1 parent 5948fb2 commit 2300b53
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions java/dagger/internal/codegen/ComponentProcessor.java
Expand Up @@ -25,7 +25,6 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.CheckReturnValue;
import dagger.BindsInstance;
import dagger.Component;
Expand Down Expand Up @@ -122,11 +121,7 @@ public Set<String> getSupportedOptions() {

@Override
protected Iterable<? extends ProcessingStep> initSteps() {
ProcessorComponent.builder()
.processingEnvironment(processingEnv)
.testingPlugins(testingPlugins)
.build()
.inject(this);
ProcessorComponent.factory().create(processingEnv, testingPlugins).inject(this);

statisticsCollector.processingStarted();
bindingGraphPlugins.initializePlugins();
Expand All @@ -152,21 +147,16 @@ protected Iterable<? extends ProcessingStep> initSteps() {
interface ProcessorComponent {
void inject(ComponentProcessor processor);

static Builder builder() {
return DaggerComponentProcessor_ProcessorComponent.builder();
static Factory factory() {
return DaggerComponentProcessor_ProcessorComponent.factory();
}

@CanIgnoreReturnValue
@Component.Builder
interface Builder {
@BindsInstance
Builder processingEnvironment(ProcessingEnvironment processingEnv);

@BindsInstance
Builder testingPlugins(
@TestingPlugins Optional<ImmutableSet<BindingGraphPlugin>> testingPlugins);

@CheckReturnValue ProcessorComponent build();
@Component.Factory
interface Factory {
@CheckReturnValue
ProcessorComponent create(
@BindsInstance ProcessingEnvironment processingEnv,
@BindsInstance @TestingPlugins Optional<ImmutableSet<BindingGraphPlugin>> testingPlugins);
}
}

Expand Down

0 comments on commit 2300b53

Please sign in to comment.