From 3a329a003e551f1e7280c88b68481c83784a027f Mon Sep 17 00:00:00 2001 From: Nicholas Doglio <3968678+WhosNickDoglio@users.noreply.github.com> Date: Sat, 19 Oct 2024 21:09:55 -0400 Subject: [PATCH] Move KSP util functions into compiler-utils and make them public (#75) --- compiler-utils/api/compiler-utils.api | 99 +++++++++++++++++++ compiler-utils/build.gradle.kts | 3 +- .../dependencies/runtimeClasspath.txt | 4 + .../squareup/anvil/compiler/internal/Utils.kt | 7 ++ .../internal}/ksp/KSAnnotationExtensions.kt | 54 +++++----- .../ksp/KSClassDeclarationExtensions.kt | 18 ++-- .../internal}/ksp/KspAnvilExceptions.kt | 10 +- .../anvil/compiler/internal}/ksp/KspUtil.kt | 98 +++++++++--------- compiler/dependencies/runtimeClasspath.txt | 3 + .../anvil/compiler/ClassScannerKsp.kt | 20 ++-- .../anvil/compiler/ContributedBinding.kt | 4 +- .../anvil/compiler/IrContributionMerger.kt | 1 + .../anvil/compiler/KspContributionMerger.kt | 69 ++++++------- .../java/com/squareup/anvil/compiler/Utils.kt | 7 -- .../codegen/ContributesBindingCodeGen.kt | 25 +++-- .../codegen/ContributesMultibindingCodeGen.kt | 29 +++--- .../codegen/ContributesSubcomponentCodeGen.kt | 16 +-- .../compiler/codegen/ContributesToCodeGen.kt | 15 ++- ...butesSubcomponentHandlerSymbolProcessor.kt | 39 ++++---- ...KspMergeAnnotationsCheckSymbolProcessor.kt | 18 ++-- .../dagger/AnvilAnnotationDetectorCheck.kt | 2 +- .../AnvilMergeAnnotationDetectorCheck.kt | 2 +- .../codegen/dagger/AssistedFactoryCodeGen.kt | 12 +-- .../codegen/dagger/AssistedInjectCodeGen.kt | 6 +- .../codegen/dagger/BindsMethodValidator.kt | 20 ++-- .../codegen/dagger/ComponentDetectorCheck.kt | 2 +- .../codegen/dagger/DaggerGenerationUtils.kt | 20 ++-- .../dagger/InjectConstructorFactoryCodeGen.kt | 4 +- .../codegen/dagger/MapKeyCreatorCodeGen.kt | 6 +- .../dagger/ProvidesMethodFactoryCodeGen.kt | 19 ++-- .../codegen/ksp/AnvilSymbolProcessing.kt | 1 + .../anvil/compiler/codegen/ksp/KSCallable.kt | 2 + .../reference/MemberFunctionReferenceTest.kt | 1 + 33 files changed, 372 insertions(+), 264 deletions(-) rename {compiler/src/main/java/com/squareup/anvil/compiler/codegen => compiler-utils/src/main/java/com/squareup/anvil/compiler/internal}/ksp/KSAnnotationExtensions.kt (77%) rename {compiler/src/main/java/com/squareup/anvil/compiler/codegen => compiler-utils/src/main/java/com/squareup/anvil/compiler/internal}/ksp/KSClassDeclarationExtensions.kt (86%) rename {compiler/src/main/java/com/squareup/anvil/compiler/codegen => compiler-utils/src/main/java/com/squareup/anvil/compiler/internal}/ksp/KspAnvilExceptions.kt (56%) rename {compiler/src/main/java/com/squareup/anvil/compiler/codegen => compiler-utils/src/main/java/com/squareup/anvil/compiler/internal}/ksp/KspUtil.kt (79%) diff --git a/compiler-utils/api/compiler-utils.api b/compiler-utils/api/compiler-utils.api index cb699c4b3..cb02e60a6 100644 --- a/compiler-utils/api/compiler-utils.api +++ b/compiler-utils/api/compiler-utils.api @@ -55,6 +55,105 @@ public final class com/squareup/anvil/compiler/internal/PsiUtilsKt { public final class com/squareup/anvil/compiler/internal/UtilsKt { public static final fun capitalize (Ljava/lang/String;)Ljava/lang/String; public static final fun decapitalize (Ljava/lang/String;)Ljava/lang/String; + public static final fun getFqName (Lcom/squareup/kotlinpoet/ClassName;)Lorg/jetbrains/kotlin/name/FqName; +} + +public final class com/squareup/anvil/compiler/internal/ksp/KSAnnotationExtensionsKt { + public static final fun argumentAt (Lcom/google/devtools/ksp/symbol/KSAnnotation;Ljava/lang/String;)Lcom/google/devtools/ksp/symbol/KSValueArgument; + public static final fun boundTypeOrNull (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Lcom/google/devtools/ksp/symbol/KSType; + public static final fun checkNoDuplicateScope (Ljava/util/List;Lcom/google/devtools/ksp/symbol/KSClassDeclaration;Z)V + public static final fun checkNoDuplicateScopeAndBoundType (Ljava/util/List;Lcom/google/devtools/ksp/symbol/KSClassDeclaration;)V + public static final fun classNameArgumentAt (Lcom/google/devtools/ksp/symbol/KSAnnotation;Ljava/lang/String;)Lcom/squareup/kotlinpoet/ClassName; + public static final fun classNameArrayArgumentAt (Lcom/google/devtools/ksp/symbol/KSAnnotation;Ljava/lang/String;)Ljava/util/List; + public static final fun exclude (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Ljava/util/List; + public static final fun ignoreQualifier (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Z + public static final fun includes (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Ljava/util/List; + public static final fun isDaggerScope (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Z + public static final fun isMapKey (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Z + public static final fun isQualifier (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Z + public static final fun modules (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Ljava/util/List; + public static final fun parentScope (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Lcom/google/devtools/ksp/symbol/KSClassDeclaration; + public static final fun priorityLegacy (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Ljava/lang/Integer; + public static final fun qualifierAnnotation (Lcom/google/devtools/ksp/symbol/KSAnnotated;)Lcom/google/devtools/ksp/symbol/KSAnnotation; + public static final fun rank (Lcom/google/devtools/ksp/symbol/KSAnnotation;)I + public static final fun replaces (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Ljava/util/List; + public static final fun resolveBoundType (Lcom/google/devtools/ksp/symbol/KSAnnotation;Lcom/google/devtools/ksp/processing/Resolver;Lcom/google/devtools/ksp/symbol/KSClassDeclaration;)Lcom/google/devtools/ksp/symbol/KSClassDeclaration; + public static final fun scope (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Lcom/google/devtools/ksp/symbol/KSType; + public static final fun scopeClassName (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Lcom/squareup/kotlinpoet/ClassName; + public static final fun scopeOrNull (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Lcom/google/devtools/ksp/symbol/KSType; + public static final fun subcomponents (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Ljava/util/List; +} + +public final class com/squareup/anvil/compiler/internal/ksp/KSClassDeclarationExtensionsKt { + public static final fun checkClassExtendsBoundType (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;Lorg/jetbrains/kotlin/name/FqName;Lcom/google/devtools/ksp/processing/Resolver;)V + public static final fun checkClassIsPublic (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;Lkotlin/jvm/functions/Function0;)V + public static final fun checkNotMoreThanOneMapKey (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;)V + public static final fun checkNotMoreThanOneQualifier (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;Lorg/jetbrains/kotlin/name/FqName;)V + public static final fun checkSingleSuperType (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;Lorg/jetbrains/kotlin/name/FqName;Lcom/google/devtools/ksp/processing/Resolver;)V + public static final fun isInterface (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;)Z + public static final fun superTypesExcludingAny (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;Lcom/google/devtools/ksp/processing/Resolver;Z)Lkotlin/sequences/Sequence; +} + +public final class com/squareup/anvil/compiler/internal/ksp/KspAnvilException : java/lang/Exception { + public fun (Ljava/lang/String;Lcom/google/devtools/ksp/symbol/KSNode;Ljava/lang/Throwable;)V + public synthetic fun (Ljava/lang/String;Lcom/google/devtools/ksp/symbol/KSNode;Ljava/lang/Throwable;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun getCause ()Ljava/lang/Throwable; + public fun getMessage ()Ljava/lang/String; + public final fun getNode ()Lcom/google/devtools/ksp/symbol/KSNode; +} + +public final class com/squareup/anvil/compiler/internal/ksp/KspErrorTypeException : java/lang/Exception { + public fun (Ljava/util/List;)V + public fun ([Lcom/google/devtools/ksp/symbol/KSAnnotated;)V + public final fun getTypesToDefer ()Ljava/util/List; +} + +public final class com/squareup/anvil/compiler/internal/ksp/KspUtilKt { + public static final fun anySymbolsWithAnnotations (Lcom/google/devtools/ksp/processing/Resolver;Ljava/util/Collection;)Z + public static final fun atLeastOneAnnotation (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;Ljava/lang/String;Lcom/google/devtools/ksp/symbol/KSType;)Ljava/util/List; + public static synthetic fun atLeastOneAnnotation$default (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;Ljava/lang/String;Lcom/google/devtools/ksp/symbol/KSType;ILjava/lang/Object;)Ljava/util/List; + public static final fun contextualToClassName (Lcom/google/devtools/ksp/symbol/KSType;Lcom/google/devtools/ksp/symbol/KSNode;)Lcom/squareup/kotlinpoet/ClassName; + public static final fun contextualToClassName (Lcom/google/devtools/ksp/symbol/KSTypeReference;)Lcom/squareup/kotlinpoet/ClassName; + public static final fun contextualToTypeName (Lcom/google/devtools/ksp/symbol/KSType;Lcom/google/devtools/ksp/symbol/KSNode;Lcom/squareup/kotlinpoet/ksp/TypeParameterResolver;)Lcom/squareup/kotlinpoet/TypeName; + public static final fun contextualToTypeName (Lcom/google/devtools/ksp/symbol/KSTypeReference;Lcom/squareup/kotlinpoet/ksp/TypeParameterResolver;)Lcom/squareup/kotlinpoet/TypeName; + public static synthetic fun contextualToTypeName$default (Lcom/google/devtools/ksp/symbol/KSType;Lcom/google/devtools/ksp/symbol/KSNode;Lcom/squareup/kotlinpoet/ksp/TypeParameterResolver;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeName; + public static synthetic fun contextualToTypeName$default (Lcom/google/devtools/ksp/symbol/KSTypeReference;Lcom/squareup/kotlinpoet/ksp/TypeParameterResolver;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/TypeName; + public static final fun find (Lcom/google/devtools/ksp/symbol/KSAnnotated;Ljava/lang/String;Lcom/google/devtools/ksp/symbol/KSType;)Ljava/util/List; + public static synthetic fun find$default (Lcom/google/devtools/ksp/symbol/KSAnnotated;Ljava/lang/String;Lcom/google/devtools/ksp/symbol/KSType;ILjava/lang/Object;)Ljava/util/List; + public static final fun findAll (Lcom/google/devtools/ksp/symbol/KSAnnotated;[Ljava/lang/String;)Ljava/util/List; + public static final fun getClassDeclarationByName (Lcom/google/devtools/ksp/processing/Resolver;Lcom/squareup/kotlinpoet/ClassName;)Lcom/google/devtools/ksp/symbol/KSClassDeclaration; + public static final fun getClassDeclarationByName (Lcom/google/devtools/ksp/processing/Resolver;Lorg/jetbrains/kotlin/name/FqName;)Lcom/google/devtools/ksp/symbol/KSClassDeclaration; + public static final fun getClassId (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;)Lorg/jetbrains/kotlin/name/ClassId; + public static final fun getClassesWithAnnotations (Lcom/google/devtools/ksp/processing/Resolver;Ljava/util/Collection;)Lkotlin/sequences/Sequence; + public static final fun getClassesWithAnnotations (Lcom/google/devtools/ksp/processing/Resolver;[Lorg/jetbrains/kotlin/name/FqName;)Lkotlin/sequences/Sequence; + public static final fun getDeclaringClass (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Lcom/google/devtools/ksp/symbol/KSClassDeclaration; + public static final fun getFqName (Lcom/google/devtools/ksp/symbol/KSAnnotation;)Lorg/jetbrains/kotlin/name/FqName; + public static final fun getFqName (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;)Lorg/jetbrains/kotlin/name/FqName; + public static final fun getFqName (Lcom/google/devtools/ksp/symbol/KSType;)Lorg/jetbrains/kotlin/name/FqName; + public static final fun getKSAnnotationsByQualifiedName (Lcom/google/devtools/ksp/symbol/KSAnnotated;Ljava/lang/String;)Lkotlin/sequences/Sequence; + public static final fun getKSAnnotationsByType (Lcom/google/devtools/ksp/symbol/KSAnnotated;Lkotlin/reflect/KClass;)Lkotlin/sequences/Sequence; + public static final fun getReportableReturnTypeNode (Lcom/google/devtools/ksp/symbol/KSFunctionDeclaration;)Lcom/google/devtools/ksp/symbol/KSNode; + public static final fun getResolvableAnnotations (Lcom/google/devtools/ksp/symbol/KSAnnotated;)Lkotlin/sequences/Sequence; + public static final fun injectConstructors (Lcom/google/devtools/ksp/processing/Resolver;)Ljava/util/List; + public static final fun isAnnotationClass (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;)Z + public static final fun isAnnotationPresent (Lcom/google/devtools/ksp/symbol/KSAnnotated;Ljava/lang/String;)Z + public static final fun isAnnotationPresent (Lcom/google/devtools/ksp/symbol/KSAnnotated;Lkotlin/reflect/KClass;)Z + public static final fun isExtensionDeclaration (Lcom/google/devtools/ksp/symbol/KSFunctionDeclaration;)Z + public static final fun isLateInit (Lcom/google/devtools/ksp/symbol/KSModifierListOwner;)Z + public static final fun mergeAnnotations (Lcom/google/devtools/ksp/symbol/KSAnnotated;)Ljava/util/List; + public static final fun requireClassDeclaration (Lcom/google/devtools/ksp/processing/Resolver;Lcom/squareup/kotlinpoet/ClassName;Lkotlin/jvm/functions/Function0;)Lcom/google/devtools/ksp/symbol/KSClassDeclaration; + public static final fun requireClassDeclaration (Lcom/google/devtools/ksp/processing/Resolver;Lorg/jetbrains/kotlin/name/FqName;Lcom/google/devtools/ksp/symbol/KSNode;)Lcom/google/devtools/ksp/symbol/KSClassDeclaration; + public static final fun resolveKSClassDeclaration (Lcom/google/devtools/ksp/symbol/KSDeclaration;)Lcom/google/devtools/ksp/symbol/KSClassDeclaration; + public static final fun resolveKSClassDeclaration (Lcom/google/devtools/ksp/symbol/KSType;)Lcom/google/devtools/ksp/symbol/KSClassDeclaration; + public static final fun returnTypeOrNull (Lcom/google/devtools/ksp/symbol/KSFunction;)Lcom/google/devtools/ksp/symbol/KSType; + public static final fun returnTypeOrNull (Lcom/google/devtools/ksp/symbol/KSFunctionDeclaration;)Lcom/google/devtools/ksp/symbol/KSType; + public static final fun toFunSpec (Lcom/google/devtools/ksp/symbol/KSFunctionDeclaration;)Lcom/squareup/kotlinpoet/FunSpec; + public static final fun toParameterSpec (Lcom/google/devtools/ksp/symbol/KSValueParameter;)Lcom/squareup/kotlinpoet/ParameterSpec; + public static final fun toPropertySpec (Lcom/google/devtools/ksp/symbol/KSPropertyDeclaration;Lcom/squareup/kotlinpoet/TypeName;)Lcom/squareup/kotlinpoet/PropertySpec; + public static synthetic fun toPropertySpec$default (Lcom/google/devtools/ksp/symbol/KSPropertyDeclaration;Lcom/squareup/kotlinpoet/TypeName;ILjava/lang/Object;)Lcom/squareup/kotlinpoet/PropertySpec; + public static final fun unwrapTypealiases (Lcom/google/devtools/ksp/symbol/KSDeclaration;)Lcom/google/devtools/ksp/symbol/KSDeclaration; + public static final fun withCompanion (Lcom/google/devtools/ksp/symbol/KSClassDeclaration;)Lkotlin/sequences/Sequence; + public static final fun withJvmSuppressWildcardsIfNeeded (Lcom/squareup/kotlinpoet/TypeName;Lcom/google/devtools/ksp/symbol/KSAnnotated;Lcom/google/devtools/ksp/symbol/KSType;)Lcom/squareup/kotlinpoet/TypeName; } public abstract interface class com/squareup/anvil/compiler/internal/reference/AnnotatedReference { diff --git a/compiler-utils/build.gradle.kts b/compiler-utils/build.gradle.kts index 6de45a920..c031558f9 100644 --- a/compiler-utils/build.gradle.kts +++ b/compiler-utils/build.gradle.kts @@ -24,7 +24,8 @@ dependencies { api(project(":annotations")) api(project(":compiler-api")) api(libs.kotlin.compiler) - api(libs.kotlinpoet) + api(libs.ksp.api) + api(libs.kotlinpoet.ksp) implementation(platform(libs.kotlin.bom)) implementation(libs.dagger2) diff --git a/compiler-utils/dependencies/runtimeClasspath.txt b/compiler-utils/dependencies/runtimeClasspath.txt index 1f0b5b680..cdf9735a6 100644 --- a/compiler-utils/dependencies/runtimeClasspath.txt +++ b/compiler-utils/dependencies/runtimeClasspath.txt @@ -1,5 +1,7 @@ com.google.dagger:dagger:2.51.1 +com.google.devtools.ksp:symbol-processing-api:1.9.24-1.0.20 com.squareup:kotlinpoet-jvm:1.16.0 +com.squareup:kotlinpoet-ksp:1.16.0 com.squareup:kotlinpoet:1.16.0 javax.inject:javax.inject:1 org.jetbrains.intellij.deps:trove4j:1.0.20200330 @@ -8,5 +10,7 @@ org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.24 org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.24 org.jetbrains.kotlin:kotlin-reflect:1.9.24 org.jetbrains.kotlin:kotlin-script-runtime:1.9.24 +org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.24 +org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.24 org.jetbrains.kotlin:kotlin-stdlib:1.9.24 org.jetbrains:annotations:13.0 diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/Utils.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/Utils.kt index b0f4c0afb..a13f4a069 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/Utils.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/Utils.kt @@ -1,9 +1,16 @@ package com.squareup.anvil.compiler.internal import com.squareup.anvil.annotations.ExperimentalAnvilApi +import com.squareup.kotlinpoet.ClassName +import org.jetbrains.kotlin.name.FqName @ExperimentalAnvilApi public fun String.capitalize(): String = replaceFirstChar(Char::uppercaseChar) @ExperimentalAnvilApi public fun String.decapitalize(): String = replaceFirstChar(Char::lowercaseChar) + +public val ClassName.fqName: FqName + get() { + return FqName(canonicalName) + } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSAnnotationExtensions.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KSAnnotationExtensions.kt similarity index 77% rename from compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSAnnotationExtensions.kt rename to compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KSAnnotationExtensions.kt index 98c237177..32711169c 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSAnnotationExtensions.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KSAnnotationExtensions.kt @@ -1,6 +1,6 @@ @file:Suppress("invisible_reference", "invisible_member") -package com.squareup.anvil.compiler.codegen.ksp +package com.squareup.anvil.compiler.internal.ksp import com.google.devtools.ksp.isDefault import com.google.devtools.ksp.processing.Resolver @@ -12,11 +12,11 @@ import com.google.devtools.ksp.symbol.KSValueArgument import com.squareup.anvil.annotations.ContributesBinding import com.squareup.anvil.compiler.internal.daggerScopeFqName import com.squareup.anvil.compiler.internal.mapKeyFqName -import com.squareup.anvil.compiler.qualifierFqName +import com.squareup.anvil.compiler.internal.qualifierFqName import com.squareup.kotlinpoet.ClassName import org.jetbrains.kotlin.name.FqName -internal fun List.checkNoDuplicateScope( +public fun List.checkNoDuplicateScope( annotatedType: KSClassDeclaration, isContributeAnnotation: Boolean, ) { @@ -49,7 +49,7 @@ internal fun List.checkNoDuplicateScope( } } -internal fun List.checkNoDuplicateScopeAndBoundType( +public fun List.checkNoDuplicateScopeAndBoundType( annotatedType: KSClassDeclaration, ) { // Exit early to avoid allocating additional collections. @@ -81,27 +81,27 @@ internal fun List.checkNoDuplicateScopeAndBoundType( } } -internal fun KSAnnotation.scopeClassName(): ClassName = +public fun KSAnnotation.scopeClassName(): ClassName = classNameArgumentAt("scope") ?: throw KspAnvilException( message = "Couldn't find scope for ${annotationType.resolve().declaration.qualifiedName?.asString()}.", this, ) -internal fun KSAnnotation.scope(): KSType = +public fun KSAnnotation.scope(): KSType = scopeOrNull() ?: throw KspAnvilException( message = "Couldn't find scope for ${annotationType.resolve().declaration.qualifiedName?.asString()}.", this, ) -internal fun KSAnnotation.scopeOrNull(): KSType? { +public fun KSAnnotation.scopeOrNull(): KSType? { return argumentOfTypeAt("scope") } -internal fun KSAnnotation.boundTypeOrNull(): KSType? = argumentOfTypeAt("boundType") +public fun KSAnnotation.boundTypeOrNull(): KSType? = argumentOfTypeAt("boundType") -internal fun KSAnnotation.resolveBoundType( +public fun KSAnnotation.resolveBoundType( resolver: Resolver, declaringClass: KSClassDeclaration, ): KSClassDeclaration { @@ -116,17 +116,17 @@ internal fun KSAnnotation.resolveBoundType( ) } -internal fun KSAnnotation.replaces(): List = classArrayArgument("replaces") +public fun KSAnnotation.replaces(): List = classArrayArgument("replaces") -internal fun KSAnnotation.subcomponents(): List = classArrayArgument( +public fun KSAnnotation.subcomponents(): List = classArrayArgument( "subcomponents", ) -internal fun KSAnnotation.exclude(): List = classArrayArgument("exclude") +public fun KSAnnotation.exclude(): List = classArrayArgument("exclude") -internal fun KSAnnotation.modules(): List = classArrayArgument("modules") +public fun KSAnnotation.modules(): List = classArrayArgument("modules") -internal fun KSAnnotation.includes(): List = classArrayArgument("includes") +public fun KSAnnotation.includes(): List = classArrayArgument("includes") private fun KSAnnotation.classArrayArgument(name: String): List = argumentOfTypeWithMapperAt, List>( @@ -138,7 +138,7 @@ private fun KSAnnotation.classArrayArgument(name: String): List("parentScope") ?.resolveKSClassDeclaration() ?: throw KspAnvilException( @@ -147,7 +147,7 @@ internal fun KSAnnotation.parentScope(): KSClassDeclaration { ) } -internal fun KSAnnotation.classNameArrayArgumentAt( +public fun KSAnnotation.classNameArrayArgumentAt( name: String, ): List? { return argumentOfTypeWithMapperAt, List>(name) { arg, value -> @@ -155,7 +155,7 @@ internal fun KSAnnotation.classNameArrayArgumentAt( } } -internal fun KSAnnotation.classNameArgumentAt( +public fun KSAnnotation.classNameArgumentAt( name: String, ): ClassName? { return argumentOfTypeWithMapperAt(name) { arg, value -> @@ -163,7 +163,7 @@ internal fun KSAnnotation.classNameArgumentAt( } } -internal inline fun KSAnnotation.argumentOfTypeAt( +public inline fun KSAnnotation.argumentOfTypeAt( name: String, ): T? { return argumentOfTypeWithMapperAt(name) { _, value -> @@ -171,7 +171,7 @@ internal inline fun KSAnnotation.argumentOfTypeAt( } } -private inline fun KSAnnotation.argumentOfTypeWithMapperAt( +public inline fun KSAnnotation.argumentOfTypeWithMapperAt( name: String, mapper: (arg: KSValueArgument, value: T) -> R, ): R? { @@ -189,7 +189,7 @@ private inline fun KSAnnotation.argumentOfTypeWithMapperAt( } } -internal fun KSAnnotation.argumentAt( +public fun KSAnnotation.argumentAt( name: String, ): KSValueArgument? { return arguments.find { it.name?.asString() == name } @@ -202,24 +202,24 @@ private fun KSAnnotation.isTypeAnnotatedWith( .declaration .isAnnotationPresent(annotationFqName.asString()) -internal fun KSAnnotation.isQualifier(): Boolean = isTypeAnnotatedWith(qualifierFqName) -internal fun KSAnnotation.isMapKey(): Boolean = isTypeAnnotatedWith(mapKeyFqName) -internal fun KSAnnotation.isDaggerScope(): Boolean = isTypeAnnotatedWith(daggerScopeFqName) +public fun KSAnnotation.isQualifier(): Boolean = isTypeAnnotatedWith(qualifierFqName) +public fun KSAnnotation.isMapKey(): Boolean = isTypeAnnotatedWith(mapKeyFqName) +public fun KSAnnotation.isDaggerScope(): Boolean = isTypeAnnotatedWith(daggerScopeFqName) -internal fun KSAnnotated.qualifierAnnotation(): KSAnnotation? = +public fun KSAnnotated.qualifierAnnotation(): KSAnnotation? = resolvableAnnotations.singleOrNull { it.isQualifier() } -internal fun KSAnnotation.ignoreQualifier(): Boolean = +public fun KSAnnotation.ignoreQualifier(): Boolean = argumentOfTypeAt("ignoreQualifier") == true -internal fun KSAnnotation.rank(): Int { +public fun KSAnnotation.rank(): Int { return argumentOfTypeAt("rank") ?: priorityLegacy() ?: ContributesBinding.RANK_NORMAL } @Suppress("DEPRECATION") -internal fun KSAnnotation.priorityLegacy(): Int? { +public fun KSAnnotation.priorityLegacy(): Int? { val priorityEntry = argumentOfTypeAt("priority") ?: return null val name = priorityEntry.resolveKSClassDeclaration()?.simpleName?.asString() ?: return null val priority = ContributesBinding.Priority.valueOf(name) diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSClassDeclarationExtensions.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KSClassDeclarationExtensions.kt similarity index 86% rename from compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSClassDeclarationExtensions.kt rename to compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KSClassDeclarationExtensions.kt index 3e4b36fd9..ca1c0c9dc 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSClassDeclarationExtensions.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KSClassDeclarationExtensions.kt @@ -1,4 +1,4 @@ -package com.squareup.anvil.compiler.codegen.ksp +package com.squareup.anvil.compiler.internal.ksp import com.google.devtools.ksp.getAllSuperTypes import com.google.devtools.ksp.getVisibility @@ -7,10 +7,10 @@ import com.google.devtools.ksp.symbol.ClassKind import com.google.devtools.ksp.symbol.KSClassDeclaration import com.google.devtools.ksp.symbol.KSType import com.google.devtools.ksp.symbol.Visibility.PUBLIC -import com.squareup.anvil.compiler.contributesMultibindingFqName +import com.squareup.anvil.compiler.internal.contributesMultibindingFqName import org.jetbrains.kotlin.name.FqName -internal fun KSClassDeclaration.checkNotMoreThanOneQualifier( +public fun KSClassDeclaration.checkNotMoreThanOneQualifier( annotationFqName: FqName, ) { val annotationsList = resolvableAnnotations.toList() @@ -28,7 +28,7 @@ internal fun KSClassDeclaration.checkNotMoreThanOneQualifier( } } -internal inline fun KSClassDeclaration.checkClassIsPublic(message: () -> String) { +public inline fun KSClassDeclaration.checkClassIsPublic(message: () -> String) { if (getVisibility() != PUBLIC) { throw KspAnvilException( message = message(), @@ -37,7 +37,7 @@ internal inline fun KSClassDeclaration.checkClassIsPublic(message: () -> String) } } -internal fun KSClassDeclaration.checkNotMoreThanOneMapKey() { +public fun KSClassDeclaration.checkNotMoreThanOneMapKey() { // The class is annotated with @ContributesMultibinding. If there is less than 2 further // annotations, then there can't be more than two map keys. val annotationsList = resolvableAnnotations.toList() @@ -54,7 +54,7 @@ internal fun KSClassDeclaration.checkNotMoreThanOneMapKey() { } } -internal fun KSClassDeclaration.checkSingleSuperType( +public fun KSClassDeclaration.checkSingleSuperType( annotationFqName: FqName, resolver: Resolver, ) { @@ -76,7 +76,7 @@ internal fun KSClassDeclaration.checkSingleSuperType( } } -internal fun KSClassDeclaration.checkClassExtendsBoundType( +public fun KSClassDeclaration.checkClassExtendsBoundType( annotationFqName: FqName, resolver: Resolver, ) { @@ -103,7 +103,7 @@ internal fun KSClassDeclaration.checkClassExtendsBoundType( } } -internal fun KSClassDeclaration.superTypesExcludingAny( +public fun KSClassDeclaration.superTypesExcludingAny( resolver: Resolver, shallow: Boolean, ): Sequence { @@ -116,6 +116,6 @@ internal fun KSClassDeclaration.superTypesExcludingAny( .filterNot { it == resolver.builtIns.anyType } } -internal fun KSClassDeclaration.isInterface(): Boolean { +public fun KSClassDeclaration.isInterface(): Boolean { return classKind == ClassKind.INTERFACE } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspAnvilExceptions.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KspAnvilExceptions.kt similarity index 56% rename from compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspAnvilExceptions.kt rename to compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KspAnvilExceptions.kt index 20a478d0f..f3683fbfd 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspAnvilExceptions.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KspAnvilExceptions.kt @@ -1,11 +1,11 @@ -package com.squareup.anvil.compiler.codegen.ksp +package com.squareup.anvil.compiler.internal.ksp import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSNode -internal class KspAnvilException( +public class KspAnvilException( override val message: String, - val node: KSNode, + public val node: KSNode, override val cause: Throwable? = null, ) : Exception() @@ -13,6 +13,6 @@ internal class KspAnvilException( * In rare cases, we might encounter error types that we can't easily forward back up the call * stack. With great shame, I hang my head in defeat with this type. */ -internal class KspErrorTypeException(val typesToDefer: List) : Exception() { - constructor(vararg types: KSAnnotated) : this(types.toList()) +public class KspErrorTypeException(public val typesToDefer: List) : Exception() { + public constructor(vararg types: KSAnnotated) : this(types.toList()) } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspUtil.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KspUtil.kt similarity index 79% rename from compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspUtil.kt rename to compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KspUtil.kt index 85f909fa5..81906fabd 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspUtil.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/ksp/KspUtil.kt @@ -1,4 +1,4 @@ -package com.squareup.anvil.compiler.codegen.ksp +package com.squareup.anvil.compiler.internal.ksp import com.google.devtools.ksp.KspExperimental import com.google.devtools.ksp.containingFile @@ -24,12 +24,12 @@ import com.google.devtools.ksp.symbol.KSTypeReference import com.google.devtools.ksp.symbol.KSValueParameter import com.google.devtools.ksp.symbol.Modifier import com.google.devtools.ksp.symbol.NonExistLocation -import com.squareup.anvil.compiler.fqName +import com.squareup.anvil.compiler.internal.fqName +import com.squareup.anvil.compiler.internal.mergeComponentFqName +import com.squareup.anvil.compiler.internal.mergeInterfacesFqName +import com.squareup.anvil.compiler.internal.mergeModulesFqName +import com.squareup.anvil.compiler.internal.mergeSubcomponentFqName import com.squareup.anvil.compiler.internal.reference.asClassId -import com.squareup.anvil.compiler.mergeComponentFqName -import com.squareup.anvil.compiler.mergeInterfacesFqName -import com.squareup.anvil.compiler.mergeModulesFqName -import com.squareup.anvil.compiler.mergeSubcomponentFqName import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.ParameterSpec @@ -50,7 +50,7 @@ import kotlin.reflect.KClass /** * Returns a sequence of [KSAnnotations][KSAnnotation] of the given [annotationKClass] type. */ -internal fun KSAnnotated.getKSAnnotationsByType( +public fun KSAnnotated.getKSAnnotationsByType( annotationKClass: KClass, ): Sequence { val qualifiedName = annotationKClass.qualifiedName ?: return emptySequence() @@ -60,7 +60,7 @@ internal fun KSAnnotated.getKSAnnotationsByType( /** * Returns a sequence of [KSAnnotations][KSAnnotation] of the given [qualifiedName]. */ -internal fun KSAnnotated.getKSAnnotationsByQualifiedName( +public fun KSAnnotated.getKSAnnotationsByQualifiedName( qualifiedName: String, ): Sequence { // Don't use resolvableAnnotations here to save the double resolve() call @@ -76,23 +76,23 @@ internal fun KSAnnotated.getKSAnnotationsByQualifiedName( } } -internal fun KSAnnotated.isAnnotationPresent(qualifiedName: String): Boolean = +public fun KSAnnotated.isAnnotationPresent(qualifiedName: String): Boolean = getKSAnnotationsByQualifiedName(qualifiedName).firstOrNull() != null -internal inline fun KSAnnotated.isAnnotationPresent(): Boolean { +public inline fun KSAnnotated.isAnnotationPresent(): Boolean { return isAnnotationPresent(T::class) } -internal fun KSAnnotated.isAnnotationPresent(klass: KClass<*>): Boolean { +public fun KSAnnotated.isAnnotationPresent(klass: KClass<*>): Boolean { val fqcn = klass.qualifiedName ?: return false return getKSAnnotationsByQualifiedName(fqcn).firstOrNull() != null } -internal fun KSClassDeclaration.isAnnotationClass(): Boolean = classKind == ANNOTATION_CLASS -internal fun KSModifierListOwner.isLateInit(): Boolean = Modifier.LATEINIT in modifiers +public fun KSClassDeclaration.isAnnotationClass(): Boolean = classKind == ANNOTATION_CLASS +public fun KSModifierListOwner.isLateInit(): Boolean = Modifier.LATEINIT in modifiers @OptIn(KspExperimental::class) -internal fun TypeName.withJvmSuppressWildcardsIfNeeded( +public fun TypeName.withJvmSuppressWildcardsIfNeeded( annotatedReference: KSAnnotated, type: KSType, ): TypeName { @@ -118,7 +118,7 @@ internal fun TypeName.withJvmSuppressWildcardsIfNeeded( /** * Resolves the [KSClassDeclaration] for this type, including following typealiases as needed. */ -internal fun KSType.resolveKSClassDeclaration(): KSClassDeclaration? = +public fun KSType.resolveKSClassDeclaration(): KSClassDeclaration? = declaration.resolveKSClassDeclaration() /** @@ -128,7 +128,7 @@ internal fun KSType.resolveKSClassDeclaration(): KSClassDeclaration? = * [KSTypeParameter] types will return null. If you expect one here, you should check the * declaration directly. */ -internal fun KSDeclaration.resolveKSClassDeclaration(): KSClassDeclaration? { +public fun KSDeclaration.resolveKSClassDeclaration(): KSClassDeclaration? { return when (val declaration = unwrapTypealiases()) { is KSClassDeclaration -> declaration is KSTypeParameter -> null @@ -139,7 +139,7 @@ internal fun KSDeclaration.resolveKSClassDeclaration(): KSClassDeclaration? { /** * Returns the resolved declaration following any typealiases. */ -internal tailrec fun KSDeclaration.unwrapTypealiases(): KSDeclaration = when (this) { +public tailrec fun KSDeclaration.unwrapTypealiases(): KSDeclaration = when (this) { is KSTypeAlias -> type.resolve().declaration.unwrapTypealiases() else -> this } @@ -147,7 +147,7 @@ internal tailrec fun KSDeclaration.unwrapTypealiases(): KSDeclaration = when (th /** * Returns a sequence of all `@Inject` and `@AssistedInject` constructors visible to this resolver */ -internal fun Resolver.injectConstructors(): List> { +public fun Resolver.injectConstructors(): List> { return getAnnotatedSymbols() .plus(getAnnotatedSymbols()) .filterIsInstance() @@ -203,62 +203,62 @@ private fun requireSingleInjectConstructor( ) } -internal inline fun Resolver.getAnnotatedSymbols(): Sequence { +public inline fun Resolver.getAnnotatedSymbols(): Sequence { val clazz = T::class val fqcn = clazz.qualifiedName ?: throw IllegalArgumentException("Cannot get qualified name for annotation $clazz") return getSymbolsWithAnnotation(fqcn) } -internal fun KSClassDeclaration.withCompanion(): Sequence = +public fun KSClassDeclaration.withCompanion(): Sequence = sequence { yield(this@withCompanion) yieldAll(declarations.filterIsInstance().filter { it.isCompanionObject }) } -internal inline fun KSClassDeclaration.getAnnotatedFunctions() = +public inline fun KSClassDeclaration.getAnnotatedFunctions(): Sequence = getDeclaredFunctions() .filter { it.isAnnotationPresent() } -internal fun KSFunctionDeclaration.isExtensionDeclaration(): Boolean = +public fun KSFunctionDeclaration.isExtensionDeclaration(): Boolean = extensionReceiver != null -internal fun KSFunctionDeclaration.returnTypeOrNull(): KSType? = +public fun KSFunctionDeclaration.returnTypeOrNull(): KSType? = returnType?.resolve()?.takeIf { it.declaration.qualifiedName?.asString() != "kotlin.Unit" } -internal fun KSFunction.returnTypeOrNull(): KSType? = +public fun KSFunction.returnTypeOrNull(): KSType? = returnType?.takeIf { it.declaration.qualifiedName?.asString() != "kotlin.Unit" } -internal fun Resolver.getClassesWithAnnotations( +public fun Resolver.getClassesWithAnnotations( vararg annotations: FqName, ): Sequence = getClassesWithAnnotations(annotations.map { it.asString() }) -internal fun Resolver.getClassesWithAnnotations( +public fun Resolver.getClassesWithAnnotations( annotations: Collection, ): Sequence = annotations.asSequence() .flatMap(::getSymbolsWithAnnotation) .filterIsInstance() .distinctBy { it.qualifiedName?.asString() } -internal fun Resolver.anySymbolsWithAnnotations( +public fun Resolver.anySymbolsWithAnnotations( annotations: Collection, ): Boolean { return annotations.any { getSymbolsWithAnnotation(it).any() } } -internal fun KSAnnotated.findAll(vararg annotations: String): List { +public fun KSAnnotated.findAll(vararg annotations: String): List { return annotations.flatMap { annotation -> getKSAnnotationsByQualifiedName(annotation) } } -internal val KSAnnotation.declaringClass: KSClassDeclaration get() = parent as KSClassDeclaration +public val KSAnnotation.declaringClass: KSClassDeclaration get() = parent as KSClassDeclaration -internal fun KSAnnotated.find( +public fun KSAnnotated.find( annotationName: String, scopeName: KSType? = null, ): List { @@ -268,7 +268,7 @@ internal fun KSAnnotated.find( } } -internal fun KSClassDeclaration.atLeastOneAnnotation( +public fun KSClassDeclaration.atLeastOneAnnotation( annotationName: String, scopeName: KSType? = null, ): List { @@ -282,9 +282,9 @@ internal fun KSClassDeclaration.atLeastOneAnnotation( } } -internal val KSClassDeclaration.classId: ClassId get() = toClassName().asClassId() +public val KSClassDeclaration.classId: ClassId get() = toClassName().asClassId() -internal fun KSFunctionDeclaration.toFunSpec(): FunSpec { +public fun KSFunctionDeclaration.toFunSpec(): FunSpec { val builder = FunSpec.builder(simpleName.getShortName()) .addModifiers(modifiers.mapNotNull { it.toKModifier() }) .addAnnotations( @@ -301,7 +301,7 @@ internal fun KSFunctionDeclaration.toFunSpec(): FunSpec { return builder.build() } -internal fun KSPropertyDeclaration.toPropertySpec( +public fun KSPropertyDeclaration.toPropertySpec( typeOverride: TypeName = type.contextualToTypeName(), ): PropertySpec { return PropertySpec.builder(simpleName.getShortName(), typeOverride) @@ -312,7 +312,7 @@ internal fun KSPropertyDeclaration.toPropertySpec( .build() } -internal fun KSValueParameter.toParameterSpec(): ParameterSpec { +public fun KSValueParameter.toParameterSpec(): ParameterSpec { return ParameterSpec.builder(name!!.asString(), type.contextualToTypeName()) .addAnnotations( resolvableAnnotations.map { it.toAnnotationSpec() }.asIterable(), @@ -320,7 +320,7 @@ internal fun KSValueParameter.toParameterSpec(): ParameterSpec { .build() } -internal fun KSAnnotated.mergeAnnotations(): List { +public fun KSAnnotated.mergeAnnotations(): List { return findAll( mergeComponentFqName.asString(), mergeSubcomponentFqName.asString(), @@ -332,15 +332,15 @@ internal fun KSAnnotated.mergeAnnotations(): List { /** * Returns a sequence of [KSAnnotation] types that are not error types. */ -internal val KSAnnotated.resolvableAnnotations: Sequence +public val KSAnnotated.resolvableAnnotations: Sequence get() = annotations .filterNot { it.annotationType.resolve().isError } -internal val KSAnnotation.fqName: FqName +public val KSAnnotation.fqName: FqName get() = annotationType.resolve().resolveKSClassDeclaration()!!.fqName -internal val KSType.fqName: FqName get() = resolveKSClassDeclaration()!!.fqName -internal val KSClassDeclaration.fqName: FqName +public val KSType.fqName: FqName get() = resolveKSClassDeclaration()!!.fqName +public val KSClassDeclaration.fqName: FqName get() { // Call resolveKSClassDeclaration to ensure we follow typealiases return resolveKSClassDeclaration()!! @@ -352,7 +352,7 @@ internal val KSClassDeclaration.fqName: FqName * A contextual alternative to [KSTypeReference.toTypeName] that uses [KSType.contextualToTypeName] * under the hood. */ -internal fun KSTypeReference.contextualToTypeName( +public fun KSTypeReference.contextualToTypeName( typeParamResolver: TypeParameterResolver = TypeParameterResolver.EMPTY, ): TypeName { return resolve().contextualToTypeName(this, typeParamResolver) @@ -362,7 +362,7 @@ internal fun KSTypeReference.contextualToTypeName( * A contextual alternative to [KSType.toTypeName] that requires an [origin] param to better * indicate the origin of the error type. */ -internal fun KSType.contextualToTypeName( +public fun KSType.contextualToTypeName( origin: KSNode, typeParamResolver: TypeParameterResolver = TypeParameterResolver.EMPTY, ): TypeName { @@ -374,7 +374,7 @@ internal fun KSType.contextualToTypeName( * A contextual alternative to `KSTypeReference.resolve().toClassName()` that uses * [KSType.contextualToClassName] under the hood. */ -internal fun KSTypeReference.contextualToClassName(): ClassName { +public fun KSTypeReference.contextualToClassName(): ClassName { return resolve().contextualToClassName(this) } @@ -382,7 +382,7 @@ internal fun KSTypeReference.contextualToClassName(): ClassName { * A contextual alternative to [KSType.toClassName] that requires an [origin] param to better * indicate the origin of the error type. */ -internal fun KSType.contextualToClassName(origin: KSNode): ClassName { +public fun KSType.contextualToClassName(origin: KSNode): ClassName { checkErrorType(origin) return toClassName() } @@ -434,14 +434,14 @@ private fun KSType.checkErrorType(origin: KSNode) { throw KspAnvilException(message = message, node = finalNode) } -internal val KSFunctionDeclaration.reportableReturnTypeNode: KSNode +public val KSFunctionDeclaration.reportableReturnTypeNode: KSNode get() = returnType ?: this -internal fun Resolver.getClassDeclarationByName(className: ClassName): KSClassDeclaration? { +public fun Resolver.getClassDeclarationByName(className: ClassName): KSClassDeclaration? { return getClassDeclarationByName(className.canonicalName) } -internal fun Resolver.requireClassDeclaration( +public fun Resolver.requireClassDeclaration( className: ClassName, node: (() -> KSNode)?, ): KSClassDeclaration { @@ -459,11 +459,11 @@ internal fun Resolver.requireClassDeclaration( } } -internal fun Resolver.getClassDeclarationByName(fqName: FqName): KSClassDeclaration? { +public fun Resolver.getClassDeclarationByName(fqName: FqName): KSClassDeclaration? { return getClassDeclarationByName(fqName.asString()) } -internal fun Resolver.requireClassDeclaration(fqName: FqName, node: KSNode?): KSClassDeclaration { +public fun Resolver.requireClassDeclaration(fqName: FqName, node: KSNode?): KSClassDeclaration { return getClassDeclarationByName(fqName) ?: run { val message = "Could not find class '${fqName.asString()}'" diff --git a/compiler/dependencies/runtimeClasspath.txt b/compiler/dependencies/runtimeClasspath.txt index f34ff5d9a..77b61f1f4 100644 --- a/compiler/dependencies/runtimeClasspath.txt +++ b/compiler/dependencies/runtimeClasspath.txt @@ -1,4 +1,5 @@ com.google.dagger:dagger:2.51.1 +com.google.devtools.ksp:symbol-processing-api:1.9.24-1.0.20 com.squareup:kotlinpoet-jvm:1.16.0 com.squareup:kotlinpoet-ksp:1.16.0 com.squareup:kotlinpoet:1.16.0 @@ -10,5 +11,7 @@ org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.24 org.jetbrains.kotlin:kotlin-daemon-embeddable:1.9.24 org.jetbrains.kotlin:kotlin-reflect:1.9.24 org.jetbrains.kotlin:kotlin-script-runtime:1.9.24 +org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.24 +org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.24 org.jetbrains.kotlin:kotlin-stdlib:1.9.24 org.jetbrains:annotations:13.0 diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/ClassScannerKsp.kt b/compiler/src/main/java/com/squareup/anvil/compiler/ClassScannerKsp.kt index 3f634f365..aaeca85de 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/ClassScannerKsp.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/ClassScannerKsp.kt @@ -1,7 +1,6 @@ package com.squareup.anvil.compiler import com.google.devtools.ksp.KspExperimental -import com.google.devtools.ksp.getClassDeclarationByName import com.google.devtools.ksp.getVisibility import com.google.devtools.ksp.processing.Resolver import com.google.devtools.ksp.symbol.KSClassDeclaration @@ -15,20 +14,21 @@ import com.squareup.anvil.compiler.ClassScannerKsp.GeneratedProperty.ReferencePr import com.squareup.anvil.compiler.ClassScannerKsp.GeneratedProperty.ScopeProperty import com.squareup.anvil.compiler.api.AnvilCompilationException import com.squareup.anvil.compiler.codegen.ksp.KSCallable -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException import com.squareup.anvil.compiler.codegen.ksp.KspTracer -import com.squareup.anvil.compiler.codegen.ksp.contextualToClassName -import com.squareup.anvil.compiler.codegen.ksp.fqName import com.squareup.anvil.compiler.codegen.ksp.getAllCallables -import com.squareup.anvil.compiler.codegen.ksp.getClassDeclarationByName import com.squareup.anvil.compiler.codegen.ksp.isAbstract -import com.squareup.anvil.compiler.codegen.ksp.isInterface -import com.squareup.anvil.compiler.codegen.ksp.parentScope -import com.squareup.anvil.compiler.codegen.ksp.resolvableAnnotations -import com.squareup.anvil.compiler.codegen.ksp.resolveKSClassDeclaration -import com.squareup.anvil.compiler.codegen.ksp.scopeClassName import com.squareup.anvil.compiler.codegen.ksp.trace import com.squareup.anvil.compiler.codegen.ksp.type +import com.squareup.anvil.compiler.internal.fqName +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.contextualToClassName +import com.squareup.anvil.compiler.internal.ksp.fqName +import com.squareup.anvil.compiler.internal.ksp.getClassDeclarationByName +import com.squareup.anvil.compiler.internal.ksp.isInterface +import com.squareup.anvil.compiler.internal.ksp.parentScope +import com.squareup.anvil.compiler.internal.ksp.resolvableAnnotations +import com.squareup.anvil.compiler.internal.ksp.resolveKSClassDeclaration +import com.squareup.anvil.compiler.internal.ksp.scopeClassName import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.ksp.toClassName import org.jetbrains.kotlin.name.FqName diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/ContributedBinding.kt b/compiler/src/main/java/com/squareup/anvil/compiler/ContributedBinding.kt index f5aaed1da..af8123dca 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/ContributedBinding.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/ContributedBinding.kt @@ -5,10 +5,10 @@ import com.google.devtools.ksp.symbol.KSClassDeclaration import com.google.devtools.ksp.symbol.KSType import com.google.devtools.ksp.symbol.KSTypeReference import com.squareup.anvil.compiler.api.AnvilCompilationException -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.resolveKSClassDeclaration import com.squareup.anvil.compiler.codegen.reference.AnvilCompilationExceptionClassReferenceIr import com.squareup.anvil.compiler.codegen.reference.ClassReferenceIr +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.resolveKSClassDeclaration import com.squareup.anvil.compiler.internal.reference.AnnotationReference import com.squareup.anvil.compiler.internal.reference.ClassReference import com.squareup.anvil.compiler.internal.reference.ClassReference.Descriptor diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/IrContributionMerger.kt b/compiler/src/main/java/com/squareup/anvil/compiler/IrContributionMerger.kt index 4f68411f2..8cf5853e2 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/IrContributionMerger.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/IrContributionMerger.kt @@ -12,6 +12,7 @@ import com.squareup.anvil.compiler.codegen.reference.findAll import com.squareup.anvil.compiler.codegen.reference.toClassReference import com.squareup.anvil.compiler.internal.asClassName import com.squareup.anvil.compiler.internal.classIdBestGuess +import com.squareup.anvil.compiler.internal.fqName import com.squareup.anvil.compiler.internal.reference.Visibility.PUBLIC import dagger.Module import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/KspContributionMerger.kt b/compiler/src/main/java/com/squareup/anvil/compiler/KspContributionMerger.kt index 8e1b1dbd4..53dbb5ebe 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/KspContributionMerger.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/KspContributionMerger.kt @@ -35,49 +35,50 @@ import com.squareup.anvil.compiler.codegen.KspMergeAnnotationsCheckSymbolProcess import com.squareup.anvil.compiler.codegen.generatedAnvilSubcomponentClassId import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.KSCallable -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.anySymbolsWithAnnotations -import com.squareup.anvil.compiler.codegen.ksp.argumentOfTypeAt -import com.squareup.anvil.compiler.codegen.ksp.atLeastOneAnnotation -import com.squareup.anvil.compiler.codegen.ksp.classId -import com.squareup.anvil.compiler.codegen.ksp.classNameArgumentAt -import com.squareup.anvil.compiler.codegen.ksp.classNameArrayArgumentAt -import com.squareup.anvil.compiler.codegen.ksp.contextualToClassName -import com.squareup.anvil.compiler.codegen.ksp.contextualToTypeName -import com.squareup.anvil.compiler.codegen.ksp.declaringClass -import com.squareup.anvil.compiler.codegen.ksp.exclude -import com.squareup.anvil.compiler.codegen.ksp.find -import com.squareup.anvil.compiler.codegen.ksp.findAll -import com.squareup.anvil.compiler.codegen.ksp.fqName import com.squareup.anvil.compiler.codegen.ksp.getAllCallables -import com.squareup.anvil.compiler.codegen.ksp.getClassDeclarationByName -import com.squareup.anvil.compiler.codegen.ksp.getClassesWithAnnotations -import com.squareup.anvil.compiler.codegen.ksp.getKSAnnotationsByType -import com.squareup.anvil.compiler.codegen.ksp.includes import com.squareup.anvil.compiler.codegen.ksp.isAbstract -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationPresent -import com.squareup.anvil.compiler.codegen.ksp.isInterface -import com.squareup.anvil.compiler.codegen.ksp.mergeAnnotations -import com.squareup.anvil.compiler.codegen.ksp.modules -import com.squareup.anvil.compiler.codegen.ksp.parentScope -import com.squareup.anvil.compiler.codegen.ksp.replaces -import com.squareup.anvil.compiler.codegen.ksp.reportableReturnTypeNode -import com.squareup.anvil.compiler.codegen.ksp.requireClassDeclaration -import com.squareup.anvil.compiler.codegen.ksp.resolvableAnnotations -import com.squareup.anvil.compiler.codegen.ksp.resolveKSClassDeclaration -import com.squareup.anvil.compiler.codegen.ksp.returnTypeOrNull -import com.squareup.anvil.compiler.codegen.ksp.scope -import com.squareup.anvil.compiler.codegen.ksp.scopeClassName -import com.squareup.anvil.compiler.codegen.ksp.superTypesExcludingAny -import com.squareup.anvil.compiler.codegen.ksp.toFunSpec -import com.squareup.anvil.compiler.codegen.ksp.toPropertySpec import com.squareup.anvil.compiler.codegen.ksp.trace import com.squareup.anvil.compiler.codegen.ksp.type import com.squareup.anvil.compiler.internal.asClassName import com.squareup.anvil.compiler.internal.capitalize import com.squareup.anvil.compiler.internal.createAnvilSpec import com.squareup.anvil.compiler.internal.findRawType +import com.squareup.anvil.compiler.internal.fqName import com.squareup.anvil.compiler.internal.joinSimpleNames +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.anySymbolsWithAnnotations +import com.squareup.anvil.compiler.internal.ksp.argumentOfTypeAt +import com.squareup.anvil.compiler.internal.ksp.atLeastOneAnnotation +import com.squareup.anvil.compiler.internal.ksp.classId +import com.squareup.anvil.compiler.internal.ksp.classNameArgumentAt +import com.squareup.anvil.compiler.internal.ksp.classNameArrayArgumentAt +import com.squareup.anvil.compiler.internal.ksp.contextualToClassName +import com.squareup.anvil.compiler.internal.ksp.contextualToTypeName +import com.squareup.anvil.compiler.internal.ksp.declaringClass +import com.squareup.anvil.compiler.internal.ksp.exclude +import com.squareup.anvil.compiler.internal.ksp.find +import com.squareup.anvil.compiler.internal.ksp.findAll +import com.squareup.anvil.compiler.internal.ksp.fqName +import com.squareup.anvil.compiler.internal.ksp.getClassDeclarationByName +import com.squareup.anvil.compiler.internal.ksp.getClassesWithAnnotations +import com.squareup.anvil.compiler.internal.ksp.getKSAnnotationsByType +import com.squareup.anvil.compiler.internal.ksp.includes +import com.squareup.anvil.compiler.internal.ksp.isAnnotationPresent +import com.squareup.anvil.compiler.internal.ksp.isInterface +import com.squareup.anvil.compiler.internal.ksp.mergeAnnotations +import com.squareup.anvil.compiler.internal.ksp.modules +import com.squareup.anvil.compiler.internal.ksp.parentScope +import com.squareup.anvil.compiler.internal.ksp.replaces +import com.squareup.anvil.compiler.internal.ksp.reportableReturnTypeNode +import com.squareup.anvil.compiler.internal.ksp.requireClassDeclaration +import com.squareup.anvil.compiler.internal.ksp.resolvableAnnotations +import com.squareup.anvil.compiler.internal.ksp.resolveKSClassDeclaration +import com.squareup.anvil.compiler.internal.ksp.returnTypeOrNull +import com.squareup.anvil.compiler.internal.ksp.scope +import com.squareup.anvil.compiler.internal.ksp.scopeClassName +import com.squareup.anvil.compiler.internal.ksp.superTypesExcludingAny +import com.squareup.anvil.compiler.internal.ksp.toFunSpec +import com.squareup.anvil.compiler.internal.ksp.toPropertySpec import com.squareup.anvil.compiler.internal.mergedClassName import com.squareup.anvil.compiler.internal.reference.asClassId import com.squareup.kotlinpoet.AnnotationSpec diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/Utils.kt b/compiler/src/main/java/com/squareup/anvil/compiler/Utils.kt index 07381cd98..76a8851bf 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/Utils.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/Utils.kt @@ -12,7 +12,6 @@ import com.squareup.anvil.annotations.internal.InternalAnvilHintMarker import com.squareup.anvil.annotations.internal.InternalBindingMarker import com.squareup.anvil.compiler.api.AnvilCompilationException import com.squareup.anvil.compiler.internal.fqName -import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.asClassName import dagger.Binds import dagger.Component @@ -25,7 +24,6 @@ import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import dagger.internal.DoubleCheck -import org.jetbrains.kotlin.name.FqName import java.io.File import javax.inject.Inject import javax.inject.Provider @@ -214,11 +212,6 @@ internal inline fun Array.mapToSet( return mapTo(destination, transform) } -internal val ClassName.fqName: FqName - get() { - return FqName(canonicalName) - } - internal inline fun , O> C.ifNotEmpty(body: (C) -> O?): O? = if (isNotEmpty()) body(this) else null diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesBindingCodeGen.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesBindingCodeGen.kt index 89ca4f7bb..3334c68bd 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesBindingCodeGen.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesBindingCodeGen.kt @@ -19,20 +19,19 @@ import com.squareup.anvil.compiler.checkNotGeneric import com.squareup.anvil.compiler.codegen.Contribution.Companion.generateFileSpecs import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.checkClassExtendsBoundType -import com.squareup.anvil.compiler.codegen.ksp.checkClassIsPublic -import com.squareup.anvil.compiler.codegen.ksp.checkNoDuplicateScopeAndBoundType -import com.squareup.anvil.compiler.codegen.ksp.checkNotMoreThanOneQualifier -import com.squareup.anvil.compiler.codegen.ksp.checkSingleSuperType -import com.squareup.anvil.compiler.codegen.ksp.getKSAnnotationsByType -import com.squareup.anvil.compiler.codegen.ksp.ignoreQualifier -import com.squareup.anvil.compiler.codegen.ksp.qualifierAnnotation -import com.squareup.anvil.compiler.codegen.ksp.rank -import com.squareup.anvil.compiler.codegen.ksp.replaces -import com.squareup.anvil.compiler.codegen.ksp.resolveBoundType -import com.squareup.anvil.compiler.codegen.ksp.scope -import com.squareup.anvil.compiler.codegen.ksp.scopeClassName import com.squareup.anvil.compiler.contributesBindingFqName +import com.squareup.anvil.compiler.internal.ksp.checkClassExtendsBoundType +import com.squareup.anvil.compiler.internal.ksp.checkClassIsPublic +import com.squareup.anvil.compiler.internal.ksp.checkNoDuplicateScopeAndBoundType +import com.squareup.anvil.compiler.internal.ksp.checkNotMoreThanOneQualifier +import com.squareup.anvil.compiler.internal.ksp.checkSingleSuperType +import com.squareup.anvil.compiler.internal.ksp.getKSAnnotationsByType +import com.squareup.anvil.compiler.internal.ksp.ignoreQualifier +import com.squareup.anvil.compiler.internal.ksp.qualifierAnnotation +import com.squareup.anvil.compiler.internal.ksp.rank +import com.squareup.anvil.compiler.internal.ksp.replaces +import com.squareup.anvil.compiler.internal.ksp.resolveBoundType +import com.squareup.anvil.compiler.internal.ksp.scopeClassName import com.squareup.anvil.compiler.internal.reference.asClassName import com.squareup.anvil.compiler.internal.reference.classAndInnerClassReferences import com.squareup.anvil.compiler.qualifierKey diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesMultibindingCodeGen.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesMultibindingCodeGen.kt index 489ca192c..f64a8c6ed 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesMultibindingCodeGen.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesMultibindingCodeGen.kt @@ -18,22 +18,21 @@ import com.squareup.anvil.compiler.checkNotGeneric import com.squareup.anvil.compiler.codegen.Contribution.Companion.generateFileSpecs import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.checkClassExtendsBoundType -import com.squareup.anvil.compiler.codegen.ksp.checkClassIsPublic -import com.squareup.anvil.compiler.codegen.ksp.checkNoDuplicateScopeAndBoundType -import com.squareup.anvil.compiler.codegen.ksp.checkNotMoreThanOneMapKey -import com.squareup.anvil.compiler.codegen.ksp.checkNotMoreThanOneQualifier -import com.squareup.anvil.compiler.codegen.ksp.checkSingleSuperType -import com.squareup.anvil.compiler.codegen.ksp.getKSAnnotationsByType -import com.squareup.anvil.compiler.codegen.ksp.ignoreQualifier -import com.squareup.anvil.compiler.codegen.ksp.isMapKey -import com.squareup.anvil.compiler.codegen.ksp.qualifierAnnotation -import com.squareup.anvil.compiler.codegen.ksp.replaces -import com.squareup.anvil.compiler.codegen.ksp.resolvableAnnotations -import com.squareup.anvil.compiler.codegen.ksp.resolveBoundType -import com.squareup.anvil.compiler.codegen.ksp.scope -import com.squareup.anvil.compiler.codegen.ksp.scopeClassName import com.squareup.anvil.compiler.contributesMultibindingFqName +import com.squareup.anvil.compiler.internal.ksp.checkClassExtendsBoundType +import com.squareup.anvil.compiler.internal.ksp.checkClassIsPublic +import com.squareup.anvil.compiler.internal.ksp.checkNoDuplicateScopeAndBoundType +import com.squareup.anvil.compiler.internal.ksp.checkNotMoreThanOneMapKey +import com.squareup.anvil.compiler.internal.ksp.checkNotMoreThanOneQualifier +import com.squareup.anvil.compiler.internal.ksp.checkSingleSuperType +import com.squareup.anvil.compiler.internal.ksp.getKSAnnotationsByType +import com.squareup.anvil.compiler.internal.ksp.ignoreQualifier +import com.squareup.anvil.compiler.internal.ksp.isMapKey +import com.squareup.anvil.compiler.internal.ksp.qualifierAnnotation +import com.squareup.anvil.compiler.internal.ksp.replaces +import com.squareup.anvil.compiler.internal.ksp.resolvableAnnotations +import com.squareup.anvil.compiler.internal.ksp.resolveBoundType +import com.squareup.anvil.compiler.internal.ksp.scopeClassName import com.squareup.anvil.compiler.internal.reference.asClassName import com.squareup.anvil.compiler.internal.reference.classAndInnerClassReferences import com.squareup.anvil.compiler.qualifierKey diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentCodeGen.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentCodeGen.kt index 71dbc5864..fb0b0e278 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentCodeGen.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentCodeGen.kt @@ -20,14 +20,6 @@ import com.squareup.anvil.compiler.api.GeneratedFileWithSources import com.squareup.anvil.compiler.api.createGeneratedFile import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.getKSAnnotationsByType -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationPresent -import com.squareup.anvil.compiler.codegen.ksp.isInterface -import com.squareup.anvil.compiler.codegen.ksp.parentScope -import com.squareup.anvil.compiler.codegen.ksp.replaces -import com.squareup.anvil.compiler.codegen.ksp.resolveKSClassDeclaration -import com.squareup.anvil.compiler.codegen.ksp.scope import com.squareup.anvil.compiler.contributesSubcomponentFactoryFqName import com.squareup.anvil.compiler.contributesSubcomponentFqName import com.squareup.anvil.compiler.contributesToFqName @@ -35,6 +27,14 @@ import com.squareup.anvil.compiler.daggerSubcomponentBuilderFqName import com.squareup.anvil.compiler.daggerSubcomponentFactoryFqName import com.squareup.anvil.compiler.internal.createAnvilSpec import com.squareup.anvil.compiler.internal.generateHintFileName +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.getKSAnnotationsByType +import com.squareup.anvil.compiler.internal.ksp.isAnnotationPresent +import com.squareup.anvil.compiler.internal.ksp.isInterface +import com.squareup.anvil.compiler.internal.ksp.parentScope +import com.squareup.anvil.compiler.internal.ksp.replaces +import com.squareup.anvil.compiler.internal.ksp.resolveKSClassDeclaration +import com.squareup.anvil.compiler.internal.ksp.scope import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionClassReference import com.squareup.anvil.compiler.internal.reference.ClassReference import com.squareup.anvil.compiler.internal.reference.Visibility diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesToCodeGen.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesToCodeGen.kt index 7dc145c87..34b7ab812 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesToCodeGen.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesToCodeGen.kt @@ -21,18 +21,17 @@ import com.squareup.anvil.compiler.api.GeneratedFileWithSources import com.squareup.anvil.compiler.api.createGeneratedFile import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.checkClassIsPublic -import com.squareup.anvil.compiler.codegen.ksp.checkNoDuplicateScope -import com.squareup.anvil.compiler.codegen.ksp.getKSAnnotationsByType -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationPresent -import com.squareup.anvil.compiler.codegen.ksp.isInterface -import com.squareup.anvil.compiler.codegen.ksp.scope -import com.squareup.anvil.compiler.codegen.ksp.scopeClassName import com.squareup.anvil.compiler.contributesToFqName import com.squareup.anvil.compiler.daggerModuleFqName import com.squareup.anvil.compiler.internal.createAnvilSpec import com.squareup.anvil.compiler.internal.generateHintFileName +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.checkClassIsPublic +import com.squareup.anvil.compiler.internal.ksp.checkNoDuplicateScope +import com.squareup.anvil.compiler.internal.ksp.getKSAnnotationsByType +import com.squareup.anvil.compiler.internal.ksp.isAnnotationPresent +import com.squareup.anvil.compiler.internal.ksp.isInterface +import com.squareup.anvil.compiler.internal.ksp.scopeClassName import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionClassReference import com.squareup.anvil.compiler.internal.reference.Visibility import com.squareup.anvil.compiler.internal.reference.asClassName diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KspContributesSubcomponentHandlerSymbolProcessor.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KspContributesSubcomponentHandlerSymbolProcessor.kt index 8d74af480..a9685d852 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KspContributesSubcomponentHandlerSymbolProcessor.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KspContributesSubcomponentHandlerSymbolProcessor.kt @@ -1,6 +1,5 @@ package com.squareup.anvil.compiler.codegen -import com.google.devtools.ksp.getClassDeclarationByName import com.google.devtools.ksp.isAbstract import com.google.devtools.ksp.processing.Resolver import com.google.devtools.ksp.processing.SymbolProcessorEnvironment @@ -19,32 +18,32 @@ import com.squareup.anvil.compiler.ClassScannerKsp import com.squareup.anvil.compiler.KspContributionMerger import com.squareup.anvil.compiler.PARENT_COMPONENT import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.classId -import com.squareup.anvil.compiler.codegen.ksp.declaringClass -import com.squareup.anvil.compiler.codegen.ksp.exclude -import com.squareup.anvil.compiler.codegen.ksp.find -import com.squareup.anvil.compiler.codegen.ksp.fqName -import com.squareup.anvil.compiler.codegen.ksp.getClassesWithAnnotations -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationPresent -import com.squareup.anvil.compiler.codegen.ksp.isDaggerScope -import com.squareup.anvil.compiler.codegen.ksp.isInterface -import com.squareup.anvil.compiler.codegen.ksp.modules -import com.squareup.anvil.compiler.codegen.ksp.parentScope -import com.squareup.anvil.compiler.codegen.ksp.replaces -import com.squareup.anvil.compiler.codegen.ksp.requireClassDeclaration -import com.squareup.anvil.compiler.codegen.ksp.resolvableAnnotations -import com.squareup.anvil.compiler.codegen.ksp.resolveKSClassDeclaration -import com.squareup.anvil.compiler.codegen.ksp.returnTypeOrNull -import com.squareup.anvil.compiler.codegen.ksp.scopeClassName import com.squareup.anvil.compiler.codegen.ksp.trace import com.squareup.anvil.compiler.contributesSubcomponentFqName import com.squareup.anvil.compiler.daggerBindingModuleSpec import com.squareup.anvil.compiler.defaultParentComponentFunctionName -import com.squareup.anvil.compiler.fqName import com.squareup.anvil.compiler.internal.asClassName import com.squareup.anvil.compiler.internal.createAnvilSpec +import com.squareup.anvil.compiler.internal.fqName import com.squareup.anvil.compiler.internal.joinSimpleNamesAndTruncate +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.classId +import com.squareup.anvil.compiler.internal.ksp.declaringClass +import com.squareup.anvil.compiler.internal.ksp.exclude +import com.squareup.anvil.compiler.internal.ksp.find +import com.squareup.anvil.compiler.internal.ksp.fqName +import com.squareup.anvil.compiler.internal.ksp.getClassesWithAnnotations +import com.squareup.anvil.compiler.internal.ksp.isAnnotationPresent +import com.squareup.anvil.compiler.internal.ksp.isDaggerScope +import com.squareup.anvil.compiler.internal.ksp.isInterface +import com.squareup.anvil.compiler.internal.ksp.modules +import com.squareup.anvil.compiler.internal.ksp.parentScope +import com.squareup.anvil.compiler.internal.ksp.replaces +import com.squareup.anvil.compiler.internal.ksp.requireClassDeclaration +import com.squareup.anvil.compiler.internal.ksp.resolvableAnnotations +import com.squareup.anvil.compiler.internal.ksp.resolveKSClassDeclaration +import com.squareup.anvil.compiler.internal.ksp.returnTypeOrNull +import com.squareup.anvil.compiler.internal.ksp.scopeClassName import com.squareup.anvil.compiler.internal.reference.asClassId import com.squareup.anvil.compiler.internal.safePackageString import com.squareup.anvil.compiler.mapToSet diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KspMergeAnnotationsCheckSymbolProcessor.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KspMergeAnnotationsCheckSymbolProcessor.kt index 7d50cd86e..cb3817720 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KspMergeAnnotationsCheckSymbolProcessor.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/KspMergeAnnotationsCheckSymbolProcessor.kt @@ -9,18 +9,18 @@ import com.google.devtools.ksp.symbol.KSAnnotation import com.google.devtools.ksp.symbol.KSClassDeclaration import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.checkNoDuplicateScope -import com.squareup.anvil.compiler.codegen.ksp.declaringClass -import com.squareup.anvil.compiler.codegen.ksp.fqName -import com.squareup.anvil.compiler.codegen.ksp.getClassesWithAnnotations -import com.squareup.anvil.compiler.codegen.ksp.getKSAnnotationsByType -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationPresent -import com.squareup.anvil.compiler.codegen.ksp.mergeAnnotations -import com.squareup.anvil.compiler.codegen.ksp.resolveKSClassDeclaration import com.squareup.anvil.compiler.daggerComponentFqName import com.squareup.anvil.compiler.daggerModuleFqName import com.squareup.anvil.compiler.daggerSubcomponentFqName +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.checkNoDuplicateScope +import com.squareup.anvil.compiler.internal.ksp.declaringClass +import com.squareup.anvil.compiler.internal.ksp.fqName +import com.squareup.anvil.compiler.internal.ksp.getClassesWithAnnotations +import com.squareup.anvil.compiler.internal.ksp.getKSAnnotationsByType +import com.squareup.anvil.compiler.internal.ksp.isAnnotationPresent +import com.squareup.anvil.compiler.internal.ksp.mergeAnnotations +import com.squareup.anvil.compiler.internal.ksp.resolveKSClassDeclaration import com.squareup.anvil.compiler.mergeComponentClassName import com.squareup.anvil.compiler.mergeComponentFqName import com.squareup.anvil.compiler.mergeInterfacesFqName diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AnvilAnnotationDetectorCheck.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AnvilAnnotationDetectorCheck.kt index 305c390c2..89408cddf 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AnvilAnnotationDetectorCheck.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AnvilAnnotationDetectorCheck.kt @@ -11,10 +11,10 @@ import com.squareup.anvil.compiler.api.CodeGenerator import com.squareup.anvil.compiler.codegen.CheckOnlyCodeGenerator import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException import com.squareup.anvil.compiler.contributesBindingFqName import com.squareup.anvil.compiler.contributesSubcomponentFqName import com.squareup.anvil.compiler.contributesToFqName +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionClassReference import com.squareup.anvil.compiler.internal.reference.classAndInnerClassReferences import com.squareup.anvil.compiler.mergeComponentFqName diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AnvilMergeAnnotationDetectorCheck.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AnvilMergeAnnotationDetectorCheck.kt index 33d6e965d..4697e8084 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AnvilMergeAnnotationDetectorCheck.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AnvilMergeAnnotationDetectorCheck.kt @@ -11,7 +11,7 @@ import com.squareup.anvil.compiler.api.CodeGenerator import com.squareup.anvil.compiler.codegen.CheckOnlyCodeGenerator import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionClassReference import com.squareup.anvil.compiler.internal.reference.classAndInnerClassReferences import com.squareup.anvil.compiler.mergeComponentFqName diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedFactoryCodeGen.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedFactoryCodeGen.kt index 40ed557f3..99c38c2c6 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedFactoryCodeGen.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedFactoryCodeGen.kt @@ -33,14 +33,14 @@ import com.squareup.anvil.compiler.codegen.dagger.AssistedFactoryCodeGen.Embedde import com.squareup.anvil.compiler.codegen.dagger.AssistedFactoryCodeGen.KspGenerator.AssistedFactoryFunction.Companion.toAssistedFactoryFunction import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.KspErrorTypeException -import com.squareup.anvil.compiler.codegen.ksp.contextualToTypeName -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationPresent -import com.squareup.anvil.compiler.codegen.ksp.isInterface -import com.squareup.anvil.compiler.codegen.ksp.resolveKSClassDeclaration import com.squareup.anvil.compiler.internal.createAnvilSpec import com.squareup.anvil.compiler.internal.joinSimpleNames +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.KspErrorTypeException +import com.squareup.anvil.compiler.internal.ksp.contextualToTypeName +import com.squareup.anvil.compiler.internal.ksp.isAnnotationPresent +import com.squareup.anvil.compiler.internal.ksp.isInterface +import com.squareup.anvil.compiler.internal.ksp.resolveKSClassDeclaration import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionClassReference import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionFunctionReference import com.squareup.anvil.compiler.internal.reference.ClassReference diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedInjectCodeGen.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedInjectCodeGen.kt index 6b65abf6d..611727836 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedInjectCodeGen.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedInjectCodeGen.kt @@ -17,11 +17,11 @@ import com.squareup.anvil.compiler.codegen.PrivateCodeGenerator import com.squareup.anvil.compiler.codegen.injectConstructor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.injectConstructors -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationPresent import com.squareup.anvil.compiler.internal.createAnvilSpec import com.squareup.anvil.compiler.internal.joinSimpleNames +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.injectConstructors +import com.squareup.anvil.compiler.internal.ksp.isAnnotationPresent import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionClassReference import com.squareup.anvil.compiler.internal.reference.ClassReference import com.squareup.anvil.compiler.internal.reference.MemberFunctionReference diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/BindsMethodValidator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/BindsMethodValidator.kt index 7465193e9..3f59b9ba8 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/BindsMethodValidator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/BindsMethodValidator.kt @@ -15,18 +15,18 @@ import com.squareup.anvil.compiler.api.CodeGenerator import com.squareup.anvil.compiler.codegen.CheckOnlyCodeGenerator import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.contextualToTypeName -import com.squareup.anvil.compiler.codegen.ksp.getAnnotatedFunctions -import com.squareup.anvil.compiler.codegen.ksp.getAnnotatedSymbols -import com.squareup.anvil.compiler.codegen.ksp.isExtensionDeclaration -import com.squareup.anvil.compiler.codegen.ksp.reportableReturnTypeNode -import com.squareup.anvil.compiler.codegen.ksp.resolveKSClassDeclaration -import com.squareup.anvil.compiler.codegen.ksp.returnTypeOrNull -import com.squareup.anvil.compiler.codegen.ksp.superTypesExcludingAny -import com.squareup.anvil.compiler.codegen.ksp.withCompanion import com.squareup.anvil.compiler.daggerBindsFqName import com.squareup.anvil.compiler.daggerModuleFqName +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.contextualToTypeName +import com.squareup.anvil.compiler.internal.ksp.getAnnotatedFunctions +import com.squareup.anvil.compiler.internal.ksp.getAnnotatedSymbols +import com.squareup.anvil.compiler.internal.ksp.isExtensionDeclaration +import com.squareup.anvil.compiler.internal.ksp.reportableReturnTypeNode +import com.squareup.anvil.compiler.internal.ksp.resolveKSClassDeclaration +import com.squareup.anvil.compiler.internal.ksp.returnTypeOrNull +import com.squareup.anvil.compiler.internal.ksp.superTypesExcludingAny +import com.squareup.anvil.compiler.internal.ksp.withCompanion import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionFunctionReference import com.squareup.anvil.compiler.internal.reference.MemberFunctionReference import com.squareup.anvil.compiler.internal.reference.TypeReference diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ComponentDetectorCheck.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ComponentDetectorCheck.kt index 336cee26f..e4b1ee550 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ComponentDetectorCheck.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ComponentDetectorCheck.kt @@ -11,8 +11,8 @@ import com.squareup.anvil.compiler.api.CodeGenerator import com.squareup.anvil.compiler.codegen.CheckOnlyCodeGenerator import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException import com.squareup.anvil.compiler.daggerComponentFqName +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionClassReference import com.squareup.anvil.compiler.internal.reference.classAndInnerClassReferences import org.jetbrains.kotlin.descriptors.ModuleDescriptor diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/DaggerGenerationUtils.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/DaggerGenerationUtils.kt index 0b82590db..41a0782fb 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/DaggerGenerationUtils.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/DaggerGenerationUtils.kt @@ -14,22 +14,22 @@ import com.google.devtools.ksp.symbol.Visibility import com.squareup.anvil.compiler.addAllWithoutCopy import com.squareup.anvil.compiler.addWithoutCopy import com.squareup.anvil.compiler.assistedFqName -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.contextualToTypeName -import com.squareup.anvil.compiler.codegen.ksp.getKSAnnotationsByType -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationPresent -import com.squareup.anvil.compiler.codegen.ksp.isInterface -import com.squareup.anvil.compiler.codegen.ksp.isLateInit -import com.squareup.anvil.compiler.codegen.ksp.isQualifier -import com.squareup.anvil.compiler.codegen.ksp.resolvableAnnotations -import com.squareup.anvil.compiler.codegen.ksp.resolveKSClassDeclaration -import com.squareup.anvil.compiler.codegen.ksp.withJvmSuppressWildcardsIfNeeded import com.squareup.anvil.compiler.daggerDoubleCheckFqNameString import com.squareup.anvil.compiler.daggerLazyClassName import com.squareup.anvil.compiler.daggerLazyFqName import com.squareup.anvil.compiler.injectFqName import com.squareup.anvil.compiler.internal.capitalize import com.squareup.anvil.compiler.internal.joinSimpleNames +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.contextualToTypeName +import com.squareup.anvil.compiler.internal.ksp.getKSAnnotationsByType +import com.squareup.anvil.compiler.internal.ksp.isAnnotationPresent +import com.squareup.anvil.compiler.internal.ksp.isInterface +import com.squareup.anvil.compiler.internal.ksp.isLateInit +import com.squareup.anvil.compiler.internal.ksp.isQualifier +import com.squareup.anvil.compiler.internal.ksp.resolvableAnnotations +import com.squareup.anvil.compiler.internal.ksp.resolveKSClassDeclaration +import com.squareup.anvil.compiler.internal.ksp.withJvmSuppressWildcardsIfNeeded import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionClassReference import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionPropertyReference import com.squareup.anvil.compiler.internal.reference.ClassReference diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryCodeGen.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryCodeGen.kt index ae8d32613..15ea43090 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryCodeGen.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryCodeGen.kt @@ -16,12 +16,12 @@ import com.squareup.anvil.compiler.codegen.PrivateCodeGenerator import com.squareup.anvil.compiler.codegen.injectConstructor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.injectConstructors -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationPresent import com.squareup.anvil.compiler.injectFqName import com.squareup.anvil.compiler.internal.containingFileAsJavaFile import com.squareup.anvil.compiler.internal.createAnvilSpec import com.squareup.anvil.compiler.internal.joinSimpleNames +import com.squareup.anvil.compiler.internal.ksp.injectConstructors +import com.squareup.anvil.compiler.internal.ksp.isAnnotationPresent import com.squareup.anvil.compiler.internal.reference.ClassReference import com.squareup.anvil.compiler.internal.reference.MemberFunctionReference import com.squareup.anvil.compiler.internal.reference.asClassName diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MapKeyCreatorCodeGen.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MapKeyCreatorCodeGen.kt index d791dce31..af2a59a7d 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MapKeyCreatorCodeGen.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MapKeyCreatorCodeGen.kt @@ -18,10 +18,10 @@ import com.squareup.anvil.compiler.api.createGeneratedFile import com.squareup.anvil.compiler.codegen.PrivateCodeGenerator import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.contextualToTypeName -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationClass import com.squareup.anvil.compiler.internal.createAnvilSpec +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.contextualToTypeName +import com.squareup.anvil.compiler.internal.ksp.isAnnotationClass import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionClassReference import com.squareup.anvil.compiler.internal.reference.ClassReference import com.squareup.anvil.compiler.internal.reference.MemberPropertyReference diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryCodeGen.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryCodeGen.kt index 81b975a73..032f4f83c 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryCodeGen.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryCodeGen.kt @@ -24,22 +24,21 @@ import com.squareup.anvil.compiler.api.createGeneratedFile import com.squareup.anvil.compiler.codegen.PrivateCodeGenerator import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessor import com.squareup.anvil.compiler.codegen.ksp.AnvilSymbolProcessorProvider -import com.squareup.anvil.compiler.codegen.ksp.KspAnvilException -import com.squareup.anvil.compiler.codegen.ksp.contextualToTypeName -import com.squareup.anvil.compiler.codegen.ksp.getAnnotatedFunctions -import com.squareup.anvil.compiler.codegen.ksp.getKSAnnotationsByType -import com.squareup.anvil.compiler.codegen.ksp.isAnnotationPresent -import com.squareup.anvil.compiler.codegen.ksp.isInterface -import com.squareup.anvil.compiler.codegen.ksp.reportableReturnTypeNode -import com.squareup.anvil.compiler.codegen.ksp.returnTypeOrNull -import com.squareup.anvil.compiler.codegen.ksp.withCompanion -import com.squareup.anvil.compiler.codegen.ksp.withJvmSuppressWildcardsIfNeeded import com.squareup.anvil.compiler.daggerModuleFqName import com.squareup.anvil.compiler.daggerProvidesFqName import com.squareup.anvil.compiler.internal.capitalize import com.squareup.anvil.compiler.internal.containingFileAsJavaFile import com.squareup.anvil.compiler.internal.createAnvilSpec import com.squareup.anvil.compiler.internal.joinSimpleNames +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException +import com.squareup.anvil.compiler.internal.ksp.contextualToTypeName +import com.squareup.anvil.compiler.internal.ksp.getAnnotatedFunctions +import com.squareup.anvil.compiler.internal.ksp.getKSAnnotationsByType +import com.squareup.anvil.compiler.internal.ksp.isAnnotationPresent +import com.squareup.anvil.compiler.internal.ksp.isInterface +import com.squareup.anvil.compiler.internal.ksp.reportableReturnTypeNode +import com.squareup.anvil.compiler.internal.ksp.withCompanion +import com.squareup.anvil.compiler.internal.ksp.withJvmSuppressWildcardsIfNeeded import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionFunctionReference import com.squareup.anvil.compiler.internal.reference.ClassReference import com.squareup.anvil.compiler.internal.reference.MemberFunctionReference diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/AnvilSymbolProcessing.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/AnvilSymbolProcessing.kt index ad9cae20d..5ad5e560c 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/AnvilSymbolProcessing.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/AnvilSymbolProcessing.kt @@ -7,6 +7,7 @@ import com.google.devtools.ksp.processing.SymbolProcessorProvider import com.google.devtools.ksp.symbol.KSAnnotated import com.squareup.anvil.compiler.api.AnvilApplicabilityChecker import com.squareup.anvil.compiler.codegen.toAnvilContext +import com.squareup.anvil.compiler.internal.ksp.KspAnvilException import com.squareup.kotlinpoet.asClassName import kotlin.time.measureTimedValue diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSCallable.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSCallable.kt index 07a98667f..1651d9027 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSCallable.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSCallable.kt @@ -7,6 +7,8 @@ import com.google.devtools.ksp.symbol.KSDeclaration import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.google.devtools.ksp.symbol.KSPropertyDeclaration import com.google.devtools.ksp.symbol.KSType +import com.squareup.anvil.compiler.internal.ksp.fqName +import com.squareup.anvil.compiler.internal.ksp.requireClassDeclaration import org.jetbrains.kotlin.name.FqName /** diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/MemberFunctionReferenceTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/MemberFunctionReferenceTest.kt index 8b425cb54..01845b74c 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/MemberFunctionReferenceTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/MemberFunctionReferenceTest.kt @@ -3,6 +3,7 @@ package com.squareup.anvil.compiler.internal.reference import com.google.common.truth.Truth.assertThat import com.squareup.anvil.compiler.compile import com.squareup.anvil.compiler.internal.fqName +import com.squareup.anvil.compiler.internal.ksp.fqName import com.squareup.anvil.compiler.internal.testing.simpleCodeGenerator import com.tschuchort.compiletesting.KotlinCompilation.ExitCode.OK import org.jetbrains.kotlin.name.FqName