Skip to content

Commit

Permalink
Remove the usesProducers compiler option.
Browse files Browse the repository at this point in the history
This CL removes `CompilerOptions#usesProducers()` because it wasn't even a compiler option to begin with. In particular, users can't change this value with a particular flag, rather it just depends on whether producers is in your classpath or not.

RELNOTES=N/A
PiperOrigin-RevId: 682035690
  • Loading branch information
bcorso authored and Dagger Team committed Oct 4, 2024
1 parent 8ba8242 commit 0502bdd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
import static dagger.internal.codegen.extension.DaggerStreams.instancesOf;
import static javax.tools.Diagnostic.Kind.ERROR;

import androidx.room.compiler.processing.XProcessingEnv;
import dagger.internal.codegen.binding.KeyFactory;
import dagger.internal.codegen.compileroption.CompilerOptions;
import dagger.internal.codegen.javapoet.TypeNames;
import dagger.internal.codegen.model.Binding;
import dagger.internal.codegen.model.BindingGraph;
import dagger.internal.codegen.model.BindingGraph.MaybeBinding;
Expand All @@ -34,12 +35,12 @@
*/
// TODO(dpb,beder): Validate this during @Inject/@Provides/@Produces validation.
final class DependsOnProductionExecutorValidator extends ValidationBindingGraphPlugin {
private final CompilerOptions compilerOptions;
private final XProcessingEnv processingEnv;
private final KeyFactory keyFactory;

@Inject
DependsOnProductionExecutorValidator(CompilerOptions compilerOptions, KeyFactory keyFactory) {
this.compilerOptions = compilerOptions;
DependsOnProductionExecutorValidator(XProcessingEnv processingEnv, KeyFactory keyFactory) {
this.processingEnv = processingEnv;
this.keyFactory = keyFactory;
}

Expand All @@ -50,7 +51,7 @@ public String pluginName() {

@Override
public void visitGraph(BindingGraph bindingGraph, DiagnosticReporter diagnosticReporter) {
if (!compilerOptions.usesProducers()) {
if (!usesProducers()) {
return;
}

Expand All @@ -69,4 +70,8 @@ private void reportError(DiagnosticReporter diagnosticReporter, Binding binding)
diagnosticReporter.reportBinding(
ERROR, binding, "%s may not depend on the production executor", binding.key());
}

private boolean usesProducers() {
return processingEnv.findTypeElement(TypeNames.PRODUCES) != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

/** A collection of options that dictate how the compiler will run. */
public abstract class CompilerOptions {
public abstract boolean usesProducers();

/**
* Returns true if the fast initialization flag, {@code fastInit}, is enabled.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import dagger.internal.codegen.javapoet.TypeNames;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashMap;
Expand Down Expand Up @@ -96,11 +95,6 @@ public final class ProcessingEnvironmentCompilerOptions extends CompilerOptions
checkValid();
}

@Override
public boolean usesProducers() {
return processingEnv.findTypeElement(TypeNames.PRODUCES) != null;
}

@Override
public boolean headerCompilation() {
return isEnabled(HEADER_COMPILATION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ final class JavacPluginCompilerOptions extends CompilerOptions {
@Inject
JavacPluginCompilerOptions() {}

@Override
public boolean usesProducers() {
return true;
}

@Override
public boolean fastInit(XTypeElement element) {
return false;
Expand Down

0 comments on commit 0502bdd

Please sign in to comment.