Skip to content

Commit

Permalink
Rename model method from java() to javac().
Browse files Browse the repository at this point in the history
RELNOTES=N/A
PiperOrigin-RevId: 572362454
  • Loading branch information
bcorso authored and Dagger Team committed Oct 10, 2023
1 parent 8327177 commit 3c8d28c
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 28 deletions.
15 changes: 3 additions & 12 deletions java/dagger/hilt/processor/internal/DaggerModels.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand All @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion java/dagger/internal/codegen/model/DaggerAnnotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public XAnnotation xprocessing() {
return equivalenceWrapper().get();
}

public AnnotationMirror java() {
public AnnotationMirror javac() {
return toJavac(xprocessing());
}

Expand Down
2 changes: 1 addition & 1 deletion java/dagger/internal/codegen/model/DaggerElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static DaggerElement from(XElement element) {

public abstract XElement xprocessing();

public Element java() {
public Element javac() {
return toJavac(xprocessing());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static DaggerExecutableElement from(XExecutableElement executableElement)

public abstract XExecutableElement xprocessing();

public ExecutableElement java() {
public ExecutableElement javac() {
return toJavac(xprocessing());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Backend getBackend() {
return Backend.valueOf(xprocessing().getBackend().name());
}

public ProcessingEnvironment java() {
public ProcessingEnvironment javac() {
return toJavac(xprocessing());
}
}
2 changes: 1 addition & 1 deletion java/dagger/internal/codegen/model/DaggerType.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public XType xprocessing() {
return equivalenceWrapper().get();
}

public TypeMirror java() {
public TypeMirror javac() {
return toJavac(xprocessing());
}

Expand Down
2 changes: 1 addition & 1 deletion java/dagger/internal/codegen/model/DaggerTypeElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static DaggerTypeElement from(XTypeElement typeElement) {

public abstract XTypeElement xprocessing();

public TypeElement java() {
public TypeElement javac() {
return toJavac(xprocessing());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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(
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
Expand Down

0 comments on commit 3c8d28c

Please sign in to comment.