From 6cdab843a677c478db1b0f487c6796800dfed36e Mon Sep 17 00:00:00 2001 From: Brad Corso Date: Mon, 9 Oct 2023 13:17:14 -0700 Subject: [PATCH] Rename model method from `java()` to `javac()`. RELNOTES=N/A PiperOrigin-RevId: 572022320 --- .../hilt/processor/internal/DaggerModels.kt | 15 +++------------ .../codegen/model/DaggerAnnotation.java | 2 +- .../internal/codegen/model/DaggerElement.java | 2 +- .../codegen/model/DaggerExecutableElement.java | 2 +- .../codegen/model/DaggerProcessingEnv.java | 2 +- .../internal/codegen/model/DaggerType.java | 2 +- .../codegen/model/DaggerTypeElement.java | 2 +- .../codegen/model/MoreAnnotationMirrors.java | 2 +- .../validation/ModelBindingGraphConverter.java | 18 +++++++++--------- 9 files changed, 19 insertions(+), 28 deletions(-) diff --git a/java/dagger/hilt/processor/internal/DaggerModels.kt b/java/dagger/hilt/processor/internal/DaggerModels.kt index f875df27bb8..9fe0cf4f722 100644 --- a/java/dagger/hilt/processor/internal/DaggerModels.kt +++ b/java/dagger/hilt/processor/internal/DaggerModels.kt @@ -30,10 +30,7 @@ import dagger.spi.model.DaggerType fun DaggerType.hasAnnotation(className: ClassName): Boolean = when (checkNotNull(backend())) { - JAVAC -> { - val javac = javac() - Processors.hasAnnotation(MoreTypes.asTypeElement(javac), className) - } + JAVAC -> Processors.hasAnnotation(MoreTypes.asTypeElement(javac()), className) KSP -> ksp().declaration.hasAnnotation(className.canonicalName()) } @@ -44,19 +41,13 @@ fun KSDeclaration.hasAnnotation(annotationName: String): Boolean = fun DaggerElement.hasAnnotation(className: ClassName) = when (checkNotNull(backend())) { - JAVAC -> { - val javac = javac() - Processors.hasAnnotation(javac, className) - } + JAVAC -> Processors.hasAnnotation(javac(), className) KSP -> ksp().hasAnnotation(className) } fun DaggerAnnotation.getQualifiedName() = when (checkNotNull(backend())) { - JAVAC -> { - val javac = javac() - MoreTypes.asTypeElement(javac.annotationType).qualifiedName.toString() - } + JAVAC -> MoreTypes.asTypeElement(javac().annotationType).qualifiedName.toString() KSP -> ksp().annotationType.resolve().declaration.qualifiedName!!.asString() } diff --git a/java/dagger/internal/codegen/model/DaggerAnnotation.java b/java/dagger/internal/codegen/model/DaggerAnnotation.java index 4a598719a3f..23b18e4c874 100644 --- a/java/dagger/internal/codegen/model/DaggerAnnotation.java +++ b/java/dagger/internal/codegen/model/DaggerAnnotation.java @@ -49,7 +49,7 @@ public XAnnotation xprocessing() { return equivalenceWrapper().get(); } - public AnnotationMirror java() { + public AnnotationMirror javac() { return toJavac(xprocessing()); } diff --git a/java/dagger/internal/codegen/model/DaggerElement.java b/java/dagger/internal/codegen/model/DaggerElement.java index cf2ac52fb9c..2de01a18f89 100644 --- a/java/dagger/internal/codegen/model/DaggerElement.java +++ b/java/dagger/internal/codegen/model/DaggerElement.java @@ -31,7 +31,7 @@ public static DaggerElement from(XElement element) { public abstract XElement xprocessing(); - public Element java() { + public Element javac() { return toJavac(xprocessing()); } diff --git a/java/dagger/internal/codegen/model/DaggerExecutableElement.java b/java/dagger/internal/codegen/model/DaggerExecutableElement.java index 484e446e217..42ce1fc975d 100644 --- a/java/dagger/internal/codegen/model/DaggerExecutableElement.java +++ b/java/dagger/internal/codegen/model/DaggerExecutableElement.java @@ -32,7 +32,7 @@ public static DaggerExecutableElement from(XExecutableElement executableElement) public abstract XExecutableElement xprocessing(); - public ExecutableElement java() { + public ExecutableElement javac() { return toJavac(xprocessing()); } diff --git a/java/dagger/internal/codegen/model/DaggerProcessingEnv.java b/java/dagger/internal/codegen/model/DaggerProcessingEnv.java index 6645b90beb9..44308293aca 100644 --- a/java/dagger/internal/codegen/model/DaggerProcessingEnv.java +++ b/java/dagger/internal/codegen/model/DaggerProcessingEnv.java @@ -39,7 +39,7 @@ public Backend getBackend() { return Backend.valueOf(xprocessing().getBackend().name()); } - public ProcessingEnvironment java() { + public ProcessingEnvironment javac() { return toJavac(xprocessing()); } } diff --git a/java/dagger/internal/codegen/model/DaggerType.java b/java/dagger/internal/codegen/model/DaggerType.java index c606f15e0fb..b6f0beb7269 100644 --- a/java/dagger/internal/codegen/model/DaggerType.java +++ b/java/dagger/internal/codegen/model/DaggerType.java @@ -39,7 +39,7 @@ public XType xprocessing() { return equivalenceWrapper().get(); } - public TypeMirror java() { + public TypeMirror javac() { return toJavac(xprocessing()); } diff --git a/java/dagger/internal/codegen/model/DaggerTypeElement.java b/java/dagger/internal/codegen/model/DaggerTypeElement.java index 77e0c4ffd9c..1bfab067db1 100644 --- a/java/dagger/internal/codegen/model/DaggerTypeElement.java +++ b/java/dagger/internal/codegen/model/DaggerTypeElement.java @@ -32,7 +32,7 @@ public static DaggerTypeElement from(XTypeElement typeElement) { public abstract XTypeElement xprocessing(); - public TypeElement java() { + public TypeElement javac() { return toJavac(xprocessing()); } diff --git a/java/dagger/internal/codegen/model/MoreAnnotationMirrors.java b/java/dagger/internal/codegen/model/MoreAnnotationMirrors.java index 9b45b891f6b..ade1f28e806 100644 --- a/java/dagger/internal/codegen/model/MoreAnnotationMirrors.java +++ b/java/dagger/internal/codegen/model/MoreAnnotationMirrors.java @@ -35,7 +35,7 @@ final class MoreAnnotationMirrors { * defined in the annotation type. */ public static String toStableString(DaggerAnnotation qualifier) { - return stableAnnotationMirrorToString(qualifier.java()); + return stableAnnotationMirrorToString(qualifier.javac()); } /** diff --git a/java/dagger/internal/codegen/validation/ModelBindingGraphConverter.java b/java/dagger/internal/codegen/validation/ModelBindingGraphConverter.java index 314ed5fb494..ae53978d5c9 100644 --- a/java/dagger/internal/codegen/validation/ModelBindingGraphConverter.java +++ b/java/dagger/internal/codegen/validation/ModelBindingGraphConverter.java @@ -134,8 +134,8 @@ private static MultibindingContributionIdentifier toModel( } private static Key toModel(dagger.internal.codegen.model.Key key) { - return Key.builder(key.type().java()) - .qualifier(key.qualifier().map(DaggerAnnotation::java)) + return Key.builder(key.type().javac()) + .qualifier(key.qualifier().map(DaggerAnnotation::javac)) .multibindingContributionIdentifier( key.multibindingContributionIdentifier().isPresent() ? Optional.of(toModel(key.multibindingContributionIdentifier().get())) @@ -159,17 +159,17 @@ private static DependencyRequest toModel( .key(toModel(request.key())) .isNullable(request.isNullable()); - request.requestElement().ifPresent(e -> builder.requestElement(e.java())); + request.requestElement().ifPresent(e -> builder.requestElement(e.javac())); return builder.build(); } private static Scope toModel(dagger.internal.codegen.model.Scope scope) { - return Scope.scope(scope.scopeAnnotation().java()); + return Scope.scope(scope.scopeAnnotation().javac()); } private static ComponentPath toModel(dagger.internal.codegen.model.ComponentPath path) { return ComponentPath.create( - path.components().stream().map(DaggerTypeElement::java).collect(toImmutableList())); + path.components().stream().map(DaggerTypeElement::javac).collect(toImmutableList())); } private static dagger.internal.codegen.model.BindingGraph.ComponentNode toInternal( @@ -232,8 +232,8 @@ static Binding create(dagger.internal.codegen.model.Binding binding) { binding.dependencies().stream() .map(ModelBindingGraphConverter::toModel) .collect(toImmutableSet()), - binding.bindingElement().map(DaggerElement::java), - binding.contributingModule().map(DaggerTypeElement::java), + binding.bindingElement().map(DaggerElement::javac), + binding.contributingModule().map(DaggerTypeElement::javac), binding.requiresModuleInstance(), binding.scope().map(ModelBindingGraphConverter::toModel), binding.isNullable(), @@ -291,7 +291,7 @@ abstract static class ChildFactoryMethodEdgeImpl implements ChildFactoryMethodEd static ChildFactoryMethodEdge create( dagger.internal.codegen.model.BindingGraph.ChildFactoryMethodEdge childFactoryMethodEdge) { return new AutoValue_ModelBindingGraphConverter_ChildFactoryMethodEdgeImpl( - childFactoryMethodEdge.factoryMethod().java(), childFactoryMethodEdge); + childFactoryMethodEdge.factoryMethod().javac(), childFactoryMethodEdge); } abstract dagger.internal.codegen.model.BindingGraph.ChildFactoryMethodEdge delegate(); @@ -310,7 +310,7 @@ static SubcomponentCreatorBindingEdge create( subcomponentCreatorBindingEdge) { return new AutoValue_ModelBindingGraphConverter_SubcomponentCreatorBindingEdgeImpl( subcomponentCreatorBindingEdge.declaringModules().stream() - .map(DaggerTypeElement::java) + .map(DaggerTypeElement::javac) .collect(toImmutableSet()), subcomponentCreatorBindingEdge); }