From 4acf4bc19c81ac8513cb0da06ebae08f0b5e92a4 Mon Sep 17 00:00:00 2001 From: Rick Busarow Date: Thu, 16 Nov 2023 15:31:14 -0600 Subject: [PATCH 1/2] bumping KtLint to 1.0.1, ktlint-gradle to 11.6.1 As of 1.0.0, KtLint changed its default style from `intellij` to `ktlint_official`. The `intellij` style was also renamed to `intellij_idea`. --- .editorconfig | 33 ++++++++++++++++++++++++++------- gradle/libs.versions.toml | 4 ++-- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.editorconfig b/.editorconfig index 0ce475a73..6ab0abb35 100644 --- a/.editorconfig +++ b/.editorconfig @@ -30,10 +30,6 @@ ij_formatter_tags_enabled = false ij_smart_tabs = false ij_wrap_on_typing = false -# Back-ticked method names are allowed to exceed the line length. That's especially helpful for -# test methods with descriptive names. -ktlint_ignore_back_ticked_identifier=true - [*.java] ij_java_align_consecutive_assignments = false ij_java_align_consecutive_variable_declarations = false @@ -483,7 +479,30 @@ ij_groovy_while_brace_force = if_multiline ij_groovy_while_on_new_line = false ij_groovy_wrap_long_lines = false -[{*.gradle.kts,*.kt,*.kts,*.main.kts}] +# These KtLint-specific settings have their own section so that we can suppress the +# 'EditorConfigKeyCorrectness' warning in one place. IntelliJ doesn't recognize the KtLint settings. +# noinspection EditorConfigKeyCorrectness +# noinspection EditorConfigHeaderUniqueness +[{*.kt,*.kts}] +kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^ +# Back-ticked method names are allowed to exceed the line length. That's especially helpful for +# test methods with descriptive names. +ktlint_ignore_back_ticked_identifier = true + +ktlint_code_style = intellij_idea + +ktlint_standard_class-naming = disabled +ktlint_standard_class-signature = disabled +ktlint_standard_filename = disabled +ktlint_standard_function-expression-body = disabled +ktlint_standard_function-naming = disabled +ktlint_standard_function-signature = disabled +ktlint_standard_max-line-length = disabled +ktlint_standard_no-empty-first-line-in-method-block = disabled +ktlint_standard_property-naming = disabled + +# noinspection EditorConfigHeaderUniqueness +[{*.kt,*.kts}] ij_continuation_indent_size = 2 ij_kotlin_align_in_columns_case_branch = false ij_kotlin_align_multiline_binary_operation = false @@ -491,8 +510,8 @@ ij_kotlin_align_multiline_extends_list = false ij_kotlin_align_multiline_method_parentheses = false ij_kotlin_align_multiline_parameters = false ij_kotlin_align_multiline_parameters_in_calls = false -ij_kotlin_allow_trailing_comma = false -ij_kotlin_allow_trailing_comma_on_call_site = false +ij_kotlin_allow_trailing_comma = true +ij_kotlin_allow_trailing_comma_on_call_site = true ij_kotlin_assignment_wrap = normal ij_kotlin_blank_lines_after_class_header = 0 ij_kotlin_blank_lines_around_block_when_branches = 0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b21b66d04..c2717688b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -26,8 +26,8 @@ kotlin = "1.9.10" kotlinpoet = "1.14.2" # If updating KSP version, we currently have ksp override logic in settings.gradle that needs to be updated too ksp = "1.9.10-1.0.13" -ktlint = "0.41.0" -ktlintPlugin = "11.3.2" +ktlint = "1.0.1" +ktlintPlugin = "11.6.1" mavenPublish = "0.25.3" # From 12c853d2998373e6abcad792d6ab9ba366c1ef89 Mon Sep 17 00:00:00 2001 From: Rick Busarow Date: Thu, 16 Nov 2023 15:40:33 -0600 Subject: [PATCH 2/2] Apply formatting changes from the KtLint bump --- .../anvil/annotations/ContributesBinding.kt | 6 +- .../annotations/ContributesMultibinding.kt | 2 +- .../annotations/ContributesSubcomponent.kt | 2 +- .../anvil/annotations/ContributesTo.kt | 2 +- .../anvil/annotations/MergeComponent.kt | 2 +- .../anvil/annotations/MergeSubcomponent.kt | 2 +- .../annotations/compat/MergeInterfaces.kt | 2 +- .../anvil/annotations/compat/MergeModules.kt | 2 +- .../squareup/anvil/PublishConventionPlugin.kt | 4 +- .../benchmark/CreateBenchmarkProjectTask.kt | 56 +++---- .../compiler/api/AnvilCompilationException.kt | 30 ++-- .../anvil/compiler/api/CodeGenerator.kt | 4 +- .../anvil/compiler/api/GeneratedFile.kt | 2 +- .../compiler/internal/DescriptorUtils.kt | 8 +- .../anvil/compiler/internal/FqName.kt | 6 +- .../compiler/internal/KotlinPoetUtils.kt | 14 +- .../anvil/compiler/internal/PsiUtils.kt | 14 +- .../reference/AnnotationArgumentReference.kt | 12 +- .../internal/reference/AnnotationReference.kt | 44 +++--- .../reference/AnvilModuleDescriptor.kt | 12 +- .../internal/reference/ClassReference.kt | 22 +-- .../internal/reference/FunctionReference.kt | 8 +- .../reference/MemberFunctionReference.kt | 14 +- .../reference/MemberPropertyReference.kt | 20 +-- .../internal/reference/ParameterReference.kt | 20 +-- .../internal/reference/PropertyReference.kt | 8 +- .../reference/TopLevelFunctionReference.kt | 4 +- .../reference/TopLevelPropertyReference.kt | 8 +- .../reference/TypeParameterReference.kt | 8 +- .../internal/reference/TypeReference.kt | 51 ++++--- .../compiler/internal/reference/Visibility.kt | 2 +- .../internal/testing/AnvilCompilation.kt | 30 ++-- .../internal/testing/AnvilCompilationMode.kt | 4 +- .../internal/testing/ReflectionTestUtils.kt | 3 +- .../internal/testing/SimpleCodeGenerator.kt | 6 +- .../compiler/internal/testing/TestUtils.kt | 6 +- .../compiler/AnvilCommandLineProcessor.kt | 14 +- .../anvil/compiler/AnvilComponentRegistrar.kt | 12 +- .../squareup/anvil/compiler/ClassScanner.kt | 14 +- .../squareup/anvil/compiler/ClassScannerIr.kt | 2 +- .../anvil/compiler/InterfaceMerger.kt | 30 ++-- .../com/squareup/anvil/compiler/IrUtils.kt | 8 +- .../squareup/anvil/compiler/ModuleMergerIr.kt | 54 +++---- .../java/com/squareup/anvil/compiler/Utils.kt | 10 +- .../codegen/AnnotationReferenceExtensions.kt | 20 +-- .../codegen/BindingModuleGenerator.kt | 50 +++--- .../codegen/ClassReferenceExtensions.kt | 24 +-- .../codegen/CodeGenerationExtension.kt | 12 +- .../compiler/codegen/ContributedBinding.kt | 16 +- .../codegen/ContributesBindingCodeGen.kt | 17 ++- .../codegen/ContributesMultibindingCodeGen.kt | 18 +-- .../ContributesSubcomponentGenerator.kt | 38 ++--- ...ContributesSubcomponentHandlerGenerator.kt | 67 ++++---- .../compiler/codegen/ContributesToCodeGen.kt | 12 +- .../compiler/codegen/FlushingCodeGenerator.kt | 2 +- .../codegen/MergeAnnotationsCheckGenerator.kt | 8 +- .../compiler/codegen/PrivateCodeGenerator.kt | 4 +- .../compiler/codegen/RealAnvilContext.kt | 8 +- .../dagger/AnvilAnnotationDetectorCheck.kt | 8 +- .../AnvilMergeAnnotationDetectorCheck.kt | 12 +- .../dagger/AssistedFactoryGenerator.kt | 40 ++--- .../codegen/dagger/AssistedInjectGenerator.kt | 24 +-- .../codegen/dagger/BindsMethodValidator.kt | 10 +- .../codegen/dagger/ComponentDetectorCheck.kt | 7 +- .../codegen/dagger/DaggerGenerationUtils.kt | 35 +++-- .../InjectConstructorFactoryGenerator.kt | 22 +-- .../codegen/dagger/MapKeyCreatorGenerator.kt | 18 +-- .../dagger/MembersInjectorGenerator.kt | 24 +-- .../compiler/codegen/dagger/Parameter.kt | 12 +- .../dagger/ProvidesMethodFactoryGenerator.kt | 44 +++--- .../codegen/ksp/KSAnnotationExtensions.kt | 6 +- .../ksp/KSClassDeclarationExtensions.kt | 18 +-- .../compiler/codegen/ksp/KspAnvilException.kt | 2 +- .../anvil/compiler/codegen/ksp/KspUtil.kt | 8 +- .../codegen/reference/AnnotatedReferenceIr.kt | 4 +- .../AnnotationArgumentReferenceIr.kt | 6 +- .../reference/AnnotationReferenceIr.kt | 16 +- .../codegen/reference/ClassReferenceIr.kt | 8 +- .../reference/RealAnvilModuleDescriptor.kt | 8 +- .../compiler/InterfaceMergerRepeatableTest.kt | 21 +-- .../anvil/compiler/InterfaceMergerTest.kt | 85 ++++++----- .../anvil/compiler/MergeModulesTest.kt | 88 +++++------ .../compiler/ModuleMergerRepeatableTest.kt | 33 ++-- .../anvil/compiler/ModuleMergerTest.kt | 123 +++++++-------- .../com/squareup/anvil/compiler/TestUtils.kt | 6 +- .../codegen/BindingModuleGeneratorTest.kt | 73 ++++----- .../BindingModuleMultibindingMapTest.kt | 19 +-- .../BindingModuleMultibindingSetTest.kt | 31 ++-- .../codegen/BindingModulePriorityTest.kt | 37 ++--- .../codegen/BindingModuleQualifierTest.kt | 29 ++-- .../codegen/CodeGenerationExtensionTest.kt | 12 +- .../ContributesBindingGeneratorTest.kt | 21 +-- .../ContributesMultibindingGeneratorTest.kt | 27 ++-- .../ContributesSubcomponentGeneratorTest.kt | 66 ++++---- ...ributesSubcomponentHandlerGeneratorTest.kt | 144 +++++++++--------- .../codegen/ContributesToCodeGenTest.kt | 15 +- .../codegen/ksp/SimpleSymbolProcessor.kt | 6 +- .../AnvilAnnotationDetectorCheckTest.kt | 22 +-- .../AnvilMergeAnnotationDetectorCheckTest.kt | 23 +-- .../dagger/AssistedFactoryGeneratorTest.kt | 129 ++++++++-------- .../dagger/AssistedInjectGeneratorTest.kt | 53 +++---- .../dagger/BindsMethodValidatorTest.kt | 43 +++--- .../dagger/ComponentDetectorCheckTest.kt | 21 +-- .../InjectConstructorFactoryGeneratorTest.kt | 133 ++++++++-------- .../dagger/MapKeyCreatorGeneratorTest.kt | 98 +++++++----- .../dagger/MembersInjectorGeneratorTest.kt | 123 +++++++-------- .../ProvidesMethodFactoryGeneratorTest.kt | 141 ++++++++--------- .../anvil/compiler/dagger/TestClasses.kt | 2 +- .../reference/AnnotationReferenceTest.kt | 65 ++++---- .../internal/reference/ClassReferenceTest.kt | 64 ++++---- .../reference/MemberFunctionReferenceTest.kt | 70 ++++----- .../reference/MemberPropertyReferenceTest.kt | 96 ++++++------ .../TopLevelFunctionReferenceTest.kt | 18 +-- .../TopLevelPropertyReferenceTest.kt | 20 +-- .../internal/reference/TypeReferenceTest.kt | 48 +++--- .../com/squareup/anvil/plugin/AnvilPlugin.kt | 36 ++--- .../squareup/anvil/plugin/VariantFilter.kt | 6 +- 117 files changed, 1669 insertions(+), 1590 deletions(-) diff --git a/annotations/src/main/java/com/squareup/anvil/annotations/ContributesBinding.kt b/annotations/src/main/java/com/squareup/anvil/annotations/ContributesBinding.kt index 1987ad70c..6db84a8e5 100644 --- a/annotations/src/main/java/com/squareup/anvil/annotations/ContributesBinding.kt +++ b/annotations/src/main/java/com/squareup/anvil/annotations/ContributesBinding.kt @@ -127,13 +127,15 @@ public annotation class ContributesBinding( * are used together for the same class. If not, simply remove the qualifier from the class * and don't use this parameter. */ - val ignoreQualifier: Boolean = false + val ignoreQualifier: Boolean = false, ) { /** * The priority of a contributed binding. */ @Suppress("unused") public enum class Priority { - NORMAL, HIGH, HIGHEST + NORMAL, + HIGH, + HIGHEST, } } diff --git a/annotations/src/main/java/com/squareup/anvil/annotations/ContributesMultibinding.kt b/annotations/src/main/java/com/squareup/anvil/annotations/ContributesMultibinding.kt index bde760f6e..bd95ef528 100644 --- a/annotations/src/main/java/com/squareup/anvil/annotations/ContributesMultibinding.kt +++ b/annotations/src/main/java/com/squareup/anvil/annotations/ContributesMultibinding.kt @@ -126,5 +126,5 @@ public annotation class ContributesMultibinding( * are used together for the same class. If not, simply remove the qualifier from the class and * don't use this parameter. */ - val ignoreQualifier: Boolean = false + val ignoreQualifier: Boolean = false, ) diff --git a/annotations/src/main/java/com/squareup/anvil/annotations/ContributesSubcomponent.kt b/annotations/src/main/java/com/squareup/anvil/annotations/ContributesSubcomponent.kt index 6d7ab5ad3..a13d3b071 100644 --- a/annotations/src/main/java/com/squareup/anvil/annotations/ContributesSubcomponent.kt +++ b/annotations/src/main/java/com/squareup/anvil/annotations/ContributesSubcomponent.kt @@ -98,7 +98,7 @@ public annotation class ContributesSubcomponent( * This contributed subcomponent will replace these contributed subcomponents. All replaced * subcomponents must use the same scope. */ - val replaces: Array> = [] + val replaces: Array> = [], ) { /** * A factory for a contributed subcomponent. diff --git a/annotations/src/main/java/com/squareup/anvil/annotations/ContributesTo.kt b/annotations/src/main/java/com/squareup/anvil/annotations/ContributesTo.kt index 7bdf773fe..0466d2bd6 100644 --- a/annotations/src/main/java/com/squareup/anvil/annotations/ContributesTo.kt +++ b/annotations/src/main/java/com/squareup/anvil/annotations/ContributesTo.kt @@ -49,5 +49,5 @@ public annotation class ContributesTo( * include other contributed bindings, multibindings and Dagger modules. All replaced classes * must use the same scope. */ - val replaces: Array> = [] + val replaces: Array> = [], ) diff --git a/annotations/src/main/java/com/squareup/anvil/annotations/MergeComponent.kt b/annotations/src/main/java/com/squareup/anvil/annotations/MergeComponent.kt index ba9b517d0..a046a4045 100644 --- a/annotations/src/main/java/com/squareup/anvil/annotations/MergeComponent.kt +++ b/annotations/src/main/java/com/squareup/anvil/annotations/MergeComponent.kt @@ -51,5 +51,5 @@ public annotation class MergeComponent( * List of bindings, multibindings, modules and component interfaces that are contributed to the * same scope, but should be excluded from the component. */ - val exclude: Array> = [] + val exclude: Array> = [], ) diff --git a/annotations/src/main/java/com/squareup/anvil/annotations/MergeSubcomponent.kt b/annotations/src/main/java/com/squareup/anvil/annotations/MergeSubcomponent.kt index 1be537ea5..0273e1387 100644 --- a/annotations/src/main/java/com/squareup/anvil/annotations/MergeSubcomponent.kt +++ b/annotations/src/main/java/com/squareup/anvil/annotations/MergeSubcomponent.kt @@ -70,5 +70,5 @@ public annotation class MergeSubcomponent( * List of bindings, multibindings, modules and component interfaces that are contributed to the * same scope, but should be excluded from the subcomponent. */ - val exclude: Array> = [] + val exclude: Array> = [], ) diff --git a/annotations/src/main/java/com/squareup/anvil/annotations/compat/MergeInterfaces.kt b/annotations/src/main/java/com/squareup/anvil/annotations/compat/MergeInterfaces.kt index c3646ce0e..24c3ec148 100644 --- a/annotations/src/main/java/com/squareup/anvil/annotations/compat/MergeInterfaces.kt +++ b/annotations/src/main/java/com/squareup/anvil/annotations/compat/MergeInterfaces.kt @@ -58,5 +58,5 @@ public annotation class MergeInterfaces( * List of component interfaces that are contributed to the same scope, but should be excluded * from the merged interface. */ - val exclude: Array> = [] + val exclude: Array> = [], ) diff --git a/annotations/src/main/java/com/squareup/anvil/annotations/compat/MergeModules.kt b/annotations/src/main/java/com/squareup/anvil/annotations/compat/MergeModules.kt index b004145de..0c7b8343b 100644 --- a/annotations/src/main/java/com/squareup/anvil/annotations/compat/MergeModules.kt +++ b/annotations/src/main/java/com/squareup/anvil/annotations/compat/MergeModules.kt @@ -72,5 +72,5 @@ public annotation class MergeModules( * List of bindings, multibindings and modules that are contributed to the same scope, but * should be excluded from the merged module. */ - val exclude: Array> = [] + val exclude: Array> = [], ) diff --git a/build-logic/src/main/kotlin/com/squareup/anvil/PublishConventionPlugin.kt b/build-logic/src/main/kotlin/com/squareup/anvil/PublishConventionPlugin.kt index 661ed3c70..9b93d92be 100644 --- a/build-logic/src/main/kotlin/com/squareup/anvil/PublishConventionPlugin.kt +++ b/build-logic/src/main/kotlin/com/squareup/anvil/PublishConventionPlugin.kt @@ -41,7 +41,7 @@ open class PublishConventionPlugin : Plugin { configurePublication( target, mavenPublishing, - KotlinJvm(javadocJar = JavadocJar.Dokka("dokkaHtml"), sourcesJar = true) + KotlinJvm(javadocJar = JavadocJar.Dokka("dokkaHtml"), sourcesJar = true), ) } } @@ -52,7 +52,7 @@ open class PublishConventionPlugin : Plugin { private fun configurePublication( target: Project, mavenPublishing: MavenPublishBaseExtension, - platform: Platform + platform: Platform, ) { mavenPublishing.configure(platform) diff --git a/build-logic/src/main/kotlin/com/squareup/anvil/benchmark/CreateBenchmarkProjectTask.kt b/build-logic/src/main/kotlin/com/squareup/anvil/benchmark/CreateBenchmarkProjectTask.kt index 825616864..eecfff9f3 100644 --- a/build-logic/src/main/kotlin/com/squareup/anvil/benchmark/CreateBenchmarkProjectTask.kt +++ b/build-logic/src/main/kotlin/com/squareup/anvil/benchmark/CreateBenchmarkProjectTask.kt @@ -65,7 +65,7 @@ open class CreateBenchmarkProjectTask : DefaultTask() { val appModule = AppModule( name = "app", - path = ":${rootDir.name}:app" + path = ":${rootDir.name}:app", ) createSettingsGradleFile(libraryModules.values + appModule) @@ -111,7 +111,7 @@ open class CreateBenchmarkProjectTask : DefaultTask() { private fun createLibraryModule( module: LibraryModule, - allLibraryModules: Map + allLibraryModules: Map, ) { val moduleDir = File(rootDir, module.name) createLibraryBuildGradleFile(module, allLibraryModules, moduleDir) @@ -121,7 +121,7 @@ open class CreateBenchmarkProjectTask : DefaultTask() { private fun createLibraryBuildGradleFile( module: LibraryModule, allLibraryModules: Map, - moduleDir: File + moduleDir: File, ) { val libDependency = allLibraryModules[module.index - 10] ?.let { @@ -153,7 +153,7 @@ open class CreateBenchmarkProjectTask : DefaultTask() { private fun createLibraryModuleSourceFiles( module: LibraryModule, - moduleDir: File + moduleDir: File, ) { val index = module.index val group = index % 10 @@ -186,16 +186,16 @@ open class CreateBenchmarkProjectTask : DefaultTask() { AnnotationSpec .builder(contributesTo) .addMember("scope = %T::class", scopeComponent) - .build() + .build(), ) .addFunction( FunSpec .builder("boundInterface$index") .addModifiers(ABSTRACT) .returns(boundInterface) - .build() + .build(), ) - .build() + .build(), ) addType(TypeSpec.interfaceBuilder(injectedInterface).build()) @@ -207,9 +207,9 @@ open class CreateBenchmarkProjectTask : DefaultTask() { .builder(contributesSubcomponent) .addMember("scope = %T::class", scopeSubcomponent) .addMember("parentScope = %T::class", scopeComponent) - .build() + .build(), ) - .build() + .build(), ) addType( TypeSpec @@ -218,16 +218,16 @@ open class CreateBenchmarkProjectTask : DefaultTask() { AnnotationSpec .builder(contributesTo) .addMember("scope = %T::class", scopeSubcomponent) - .build() + .build(), ) .addFunction( FunSpec .builder("injectedInterface$index") .addModifiers(ABSTRACT) .returns(injectedInterface) - .build() + .build(), ) - .build() + .build(), ) } } @@ -250,10 +250,10 @@ open class CreateBenchmarkProjectTask : DefaultTask() { addMember("replaces = [$template]", *replacedImpls.toTypedArray()) } } - .build() + .build(), ) .addSuperinterface(boundInterface) - .build() + .build(), ) .addType( TypeSpec @@ -269,13 +269,13 @@ open class CreateBenchmarkProjectTask : DefaultTask() { AnnotationSpec .builder(Suppress::class) .addMember("\"UNUSED_PARAMETER\"") - .build() + .build(), ) - .build() + .build(), ) - .build() + .build(), ) - .build() + .build(), ) .addType( TypeSpec @@ -285,7 +285,7 @@ open class CreateBenchmarkProjectTask : DefaultTask() { AnnotationSpec .builder(contributesTo) .addMember("scope = %T::class", scopeSubcomponent) - .build() + .build(), ) .addFunction( FunSpec @@ -294,9 +294,9 @@ open class CreateBenchmarkProjectTask : DefaultTask() { .addParameter("injectedInterfaceImpl", injectedInterfaceImpl) .addStatement("return injectedInterfaceImpl") .returns(injectedInterface) - .build() + .build(), ) - .build() + .build(), ) .build() .let { fileSpec -> @@ -309,7 +309,7 @@ open class CreateBenchmarkProjectTask : DefaultTask() { private fun createAppModule( module: AppModule, - allLibraryModules: Map + allLibraryModules: Map, ) { val moduleDir = File(rootDir, module.name) createAppBuildGradleFile(allLibraryModules, moduleDir) @@ -318,7 +318,7 @@ open class CreateBenchmarkProjectTask : DefaultTask() { private fun createAppBuildGradleFile( allLibraryModules: Map, - moduleDir: File + moduleDir: File, ) { val libDependencies = allLibraryModules.keys.sorted() .let { it.subList(it.size - 10, it.size) } @@ -356,7 +356,7 @@ open class CreateBenchmarkProjectTask : DefaultTask() { private fun createAppModuleSourceFiles( allLibraryModules: Map, - moduleDir: File + moduleDir: File, ) { val packageName = "com.squareup.anvil.benchmark.app" @@ -377,9 +377,9 @@ open class CreateBenchmarkProjectTask : DefaultTask() { AnnotationSpec .builder(mergeComponent) .addMember("scope = %T::class", scopeComponent) - .build() + .build(), ) - .build() + .build(), ) } } @@ -400,9 +400,9 @@ open class CreateBenchmarkProjectTask : DefaultTask() { } addMember("replaces = [$template]", *replacedModules.toTypedArray()) } - .build() + .build(), ) - .build() + .build(), ) .build() .let { fileSpec -> diff --git a/compiler-api/src/main/java/com/squareup/anvil/compiler/api/AnvilCompilationException.kt b/compiler-api/src/main/java/com/squareup/anvil/compiler/api/AnvilCompilationException.kt index 1b35ce5f0..94eaa82ac 100644 --- a/compiler-api/src/main/java/com/squareup/anvil/compiler/api/AnvilCompilationException.kt +++ b/compiler-api/src/main/java/com/squareup/anvil/compiler/api/AnvilCompilationException.kt @@ -25,83 +25,83 @@ import org.jetbrains.kotlin.util.getExceptionMessage public class AnvilCompilationException( message: String, cause: Throwable? = null, - element: PsiElement? = null + element: PsiElement? = null, ) : CompilationException(message, cause, element) { public companion object { public operator fun invoke( annotationDescriptor: AnnotationDescriptor, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException { return AnvilCompilationException( message = message, cause = cause, - element = annotationDescriptor.identifier + element = annotationDescriptor.identifier, ) } public operator fun invoke( functionDescriptor: FunctionDescriptor, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException { return AnvilCompilationException( message = message, cause = cause, - element = functionDescriptor.identifier + element = functionDescriptor.identifier, ) } public operator fun invoke( parameterDescriptor: ValueParameterDescriptor, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException { return AnvilCompilationException( message = message, cause = cause, - element = parameterDescriptor.identifier + element = parameterDescriptor.identifier, ) } public operator fun invoke( propertyDescriptor: PropertyDescriptor, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException { return AnvilCompilationException( message = message, cause = cause, - element = propertyDescriptor.identifier + element = propertyDescriptor.identifier, ) } public operator fun invoke( classDescriptor: ClassDescriptor, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException { return AnvilCompilationException( message = message, cause = cause, - element = classDescriptor.identifier + element = classDescriptor.identifier, ) } public operator fun invoke( element: IrElement? = null, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException { return AnvilCompilationException( message = getExceptionMessage( subsystemName = "Anvil", message = message, cause = cause, - location = element?.render() + location = element?.render(), ), cause = cause, - element = element?.psi + element = element?.psi, ).apply { if (element != null) { withAttachment("element.kt", element.render()) @@ -117,7 +117,7 @@ public class AnvilCompilationException( return AnvilCompilationException( message = message, cause = cause, - element = element?.owner + element = element?.owner, ) } } diff --git a/compiler-api/src/main/java/com/squareup/anvil/compiler/api/CodeGenerator.kt b/compiler-api/src/main/java/com/squareup/anvil/compiler/api/CodeGenerator.kt index 91df51986..c6a639145 100644 --- a/compiler-api/src/main/java/com/squareup/anvil/compiler/api/CodeGenerator.kt +++ b/compiler-api/src/main/java/com/squareup/anvil/compiler/api/CodeGenerator.kt @@ -37,7 +37,7 @@ public interface CodeGenerator : AnvilApplicabilityChecker { public fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection } @@ -51,7 +51,7 @@ public fun CodeGenerator.createGeneratedFile( codeGenDir: File, packageName: String, fileName: String, - content: String + content: String, ): GeneratedFile { val directory = File(codeGenDir, packageName.replace('.', File.separatorChar)) val file = File(directory, "$fileName.kt") diff --git a/compiler-api/src/main/java/com/squareup/anvil/compiler/api/GeneratedFile.kt b/compiler-api/src/main/java/com/squareup/anvil/compiler/api/GeneratedFile.kt index ed1f31524..eadcf9b9f 100644 --- a/compiler-api/src/main/java/com/squareup/anvil/compiler/api/GeneratedFile.kt +++ b/compiler-api/src/main/java/com/squareup/anvil/compiler/api/GeneratedFile.kt @@ -10,5 +10,5 @@ import java.io.File */ public data class GeneratedFile( val file: File, - val content: String + val content: String, ) diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/DescriptorUtils.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/DescriptorUtils.kt index b13403c34..eb132bb4b 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/DescriptorUtils.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/DescriptorUtils.kt @@ -30,7 +30,7 @@ public fun KotlinType.classDescriptorOrNull(): ClassDescriptor? { public fun KotlinType.classDescriptor(): ClassDescriptor { return classDescriptorOrNull() ?: throw AnvilCompilationException( - "Unable to resolve type for $this." + "Unable to resolve type for $this.", ) } @@ -52,12 +52,12 @@ public fun ConstantValue<*>.argumentType(module: ModuleDescriptor): KotlinType { classId = ClassId( classId.packageFqName, FqName(classId.relativeClassName.asString().replace('$', '.')), - false - ) + false, + ), ) ?.defaultType ?: throw AnvilCompilationException( - "Couldn't resolve class across module dependencies for class ID: $classId" + "Couldn't resolve class across module dependencies for class ID: $classId", ) } diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/FqName.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/FqName.kt index 99a488223..47722d43a 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/FqName.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/FqName.kt @@ -48,14 +48,14 @@ public fun FqName.descendant(segments: String): FqName = public val KClass<*>.fqName: FqName get() = FqName( requireNotNull(qualifiedName) { "An FqName cannot be created for a local class or class of an anonymous object." - } + }, ) /** @see String.safePackageString */ @ExperimentalAnvilApi public fun FqName.safePackageString( dotPrefix: Boolean = false, - dotSuffix: Boolean = true + dotSuffix: Boolean = true, ): String = toString().safePackageString(isRoot, dotPrefix, dotSuffix) /** @@ -68,7 +68,7 @@ public fun FqName.safePackageString( public fun String.safePackageString( isRoot: Boolean = isEmpty(), dotPrefix: Boolean = false, - dotSuffix: Boolean = true + dotSuffix: Boolean = true, ): String = if (isRoot) { "" diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/KotlinPoetUtils.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/KotlinPoetUtils.kt index d51e19794..2740fd7f2 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/KotlinPoetUtils.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/KotlinPoetUtils.kt @@ -28,7 +28,7 @@ public fun ClassDescriptor.asClassName(): ClassName = simpleNames = parentsWithSelf.filterIsInstance() .map { it.name.asString() } .toList() - .reversed() + .reversed(), ) @ExperimentalAnvilApi @@ -55,7 +55,7 @@ private fun FqName.asClassNameOrNull(module: ModuleDescriptor): ClassName? { // If we found a valid name, it means the package is one segment back from the current index return ClassName( packageName = segments.subList(0, index - 1).joinToString(separator = "."), - simpleNames = segments.subList(index - 1, segments.size) + simpleNames = segments.subList(index - 1, segments.size), ) } } @@ -68,14 +68,14 @@ private fun FqName.asClassNameOrNull(module: ModuleDescriptor): ClassName? { public fun ClassId.asClassName(): ClassName { return ClassName( packageName = packageFqName.asString(), - simpleNames = relativeClassName.pathSegments().map { it.asString() } + simpleNames = relativeClassName.pathSegments().map { it.asString() }, ) } @ExperimentalAnvilApi public fun TypeName.withJvmSuppressWildcardsIfNeeded( annotatedReference: AnnotatedReference, - typeReference: TypeReference + typeReference: TypeReference, ): TypeName { // If the parameter is annotated with @JvmSuppressWildcards, then add the annotation // to our type so that this information is forwarded when our Factory is compiled. @@ -111,7 +111,7 @@ private fun FileSpec.Builder.suppressWarnings() { addMember("\"EXPERIMENTAL_API_USAGE\"") } } - .build() + .build(), ) } @@ -120,7 +120,7 @@ public fun FileSpec.Companion.buildFile( packageName: String, fileName: String, generatorComment: String = "Generated by Anvil.\nhttps://github.com/square/anvil", - block: FileSpec.Builder.() -> Unit + block: FileSpec.Builder.() -> Unit, ): String = createAnvilSpec(packageName, fileName, generatorComment, block) .toString() @@ -129,7 +129,7 @@ public fun FileSpec.Companion.createAnvilSpec( packageName: String, fileName: String, generatorComment: String = "Generated by Anvil.\nhttps://github.com/square/anvil", - block: FileSpec.Builder.() -> Unit + block: FileSpec.Builder.() -> Unit, ): FileSpec = builder(packageName, fileName) .apply { diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/PsiUtils.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/PsiUtils.kt index af01dd6f0..3a94b0051 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/PsiUtils.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/PsiUtils.kt @@ -53,7 +53,7 @@ public fun PsiElement.ktFile(): KtFile { @ExperimentalAnvilApi public fun PsiElement.fqNameOrNull( - module: ModuleDescriptor + module: ModuleDescriptor, ): FqName? { // Usually it's the opposite way, the require*() method calls the nullable method. But in this // case we'd like to preserve the better error messages in case something goes wrong. @@ -66,13 +66,13 @@ public fun PsiElement.fqNameOrNull( @ExperimentalAnvilApi public fun PsiElement.requireFqName( - module: ModuleDescriptor + module: ModuleDescriptor, ): FqName { val containingKtFile = ktFile() fun failTypeHandling(): Nothing = throw AnvilCompilationException( "Don't know how to handle Psi element: $text", - element = this + element = this, ) val classReference = when (this) { @@ -147,7 +147,7 @@ public fun PsiElement.requireFqName( // Returns "Abc" for "Abc::class". val element = children.singleOrNull() ?: throw AnvilCompilationException( "Expected a single child, but there were ${children.size} instead: $text", - element = this + element = this, ) return element.requireFqName(module) } @@ -160,7 +160,7 @@ public fun PsiElement.requireFqName( if (parameterCount !in 0..22) { throw AnvilCompilationException( element = this, - message = "Couldn't find function type for $parameterCount parameters." + message = "Couldn't find function type for $parameterCount parameters.", ) } return FqName("kotlin.jvm.functions.Function$parameterCount") @@ -293,7 +293,7 @@ public fun PsiElement.requireFqName( // Everything else isn't supported. throw AnvilCompilationException( "Couldn't resolve FqName $classReference for Psi element: $text", - element = this + element = this, ) } @@ -325,7 +325,7 @@ private fun PsiElement.findClassReferenceInSuperTypes( // It might be a generic type, e.g. ClassA. Remove the generic type. )?.substringBefore('<') ?: throw AnvilCompilationException( - "Couldn't get the super type for ${superType.text}." + "Couldn't get the super type for ${superType.text}.", ) // Find the FqName for our super type. We check below if it's actually correct. diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnnotationArgumentReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnnotationArgumentReference.kt index 310579e4e..b6c9eb61f 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnnotationArgumentReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnnotationArgumentReference.kt @@ -122,7 +122,7 @@ public sealed class AnnotationArgumentReference { public val argument: KtValueArgument, override val annotation: AnnotationReference.Psi, override val name: String?, - override val resolvedName: String + override val resolvedName: String, ) : AnnotationArgumentReference() { protected override val value: Any by lazy(NONE) { fun fail(): Nothing { @@ -314,7 +314,7 @@ public sealed class AnnotationArgumentReference { public val argument: ConstantValue<*>, override val annotation: AnnotationReference.Descriptor, override val name: String, - override val resolvedName: String = name + override val resolvedName: String = name, ) : AnnotationArgumentReference() { protected override val value: Any by lazy(NONE) { @@ -352,7 +352,7 @@ public sealed class AnnotationArgumentReference { @ExperimentalAnvilApi public fun KtValueArgument.toAnnotationArgumentReference( annotationReference: AnnotationReference.Psi, - indexOfArgument: Int + indexOfArgument: Int, ): Psi { val children = children val name = (children.firstOrNull() as? KtValueArgumentName)?.asName?.asString() @@ -368,17 +368,17 @@ public fun KtValueArgument.toAnnotationArgumentReference( argument = this, annotation = annotationReference, name = name, - resolvedName = resolvedName + resolvedName = resolvedName, ) } @ExperimentalAnvilApi public fun Pair>.toAnnotationArgumentReference( - annotationReference: AnnotationReference.Descriptor + annotationReference: AnnotationReference.Descriptor, ): Descriptor { return Descriptor( argument = second, annotation = annotationReference, - name = first.asString() + name = first.asString(), ) } diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnnotationReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnnotationReference.kt index 06c0b6e59..5fbd583c4 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnnotationReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnnotationReference.kt @@ -57,7 +57,7 @@ public sealed class AnnotationReference { public open fun declaringClass(): ClassReference = declaringClass ?: throw AnvilCompilationExceptionAnnotationReference( annotationReference = this, - message = "The declaring class was null, this means the annotation wasn't used on a class." + message = "The declaring class was null, this means the annotation wasn't used on a class.", ) public abstract fun scopeOrNull(parameterIndex: Int = DEFAULT_SCOPE_INDEX): ClassReference? @@ -65,7 +65,7 @@ public sealed class AnnotationReference { scopeOrNull(parameterIndex) ?: throw AnvilCompilationExceptionAnnotationReference( annotationReference = this, - message = "Couldn't find scope for $fqName." + message = "Couldn't find scope for $fqName.", ) public fun boundTypeOrNull(): ClassReference? = argumentAt("boundType", 1)?.value() @@ -88,7 +88,7 @@ public sealed class AnnotationReference { when (val value = argument.value()) { is ClassReference -> addMember( "${argument.resolvedName} = %T::class", - value.asClassName() + value.asClassName(), ) is FqName -> { val clazz = value.toClassReferenceOrNull(module) @@ -96,7 +96,7 @@ public sealed class AnnotationReference { // That's an enum value! val enumMember = MemberName( enclosingClassName = clazz.enclosingClass()!!.asClassName(), - simpleName = clazz.shortName + simpleName = clazz.shortName, ) addMember("${argument.resolvedName} = %M", enumMember) } else { @@ -105,25 +105,25 @@ public sealed class AnnotationReference { } is String -> addMember("${argument.resolvedName} = \"$value\"") is BooleanArray -> addMember( - "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}" + "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}", ) is IntArray -> addMember( - "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}" + "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}", ) is LongArray -> addMember( - "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}" + "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}", ) is DoubleArray -> addMember( - "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}" + "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}", ) is ByteArray -> addMember( - "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}" + "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}", ) is ShortArray -> addMember( - "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}" + "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}", ) is FloatArray -> addMember( - "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}" + "${argument.resolvedName} = ${value.joinToString(prefix = "[", postfix = "]")}", ) is List<*> -> { when { @@ -134,7 +134,7 @@ public sealed class AnnotationReference { addMember( "${argument.resolvedName} = [$template]", - *classes.map { it.asClassName() }.toTypedArray() + *classes.map { it.asClassName() }.toTypedArray(), ) } value[0] is FqName -> { @@ -220,19 +220,19 @@ public sealed class AnnotationReference { @ExperimentalAnvilApi public fun KtAnnotationEntry.toAnnotationReference( declaringClass: ClassReference.Psi?, - module: ModuleDescriptor + module: ModuleDescriptor, ): Psi { return Psi( annotation = this, classReference = requireFqName(module).toClassReference(module), - declaringClass = declaringClass + declaringClass = declaringClass, ) } @ExperimentalAnvilApi public fun AnnotationDescriptor.toAnnotationReference( declaringClass: ClassReference.Descriptor?, - module: ModuleDescriptor + module: ModuleDescriptor, ): Descriptor { val annotationClass = annotationClass ?: throw AnvilCompilationException( message = "Couldn't find the annotation class for $fqName", @@ -241,14 +241,14 @@ public fun AnnotationDescriptor.toAnnotationReference( return Descriptor( annotation = this, classReference = annotationClass.toClassReference(module), - declaringClass = declaringClass + declaringClass = declaringClass, ) } @ExperimentalAnvilApi public fun AnnotationReference.argumentAt( name: String, - index: Int + index: Int, ): AnnotationArgumentReference? { return arguments.singleOrNull { it.name == name } ?: arguments.elementAtOrNull(index)?.takeIf { it.name == null } @@ -259,17 +259,17 @@ public fun AnnotationReference.argumentAt( public fun AnvilCompilationExceptionAnnotationReference( annotationReference: AnnotationReference, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException = when (annotationReference) { is Psi -> AnvilCompilationException( element = annotationReference.annotation, message = message, - cause = cause + cause = cause, ) is Descriptor -> AnvilCompilationException( annotationDescriptor = annotationReference.annotation, message = message, - cause = cause + cause = cause, ) } @@ -279,7 +279,7 @@ private fun replacesIndex(annotationFqName: FqName): Int { contributesBindingFqName, contributesMultibindingFqName -> 2 contributesSubcomponentFqName -> 4 else -> throw NotImplementedError( - "Couldn't find index of replaces argument for $annotationFqName." + "Couldn't find index of replaces argument for $annotationFqName.", ) } } @@ -290,7 +290,7 @@ private fun excludeIndex(annotationFqName: FqName): Int { mergeSubcomponentFqName -> 2 mergeComponentFqName, mergeModulesFqName, contributesSubcomponentFqName -> 3 else -> throw NotImplementedError( - "Couldn't find index of exclude argument for $annotationFqName." + "Couldn't find index of exclude argument for $annotationFqName.", ) } } diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnvilModuleDescriptor.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnvilModuleDescriptor.kt index c44cc9762..68e4d3f69 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnvilModuleDescriptor.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/AnvilModuleDescriptor.kt @@ -20,11 +20,11 @@ public interface AnvilModuleDescriptor : ModuleDescriptor { public fun resolveFqNameOrNull( fqName: FqName, - lookupLocation: LookupLocation = FROM_BACKEND + lookupLocation: LookupLocation = FROM_BACKEND, ): ClassDescriptor? public fun resolveTypeAliasFqNameOrNull( - fqName: FqName + fqName: FqName, ): TypeAliasDescriptor? public fun getClassAndInnerClassReferences(ktFile: KtFile): List @@ -51,12 +51,12 @@ internal inline fun ModuleDescriptor.asAnvilModuleDescriptor(): AnvilModuleDescr @ExperimentalAnvilApi public fun FqName.canResolveFqName( - module: ModuleDescriptor + module: ModuleDescriptor, ): Boolean = module.asAnvilModuleDescriptor().resolveClassIdOrNull(classIdBestGuess()) != null @ExperimentalAnvilApi public fun Collection.classAndInnerClassReferences( - module: ModuleDescriptor + module: ModuleDescriptor, ): Sequence { return asSequence().flatMap { module.asAnvilModuleDescriptor().getClassAndInnerClassReferences(it) @@ -65,7 +65,7 @@ public fun Collection.classAndInnerClassReferences( @ExperimentalAnvilApi public fun Collection.topLevelFunctionReferences( - module: ModuleDescriptor + module: ModuleDescriptor, ): Sequence { return asSequence().flatMap { module.asAnvilModuleDescriptor().getTopLevelFunctionReferences(it) @@ -74,7 +74,7 @@ public fun Collection.topLevelFunctionReferences( @ExperimentalAnvilApi public fun Collection.topLevelPropertyReferences( - module: ModuleDescriptor + module: ModuleDescriptor, ): Sequence { return asSequence().flatMap { module.asAnvilModuleDescriptor().getTopLevelPropertyReferences(it) diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/ClassReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/ClassReference.kt index b0473cab3..5f6867bec 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/ClassReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/ClassReference.kt @@ -127,7 +127,7 @@ public sealed class ClassReference : Comparable, AnnotatedRefere public class Psi( public val clazz: KtClassOrObject, override val classId: ClassId, - override val module: AnvilModuleDescriptor + override val module: AnvilModuleDescriptor, ) : ClassReference() { override val fqName: FqName = classId.asSingleFqName() @@ -211,7 +211,7 @@ public sealed class ClassReference : Comparable, AnnotatedRefere PRIVATE_KEYWORD -> PRIVATE else -> throw AnvilCompilationExceptionClassReference( classReference = this, - message = "Couldn't get visibility $visibility for class $fqName." + message = "Couldn't get visibility $visibility for class $fqName.", ) } } @@ -235,7 +235,7 @@ public sealed class ClassReference : Comparable, AnnotatedRefere public class Descriptor( public val clazz: ClassDescriptor, override val classId: ClassId, - override val module: AnvilModuleDescriptor + override val module: AnvilModuleDescriptor, ) : ClassReference() { override val fqName: FqName = classId.asSingleFqName() @@ -314,7 +314,7 @@ public sealed class ClassReference : Comparable, AnnotatedRefere DescriptorVisibilities.PRIVATE -> PRIVATE else -> throw AnvilCompilationExceptionClassReference( classReference = this, - message = "Couldn't get visibility $visibility for class $fqName." + message = "Couldn't get visibility $visibility for class $fqName.", ) } } @@ -362,7 +362,7 @@ public fun FqName.toClassReference(module: ModuleDescriptor): ClassReference { @ExperimentalAnvilApi public fun ClassReference.generateClassName( separator: String = "_", - suffix: String = "" + suffix: String = "", ): ClassId { return asClassName().generateClassName(separator, suffix).asClassId() } @@ -370,7 +370,7 @@ public fun ClassReference.generateClassName( @ExperimentalAnvilApi public fun ClassName.generateClassName( separator: String = "_", - suffix: String = "" + suffix: String = "", ): ClassName { val className = simpleNames.joinToString(separator = separator) return ClassName(packageName, className + suffix) @@ -380,7 +380,7 @@ public fun ClassName.generateClassName( public fun ClassName.asClassId(local: Boolean = false): ClassId = ClassId( FqName(packageName), FqName(simpleNames.joinToString(".")), - local + local, ) @ExperimentalAnvilApi @@ -407,7 +407,7 @@ public fun ClassReference.asTypeName(): TypeName { */ @ExperimentalAnvilApi public fun ClassReference.allSuperTypeClassReferences( - includeSelf: Boolean = false + includeSelf: Boolean = false, ): Sequence { return generateSequence(listOf(this)) { superTypes -> superTypes @@ -426,16 +426,16 @@ public fun ClassReference.allSuperTypeClassReferences( public fun AnvilCompilationExceptionClassReference( classReference: ClassReference, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException = when (classReference) { is Psi -> AnvilCompilationException( element = classReference.clazz.identifyingElement ?: classReference.clazz, message = message, - cause = cause + cause = cause, ) is Descriptor -> AnvilCompilationException( classDescriptor = classReference.clazz, message = message, - cause = cause + cause = cause, ) } diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/FunctionReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/FunctionReference.kt index 4efdec397..c7d99458a 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/FunctionReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/FunctionReference.kt @@ -21,7 +21,7 @@ public sealed interface FunctionReference { public fun returnType(): TypeReference = returnTypeOrNull() ?: throw AnvilCompilationExceptionFunctionReference( functionReference = this, - message = "Unable to get the return type for function $fqName." + message = "Unable to get the return type for function $fqName.", ) public fun visibility(): Visibility @@ -40,16 +40,16 @@ public sealed interface FunctionReference { public fun AnvilCompilationExceptionFunctionReference( functionReference: FunctionReference, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException = when (functionReference) { is Psi -> AnvilCompilationException( element = functionReference.function, message = message, - cause = cause + cause = cause, ) is Descriptor -> AnvilCompilationException( functionDescriptor = functionReference.function, message = message, - cause = cause + cause = cause, ) } diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/MemberFunctionReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/MemberFunctionReference.kt index 60bfab76c..fddd609de 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/MemberFunctionReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/MemberFunctionReference.kt @@ -42,7 +42,7 @@ public sealed class MemberFunctionReference : AnnotatedReference, FunctionRefere public abstract fun isAbstract(): Boolean public abstract fun isConstructor(): Boolean public fun resolveGenericReturnTypeOrNull( - implementingClass: ClassReference + implementingClass: ClassReference, ): ClassReference? { return returnType ?.resolveGenericTypeOrNull(implementingClass) @@ -54,7 +54,7 @@ public sealed class MemberFunctionReference : AnnotatedReference, FunctionRefere ?: throw AnvilCompilationExceptionFunctionReference( functionReference = this, message = "Unable to resolve return type for function $fqName with the implementing " + - "class ${implementingClass.fqName}." + "class ${implementingClass.fqName}.", ) override fun toString(): String = "$fqName()" @@ -75,7 +75,7 @@ public sealed class MemberFunctionReference : AnnotatedReference, FunctionRefere public class Psi internal constructor( public override val function: KtFunction, override val declaringClass: ClassReference.Psi, - override val fqName: FqName + override val fqName: FqName, ) : MemberFunctionReference(), FunctionReference.Psi { override val annotations: List by lazy(NONE) { @@ -106,7 +106,7 @@ public sealed class MemberFunctionReference : AnnotatedReference, FunctionRefere KtTokens.PRIVATE_KEYWORD -> PRIVATE else -> throw AnvilCompilationExceptionClassReference( classReference = declaringClass, - message = "Couldn't get visibility $visibility for function $fqName." + message = "Couldn't get visibility $visibility for function $fqName.", ) } } @@ -115,7 +115,7 @@ public sealed class MemberFunctionReference : AnnotatedReference, FunctionRefere public class Descriptor internal constructor( public override val function: FunctionDescriptor, override val declaringClass: ClassReference.Descriptor, - override val fqName: FqName = function.fqNameSafe + override val fqName: FqName = function.fqNameSafe, ) : MemberFunctionReference(), FunctionReference.Descriptor { override val annotations: List by lazy(NONE) { @@ -144,7 +144,7 @@ public sealed class MemberFunctionReference : AnnotatedReference, FunctionRefere DescriptorVisibilities.PRIVATE -> PRIVATE else -> throw AnvilCompilationExceptionClassReference( classReference = declaringClass, - message = "Couldn't get visibility $visibility for function $fqName." + message = "Couldn't get visibility $visibility for function $fqName.", ) } } @@ -153,7 +153,7 @@ public sealed class MemberFunctionReference : AnnotatedReference, FunctionRefere @ExperimentalAnvilApi public fun KtFunction.toFunctionReference( - declaringClass: ClassReference.Psi + declaringClass: ClassReference.Psi, ): Psi { val fqName = if (this is KtConstructor<*>) { declaringClass.fqName.child(Name.identifier("")) diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/MemberPropertyReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/MemberPropertyReference.kt index d3b669a1a..21dc1a74e 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/MemberPropertyReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/MemberPropertyReference.kt @@ -62,7 +62,7 @@ public sealed class MemberPropertyReference : AnnotatedReference, PropertyRefere public override val property: KtCallableDeclaration, override val declaringClass: ClassReference.Psi, override val fqName: FqName, - override val name: String + override val name: String, ) : MemberPropertyReference(), PropertyReference.Psi { override val annotations: List by lazy(NONE) { @@ -102,7 +102,7 @@ public sealed class MemberPropertyReference : AnnotatedReference, PropertyRefere KtTokens.PRIVATE_KEYWORD -> PRIVATE else -> throw AnvilCompilationExceptionClassReference( classReference = declaringClass, - message = "Couldn't get visibility $visibility for property $fqName." + message = "Couldn't get visibility $visibility for property $fqName.", ) } } @@ -118,13 +118,13 @@ public sealed class MemberPropertyReference : AnnotatedReference, PropertyRefere property: T, declaringClass: ClassReference.Psi, fqName: FqName = property.requireFqName(), - name: String = fqName.shortName().asString() + name: String = fqName.shortName().asString(), ): Psi where T : KtCallableDeclaration, T : KtValVarKeywordOwner = Psi( property = property, declaringClass = declaringClass, fqName = fqName, - name = name + name = name, ) } } @@ -133,7 +133,7 @@ public sealed class MemberPropertyReference : AnnotatedReference, PropertyRefere public override val property: PropertyDescriptor, override val declaringClass: ClassReference.Descriptor, override val fqName: FqName = property.fqNameSafe, - override val name: String = fqName.shortName().asString() + override val name: String = fqName.shortName().asString(), ) : MemberPropertyReference(), PropertyReference.Descriptor { override val annotations: List by lazy(NONE) { @@ -170,7 +170,7 @@ public sealed class MemberPropertyReference : AnnotatedReference, PropertyRefere DescriptorVisibilities.PRIVATE -> PRIVATE else -> throw AnvilCompilationExceptionClassReference( classReference = declaringClass, - message = "Couldn't get visibility $visibility for property $fqName." + message = "Couldn't get visibility $visibility for property $fqName.", ) } } @@ -181,12 +181,12 @@ public sealed class MemberPropertyReference : AnnotatedReference, PropertyRefere @ExperimentalAnvilApi public fun KtParameter.toPropertyReference( - declaringClass: ClassReference.Psi + declaringClass: ClassReference.Psi, ): Psi { if (!isPropertyParameter()) { throw AnvilCompilationException( element = this, - message = "A KtParameter may only be turned into a PropertyReference if it's a val or var." + message = "A KtParameter may only be turned into a PropertyReference if it's a val or var.", ) } return Psi(this, declaringClass) @@ -194,10 +194,10 @@ public fun KtParameter.toPropertyReference( @ExperimentalAnvilApi public fun KtProperty.toPropertyReference( - declaringClass: ClassReference.Psi + declaringClass: ClassReference.Psi, ): Psi = Psi(this, declaringClass) @ExperimentalAnvilApi public fun PropertyDescriptor.toPropertyReference( - declaringClass: ClassReference.Descriptor + declaringClass: ClassReference.Descriptor, ): Descriptor = Descriptor(this, declaringClass) diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/ParameterReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/ParameterReference.kt index d7af0438f..a8d9d6dcd 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/ParameterReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/ParameterReference.kt @@ -29,11 +29,11 @@ public sealed class ParameterReference : AnnotatedReference { ?: throw AnvilCompilationExceptionParameterReference( parameterReference = this, message = "Unable to get type for the parameter with name $name of " + - "function ${declaringFunction.fqName}" + "function ${declaringFunction.fqName}", ) public fun resolveTypeNameOrNull( - implementingClass: ClassReference + implementingClass: ClassReference, ): TypeName? { return type?.resolveGenericTypeNameOrNull(implementingClass) } @@ -43,7 +43,7 @@ public sealed class ParameterReference : AnnotatedReference { ?: throw AnvilCompilationExceptionParameterReference( message = "Unable to resolve type name for parameter with name $name with the " + "implementing class ${implementingClass.fqName}.", - parameterReference = this + parameterReference = this, ) override fun toString(): String { @@ -68,7 +68,7 @@ public sealed class ParameterReference : AnnotatedReference { public class Psi( public val parameter: KtParameter, - override val declaringFunction: FunctionReference.Psi + override val declaringFunction: FunctionReference.Psi, ) : ParameterReference() { override val name: String = parameter.nameAsSafeName.asString() @@ -91,7 +91,7 @@ public sealed class ParameterReference : AnnotatedReference { public class Descriptor( public val parameter: ValueParameterDescriptor, - override val declaringFunction: FunctionReference.Descriptor + override val declaringFunction: FunctionReference.Descriptor, ) : ParameterReference() { override val name: String = parameter.name.asString() @@ -115,14 +115,14 @@ public sealed class ParameterReference : AnnotatedReference { @ExperimentalAnvilApi public fun KtParameter.toParameterReference( - declaringFunction: FunctionReference.Psi + declaringFunction: FunctionReference.Psi, ): Psi { return Psi(this, declaringFunction) } @ExperimentalAnvilApi public fun ValueParameterDescriptor.toParameterReference( - declaringFunction: FunctionReference.Descriptor + declaringFunction: FunctionReference.Descriptor, ): Descriptor { return Descriptor(this, declaringFunction) } @@ -132,16 +132,16 @@ public fun ValueParameterDescriptor.toParameterReference( public fun AnvilCompilationExceptionParameterReference( parameterReference: ParameterReference, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException = when (parameterReference) { is Psi -> AnvilCompilationException( element = parameterReference.parameter, message = message, - cause = cause + cause = cause, ) is Descriptor -> AnvilCompilationException( parameterDescriptor = parameterReference.parameter, message = message, - cause = cause + cause = cause, ) } diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/PropertyReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/PropertyReference.kt index 3a4ce7037..03c7db5ea 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/PropertyReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/PropertyReference.kt @@ -26,7 +26,7 @@ public sealed interface PropertyReference { public fun type(): TypeReference = typeOrNull() ?: throw AnvilCompilationExceptionPropertyReference( propertyReference = this, - message = "Unable to get type for property $fqName." + message = "Unable to get type for property $fqName.", ) public sealed interface Psi : PropertyReference { @@ -43,16 +43,16 @@ public sealed interface PropertyReference { public fun AnvilCompilationExceptionPropertyReference( propertyReference: PropertyReference, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException = when (propertyReference) { is Psi -> AnvilCompilationException( element = propertyReference.property, message = message, - cause = cause + cause = cause, ) is Descriptor -> AnvilCompilationException( propertyDescriptor = propertyReference.property, message = message, - cause = cause + cause = cause, ) } diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TopLevelFunctionReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TopLevelFunctionReference.kt index d21c9bb5e..80d680e10 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TopLevelFunctionReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TopLevelFunctionReference.kt @@ -67,7 +67,7 @@ public sealed class TopLevelFunctionReference : AnnotatedReference, FunctionRefe KtTokens.PRIVATE_KEYWORD -> PRIVATE else -> throw AnvilCompilationExceptionFunctionReference( functionReference = this, - message = "Couldn't get visibility $visibility for function $fqName." + message = "Couldn't get visibility $visibility for function $fqName.", ) } } @@ -101,7 +101,7 @@ public sealed class TopLevelFunctionReference : AnnotatedReference, FunctionRefe DescriptorVisibilities.PRIVATE -> PRIVATE else -> throw AnvilCompilationExceptionFunctionReference( functionReference = this, - message = "Couldn't get visibility $visibility for function $fqName." + message = "Couldn't get visibility $visibility for function $fqName.", ) } } diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TopLevelPropertyReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TopLevelPropertyReference.kt index d45011a20..eefd57c2a 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TopLevelPropertyReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TopLevelPropertyReference.kt @@ -95,7 +95,7 @@ public sealed class TopLevelPropertyReference : AnnotatedReference, PropertyRefe KtTokens.PRIVATE_KEYWORD -> PRIVATE else -> throw AnvilCompilationExceptionPropertyReference( propertyReference = this, - message = "Couldn't get visibility $visibility for property $fqName." + message = "Couldn't get visibility $visibility for property $fqName.", ) } } @@ -117,7 +117,7 @@ public sealed class TopLevelPropertyReference : AnnotatedReference, PropertyRefe property = property, fqName = fqName, name = name, - module = module + module = module, ) } } @@ -163,7 +163,7 @@ public sealed class TopLevelPropertyReference : AnnotatedReference, PropertyRefe DescriptorVisibilities.PRIVATE -> PRIVATE else -> throw AnvilCompilationExceptionPropertyReference( propertyReference = this, - message = "Couldn't get visibility $visibility for property $fqName." + message = "Couldn't get visibility $visibility for property $fqName.", ) } } @@ -179,7 +179,7 @@ public fun KtParameter.toTopLevelPropertyReference( if (!isPropertyParameter()) { throw AnvilCompilationException( element = this, - message = "A KtParameter may only be turned into a PropertyReference if it's a val or var." + message = "A KtParameter may only be turned into a PropertyReference if it's a val or var.", ) } return Psi(property = this, module = module) diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TypeParameterReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TypeParameterReference.kt index 9f872d00a..73959bc6e 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TypeParameterReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TypeParameterReference.kt @@ -22,13 +22,13 @@ public sealed class TypeParameterReference { public class Psi internal constructor( override val name: String, override val upperBounds: List, - override val declaringClass: ClassReference.Psi + override val declaringClass: ClassReference.Psi, ) : TypeParameterReference() public class Descriptor internal constructor( override val name: String, override val upperBounds: List, - override val declaringClass: ClassReference.Descriptor + override val declaringClass: ClassReference.Descriptor, ) : TypeParameterReference() override fun toString(): String { @@ -74,11 +74,11 @@ public fun ClassReference.Psi.getTypeParameterReferences(): List { @ExperimentalAnvilApi public fun TypeParameterDescriptor.toTypeParameterReference( - declaringClass: ClassReference.Descriptor + declaringClass: ClassReference.Descriptor, ): Descriptor { return Descriptor( name = name.asString(), upperBounds = upperBounds.map { it.toTypeReference(declaringClass, declaringClass.module) }, - declaringClass = declaringClass + declaringClass = declaringClass, ) } diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TypeReference.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TypeReference.kt index f7a76511a..965fe91ae 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TypeReference.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/TypeReference.kt @@ -74,18 +74,18 @@ public sealed class TypeReference { public fun asClassReference(): ClassReference = classReference ?: throw AnvilCompilationExceptionTypReference( typeReference = this, - message = "Unable to convert a type reference to a class reference." + message = "Unable to convert a type reference to a class reference.", ) public fun asTypeNameOrNull(): TypeName? = typeNameOrNull public fun asTypeName(): TypeName = typeName public abstract fun resolveGenericTypeOrNull( - implementingClass: ClassReference + implementingClass: ClassReference, ): TypeReference? public fun resolveGenericTypeNameOrNull( - implementingClass: ClassReference + implementingClass: ClassReference, ): TypeName? { asClassReferenceOrNull()?.let { // Then it's a normal type and not a generic type. @@ -188,7 +188,7 @@ public sealed class TypeReference { * example, this would be `ServiceFactory`. */ internal fun resolveTypeReference( - implementingClass: ClassReference + implementingClass: ClassReference, ): TypeReference { // If the element isn't a type variable name like `T`, it can be resolved through imports. type.typeElement?.fqNameOrNull(module) @@ -200,7 +200,7 @@ public sealed class TypeReference { // When we fail to resolve the generic type here, we're potentially at the end of a chain of // generics, so we return the current type instead of null. return resolveGenericTypeReference( - implementingClass, declaringClass, type.text, module + implementingClass, declaringClass, type.text, module, ) ?: this } @@ -211,7 +211,7 @@ public sealed class TypeReference { private fun KtTypeReference.requireTypeName(): TypeName { fun PsiElement.fail(): Nothing = throw AnvilCompilationException( message = "Couldn't resolve type: $text", - element = this + element = this, ) fun KtUserType.isTypeParameter(): Boolean { @@ -241,7 +241,7 @@ public sealed class TypeReference { throw AnvilCompilationException( message = "Couldn't resolve fqName.", element = this, - cause = e + cause = e, ) } } @@ -266,10 +266,10 @@ public sealed class TypeReference { .builder( annotationEntry .requireFqName(module) - .asClassName(module) + .asClassName(module), ) .build() - } + }, ) } else { typeName @@ -287,7 +287,7 @@ public sealed class TypeReference { } } } - } + }, ) } else { className @@ -304,9 +304,9 @@ public sealed class TypeReference { } ?: emptyList(), returnType = (returnTypeReference ?: fail()) - .requireTypeName() + .requireTypeName(), ).copy( - suspending = type.modifierList?.hasSuspendModifier() ?: false + suspending = type.modifierList?.hasSuspendModifier() ?: false, ) is KtNullableType -> { (innerType ?: fail()).requireTypeName().copy(nullable = true) @@ -319,7 +319,7 @@ public sealed class TypeReference { } private fun findUnwrappedTypesWithTypeAlias( - unwrappedTypes: List + unwrappedTypes: List, ): List { // For Psi we must inspect the type and check if further arguments have been specified in // a type alias, e.g. @@ -372,7 +372,7 @@ public sealed class TypeReference { get() = typeNameOrNull ?: throw AnvilCompilationExceptionTypReference( typeReference = this, message = "Unable to convert the Kotlin type $type to a type name for declaring class " + - "${declaringClass?.fqName}." + "${declaringClass?.fqName}.", ) override val unwrappedTypes: List by lazy(NONE) { @@ -402,7 +402,7 @@ public sealed class TypeReference { * this would be `SomeFactory`. */ internal fun resolveGenericKotlinTypeOrNull( - implementingClass: ClassReference + implementingClass: ClassReference, ): TypeReference? { type.classDescriptorOrNull()?.fqNameOrNull() ?.let { return this } @@ -435,7 +435,7 @@ public sealed class TypeReference { implementingClass = implementingClass, declaringClass = declaringClass, parameterName = parameterKotlinType.toString(), - module = module + module = module, ) } @@ -470,7 +470,7 @@ public sealed class TypeReference { @ExperimentalAnvilApi public fun KtTypeReference.toTypeReference( declaringClass: ClassReference.Psi?, - module: AnvilModuleDescriptor + module: AnvilModuleDescriptor, ): Psi { return Psi(this, declaringClass, module) } @@ -478,7 +478,7 @@ public fun KtTypeReference.toTypeReference( @ExperimentalAnvilApi public fun KotlinType.toTypeReference( declaringClass: ClassReference?, - module: AnvilModuleDescriptor + module: AnvilModuleDescriptor, ): Descriptor { return Descriptor(this, declaringClass, module) } @@ -488,18 +488,18 @@ public fun KotlinType.toTypeReference( public fun AnvilCompilationExceptionTypReference( typeReference: TypeReference, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException = when (typeReference) { is Psi -> AnvilCompilationException( element = typeReference.type, message = message, - cause = cause + cause = cause, ) is Descriptor -> { AnvilCompilationException( classDescriptor = typeReference.type.classDescriptor(), message = message + " Hint: ${typeReference.type}", - cause = cause + cause = cause, ) } } @@ -551,7 +551,8 @@ private fun resolveGenericTypeReference( ?.containingClassReference(implementingClass) ?.let { resolvedDeclaringClass -> resolvedTypeReference.toTypeReference( - resolvedDeclaringClass, module + resolvedDeclaringClass, + module, ).resolveGenericKotlinTypeOrNull(implementingClass) } } @@ -579,7 +580,7 @@ private fun resolveGenericTypeReference( * resolve `T` to `Something`. */ private fun ClassReference.Psi.superTypeListEntryOrNull( - superTypeFqName: FqName + superTypeFqName: FqName, ): KtSuperTypeListEntry? { return allSuperTypeClassReferences(includeSelf = true) .filterIsInstance() @@ -591,7 +592,7 @@ private fun ClassReference.Psi.superTypeListEntryOrNull( } private fun ClassReference.Descriptor.superTypeOrNull( - superTypeFqName: FqName + superTypeFqName: FqName, ): KotlinType? { return allSuperTypeClassReferences(includeSelf = true) .filterIsInstance() @@ -619,7 +620,7 @@ private fun ClassReference.Descriptor.superTypeOrNull( * @param implementingClass: The lowest descendant implementing class, e.g. Child from */ private fun KotlinType.containingClassReference( - implementingClass: ClassReference + implementingClass: ClassReference, ): ClassReference.Descriptor? { val containingClassReference = implementingClass.allSuperTypeClassReferences(true) .toList() diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/Visibility.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/Visibility.kt index b4be80adc..7756cde0e 100644 --- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/Visibility.kt +++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/reference/Visibility.kt @@ -7,5 +7,5 @@ public enum class Visibility { PUBLIC, INTERNAL, PROTECTED, - PRIVATE + PRIVATE, } diff --git a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilation.kt b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilation.kt index bbe1f2a65..272515e83 100644 --- a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilation.kt +++ b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilation.kt @@ -29,7 +29,7 @@ import java.util.ServiceLoader */ @ExperimentalAnvilApi public class AnvilCompilation internal constructor( - val kotlinCompilation: KotlinCompilation + val kotlinCompilation: KotlinCompilation, ) { private var isCompiled = false @@ -70,13 +70,13 @@ public class AnvilCompilation internal constructor( PluginOption( pluginId = anvilCommandLineProcessor.pluginId, optionName = "disable-component-merging", - optionValue = disableComponentMerging.toString() + optionValue = disableComponentMerging.toString(), ), PluginOption( pluginId = anvilCommandLineProcessor.pluginId, optionName = "backend", - optionValue = mode.backend.name.lowercase(Locale.US) - ) + optionValue = mode.backend.name.lowercase(Locale.US), + ), ) when (mode) { @@ -87,18 +87,18 @@ public class AnvilCompilation internal constructor( PluginOption( pluginId = anvilCommandLineProcessor.pluginId, optionName = "src-gen-dir", - optionValue = File(workingDir, "build/anvil").absolutePath + optionValue = File(workingDir, "build/anvil").absolutePath, ), PluginOption( pluginId = anvilCommandLineProcessor.pluginId, optionName = "generate-dagger-factories", - optionValue = generateDaggerFactories.toString() + optionValue = generateDaggerFactories.toString(), ), PluginOption( pluginId = anvilCommandLineProcessor.pluginId, optionName = "generate-dagger-factories-only", - optionValue = generateDaggerFactoriesOnly.toString() - ) + optionValue = generateDaggerFactoriesOnly.toString(), + ), ) } is Ksp -> { @@ -106,8 +106,8 @@ public class AnvilCompilation internal constructor( addAll( ServiceLoader.load( SymbolProcessorProvider::class.java, - SymbolProcessorProvider::class.java.classLoader - ) + SymbolProcessorProvider::class.java.classLoader, + ), ) addAll(mode.symbolProcessorProviders) } @@ -122,7 +122,7 @@ public class AnvilCompilation internal constructor( if (enableExperimentalAnvilApis) { kotlincArguments += listOf( "-opt-in=kotlin.RequiresOptIn", - "-opt-in=com.squareup.anvil.annotations.ExperimentalAnvilApi" + "-opt-in=com.squareup.anvil.annotations.ExperimentalAnvilApi", ) } } @@ -164,14 +164,14 @@ public class AnvilCompilation internal constructor( */ public fun generatedAnvilFile( packageName: String, - fileName: String + fileName: String, ): File { check(isCompiled) { "No compilation run yet! Call compile() first." } return File( kotlinCompilation.workingDir, - "build/anvil/${packageName.replace('.', File.separatorChar)}/$fileName.kt" + "build/anvil/${packageName.replace('.', File.separatorChar)}/$fileName.kt", ) .apply { check(exists()) { @@ -192,7 +192,7 @@ public class AnvilCompilation internal constructor( */ public fun compile( @Language("kotlin") vararg sources: String, - block: JvmCompilationResult.() -> Unit = {} + block: JvmCompilationResult.() -> Unit = {}, ): JvmCompilationResult { checkNotCompiled() if (!anvilConfigured) { @@ -213,7 +213,7 @@ public class AnvilCompilation internal constructor( inheritClassPath = true jvmTarget = JvmTarget.JVM_1_8.description verbose = false - } + }, ) } } diff --git a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilationMode.kt b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilationMode.kt index 177ef6b87..90ebeec6a 100644 --- a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilationMode.kt +++ b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/AnvilCompilationMode.kt @@ -8,9 +8,9 @@ import com.squareup.anvil.compiler.api.CodeGenerator sealed class AnvilCompilationMode(val backend: AnvilBackend) { data class Embedded( - val codeGenerators: List = emptyList() + val codeGenerators: List = emptyList(), ) : AnvilCompilationMode(EMBEDDED) data class Ksp( - val symbolProcessorProviders: List = emptyList() + val symbolProcessorProviders: List = emptyList(), ) : AnvilCompilationMode(KSP) } diff --git a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/ReflectionTestUtils.kt b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/ReflectionTestUtils.kt index f2faf8097..f77bbeb7e 100644 --- a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/ReflectionTestUtils.kt +++ b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/ReflectionTestUtils.kt @@ -9,6 +9,7 @@ import java.lang.reflect.Modifier @ExperimentalAnvilApi public val Member.isStatic: Boolean get() = Modifier.isStatic(modifiers) + @ExperimentalAnvilApi public val Member.isAbstract: Boolean get() = Modifier.isAbstract(modifiers) @@ -19,7 +20,7 @@ public val Member.isAbstract: Boolean get() = Modifier.isAbstract(modifiers) @ExperimentalAnvilApi @Suppress("UNCHECKED_CAST") public fun Class.createInstance( - vararg initargs: Any? + vararg initargs: Any?, ): T = declaredConstructors.single().use { it.newInstance(*initargs) } as T @ExperimentalAnvilApi diff --git a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/SimpleCodeGenerator.kt b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/SimpleCodeGenerator.kt index 6473710e7..98120a6a3 100644 --- a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/SimpleCodeGenerator.kt +++ b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/SimpleCodeGenerator.kt @@ -13,14 +13,14 @@ import java.io.File private var counter = 0 fun simpleCodeGenerator( - mapper: CodeGenerator.(clazz: ClassReference.Psi) -> String? + mapper: CodeGenerator.(clazz: ClassReference.Psi) -> String?, ): CodeGenerator = object : CodeGenerator { override fun isApplicable(context: AnvilContext): Boolean = true override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { return projectFiles .classAndInnerClassReferences(module) @@ -34,7 +34,7 @@ fun simpleCodeGenerator( codeGenDir = codeGenDir, packageName = packageName, fileName = fileName, - content = content + content = content, ) } .toList() diff --git a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/TestUtils.kt b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/TestUtils.kt index 81afc4c49..d86989b01 100644 --- a/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/TestUtils.kt +++ b/compiler-utils/src/testFixtures/java/com/squareup/anvil/compiler/internal/testing/TestUtils.kt @@ -13,11 +13,11 @@ import kotlin.reflect.KClass @ExperimentalAnvilApi public fun Class<*>.moduleFactoryClass( providerMethodName: String, - companion: Boolean = false + companion: Boolean = false, ): Class<*> { val companionString = if (companion) "_Companion" else "" return classLoader.loadClass( - "${generatedClassesString()}${companionString}_${providerMethodName.capitalize()}Factory" + "${generatedClassesString()}${companionString}_${providerMethodName.capitalize()}Factory", ) } @@ -38,7 +38,7 @@ public fun Class<*>.membersInjector(): Class<*> { @ExperimentalAnvilApi public fun Class<*>.generatedClassesString( - separator: String = "_" + separator: String = "_", ): String { return generateSequence(enclosingClass) { it.enclosingClass } .toList() diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/AnvilCommandLineProcessor.kt b/compiler/src/main/java/com/squareup/anvil/compiler/AnvilCommandLineProcessor.kt index 831c7822b..b386a8a8a 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/AnvilCommandLineProcessor.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/AnvilCommandLineProcessor.kt @@ -40,7 +40,7 @@ class AnvilCommandLineProcessor : CommandLineProcessor { valueDescription = "", description = "Path to directory in which Anvil specific code should be generated", required = false, - allowMultipleOccurrences = false + allowMultipleOccurrences = false, ), CliOption( optionName = generateDaggerFactoriesName, @@ -49,7 +49,7 @@ class AnvilCommandLineProcessor : CommandLineProcessor { "annotation processor would generate for @Provides methods and @Inject " + "constructors.", required = false, - allowMultipleOccurrences = false + allowMultipleOccurrences = false, ), CliOption( optionName = generateDaggerFactoriesOnlyName, @@ -57,7 +57,7 @@ class AnvilCommandLineProcessor : CommandLineProcessor { description = "Whether Anvil should generate Factory classes only and no code for " + "contributed code.", required = false, - allowMultipleOccurrences = false + allowMultipleOccurrences = false, ), CliOption( optionName = disableComponentMergingName, @@ -65,7 +65,7 @@ class AnvilCommandLineProcessor : CommandLineProcessor { description = "Whether Anvil should generate code only and not transform code for " + "@MergeComponent or @MergeSubcomponent.", required = false, - allowMultipleOccurrences = false + allowMultipleOccurrences = false, ), @Suppress("EnumValuesSoftDeprecate") // Can't use Enum.entries while targeting Kotlin 1.8 CliOption( @@ -73,14 +73,14 @@ class AnvilCommandLineProcessor : CommandLineProcessor { valueDescription = AnvilBackend.values().joinToString("|", "<", ">"), description = "Controls whether Anvil is running as an embedded plugin or as KSP.", required = false, - allowMultipleOccurrences = false - ) + allowMultipleOccurrences = false, + ), ) override fun processOption( option: AbstractCliOption, value: String, - configuration: CompilerConfiguration + configuration: CompilerConfiguration, ) { when (option.optionName) { srcGenDirName -> configuration.put(srcGenDirKey, value) diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/AnvilComponentRegistrar.kt b/compiler/src/main/java/com/squareup/anvil/compiler/AnvilComponentRegistrar.kt index ca01e80b4..815581538 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/AnvilComponentRegistrar.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/AnvilComponentRegistrar.kt @@ -34,7 +34,7 @@ class AnvilComponentRegistrar : ComponentRegistrar { override fun registerProjectComponents( project: MockProject, - configuration: CompilerConfiguration + configuration: CompilerConfiguration, ) { val commandLineOptions = configuration.commandLineOptions val scanner by lazy(NONE) { @@ -47,12 +47,12 @@ class AnvilComponentRegistrar : ComponentRegistrar { if (!commandLineOptions.generateFactoriesOnly && !commandLineOptions.disableComponentMerging) { SyntheticResolveExtension.registerExtension( project, - InterfaceMerger(scanner, moduleDescriptorFactory) + InterfaceMerger(scanner, moduleDescriptorFactory), ) IrGenerationExtension.registerExtension( project, - ModuleMergerIr(scanner, moduleDescriptorFactory) + ModuleMergerIr(scanner, moduleDescriptorFactory), ) } @@ -84,14 +84,14 @@ class AnvilComponentRegistrar : ComponentRegistrar { codeGenDir = sourceGenFolder, codeGenerators = codeGenerators, commandLineOptions = commandLineOptions, - moduleDescriptorFactory = moduleDescriptorFactory - ) + moduleDescriptorFactory = moduleDescriptorFactory, + ), ) } private fun AnalysisHandlerExtension.Companion.registerExtensionFirst( project: MockProject, - extension: AnalysisHandlerExtension + extension: AnalysisHandlerExtension, ) { project.extensionArea .getExtensionPoint(AnalysisHandlerExtension.extensionPointName) diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/ClassScanner.kt b/compiler/src/main/java/com/squareup/anvil/compiler/ClassScanner.kt index 17a3d5044..77dc30356 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/ClassScanner.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/ClassScanner.kt @@ -25,7 +25,7 @@ internal class ClassScanner { fun findContributedClasses( module: ModuleDescriptor, annotation: FqName, - scope: FqName? + scope: FqName?, ): Sequence { val propertyGroups = cache.getOrPut(CacheKey(annotation, module.hashCode())) { val packageName = when (annotation) { @@ -61,13 +61,13 @@ internal class ClassScanner { .distinctBy { it.baseName } .singleOrEmpty() ?: throw AnvilCompilationException( - message = "Couldn't find the reference for a generated hint: ${properties[0].baseName}." + message = "Couldn't find the reference for a generated hint: ${properties[0].baseName}.", ) val scopes = properties.filterIsInstance() .ifEmpty { throw AnvilCompilationException( - message = "Couldn't find any scope for a generated hint: ${properties[0].baseName}." + message = "Couldn't find any scope for a generated hint: ${properties[0].baseName}.", ) } .map { it.descriptor.type.argumentType().classDescriptor().fqNameSafe } @@ -96,16 +96,16 @@ private fun PackageViewDescriptor.subPackages(): List = m private sealed class GeneratedProperty( val descriptor: PropertyDescriptor, - val baseName: String + val baseName: String, ) { class ReferenceProperty( descriptor: PropertyDescriptor, - baseName: String + baseName: String, ) : GeneratedProperty(descriptor, baseName) class ScopeProperty( descriptor: PropertyDescriptor, - baseName: String + baseName: String, ) : GeneratedProperty(descriptor, baseName) companion object { @@ -135,5 +135,5 @@ private sealed class GeneratedProperty( private data class CacheKey( val fqName: FqName, - val moduleHash: Int + val moduleHash: Int, ) diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/ClassScannerIr.kt b/compiler/src/main/java/com/squareup/anvil/compiler/ClassScannerIr.kt index bfcf6596e..bf95d1f17 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/ClassScannerIr.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/ClassScannerIr.kt @@ -16,7 +16,7 @@ internal fun ClassScanner.findContributedClasses( moduleFragment: IrModuleFragment, annotation: FqName, scope: ClassReferenceIr?, - moduleDescriptorFactory: RealAnvilModuleDescriptor.Factory + moduleDescriptorFactory: RealAnvilModuleDescriptor.Factory, ): Sequence { val module = moduleDescriptorFactory.create(moduleFragment.descriptor) diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/InterfaceMerger.kt b/compiler/src/main/java/com/squareup/anvil/compiler/InterfaceMerger.kt index b65d1370d..9d11e3088 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/InterfaceMerger.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/InterfaceMerger.kt @@ -25,11 +25,11 @@ import org.jetbrains.kotlin.types.KotlinType */ internal class InterfaceMerger( private val classScanner: ClassScanner, - private val moduleDescriptorFactory: RealAnvilModuleDescriptor.Factory + private val moduleDescriptorFactory: RealAnvilModuleDescriptor.Factory, ) : SyntheticResolveExtension { override fun addSyntheticSupertypes( thisDescriptor: ClassDescriptor, - supertypes: MutableList + supertypes: MutableList, ) { if (thisDescriptor.shouldIgnore()) return @@ -43,7 +43,7 @@ internal class InterfaceMerger( if (!mergeAnnotatedClass.isInterface()) { throw AnvilCompilationExceptionClassReference( classReference = mergeAnnotatedClass, - message = "Dagger components must be interfaces." + message = "Dagger components must be interfaces.", ) } @@ -58,7 +58,7 @@ internal class InterfaceMerger( classReference = mergeAnnotatedClass, message = "It seems like you tried to contribute an inner class to its outer class. " + "This is not supported and results in a compiler error.", - cause = e + cause = e, ) } } @@ -69,7 +69,7 @@ internal class InterfaceMerger( .findContributedClasses( module = module, annotation = contributesToFqName, - scope = annotation.scope().fqName + scope = annotation.scope().fqName, ) } .filter { clazz -> @@ -86,7 +86,7 @@ internal class InterfaceMerger( throw AnvilCompilationExceptionClassReference( classReference = contributedClass, message = "${contributedClass.fqName} is contributed to the Dagger graph, but the " + - "interface is not public. Only public interfaces are supported." + "interface is not public. Only public interfaces are supported.", ) } } @@ -108,13 +108,15 @@ internal class InterfaceMerger( classReference = contributedClass, message = "${contributedClass.fqName} wants to replace " + "${classToReplace.fqName}, but the class being " + - "replaced is not an interface." + "replaced is not an interface.", ) } val contributesToOurScope = classToReplace.annotations .findAll( - contributesToFqName, contributesBindingFqName, contributesMultibindingFqName + contributesToFqName, + contributesBindingFqName, + contributesMultibindingFqName, ) .map { it.scope() } .any { scope -> scope in scopes } @@ -125,7 +127,7 @@ internal class InterfaceMerger( message = "${contributedClass.fqName} with scopes " + "${scopes.joinToString(prefix = "[", postfix = "]") { it.fqName.asString() }} " + "wants to replace ${classToReplace.fqName}, but the replaced class isn't " + - "contributed to the same scope." + "contributed to the same scope.", ) } } @@ -141,7 +143,7 @@ internal class InterfaceMerger( .findAll(contributesToFqName, contributesBindingFqName, contributesMultibindingFqName) .map { it.scope() } .plus( - excludedClass.annotations.find(contributesSubcomponentFqName).map { it.parentScope() } + excludedClass.annotations.find(contributesSubcomponentFqName).map { it.parentScope() }, ) .any { scope -> scope in scopes } @@ -151,7 +153,7 @@ internal class InterfaceMerger( "${scopes.joinToString(prefix = "[", postfix = "]") { it.fqName.asString() }} " + "wants to exclude ${excludedClass.fqName}, but the excluded class isn't " + "contributed to the same scope.", - classReference = mergeAnnotatedClass + classReference = mergeAnnotatedClass, ) } } @@ -167,7 +169,7 @@ internal class InterfaceMerger( classReference = mergeAnnotatedClass, message = "${mergeAnnotatedClass.fqName} excludes types that it implements or " + "extends. These types cannot be excluded. Look at all the super types to find these " + - "classes: ${intersect.joinToString { it.fqName.asString() }}." + "classes: ${intersect.joinToString { it.fqName.asString() }}.", ) } } @@ -187,13 +189,13 @@ internal class InterfaceMerger( private fun findContributedSubcomponentParentInterfaces( clazz: ClassReference, scopes: Collection, - module: ModuleDescriptor + module: ModuleDescriptor, ): Sequence { return classScanner .findContributedClasses( module = module, annotation = contributesSubcomponentFqName, - scope = null + scope = null, ) .filter { it.atLeastOneAnnotation(contributesSubcomponentFqName).single().parentScope() in scopes diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/IrUtils.kt b/compiler/src/main/java/com/squareup/anvil/compiler/IrUtils.kt index 75293a8c5..084d1523f 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/IrUtils.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/IrUtils.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.name.FqName internal fun IrPluginContext.requireReferenceClass(fqName: FqName): IrClassSymbol { return referenceClass(fqName.classIdBestGuess()) ?: throw AnvilCompilationException( - message = "Couldn't resolve reference for $fqName" + message = "Couldn't resolve reference for $fqName", ) } @@ -34,7 +34,7 @@ internal fun ClassId.referenceClassOrNull(context: IrPluginContext): ClassRefere internal fun IrClass.requireClassId(): ClassId { return classId ?: throw AnvilCompilationException( element = this, - message = "Couldn't find a ClassId for $fqName." + message = "Couldn't find a ClassId for $fqName.", ) } @@ -44,13 +44,13 @@ internal val IrExpression.kclassUnwrapped: IrClassifierSymbol get() = (type as? IrSimpleType)?.arguments?.get(0)?.typeOrNull?.classifierOrNull ?: throw AnvilCompilationException( message = "Couldn't resolve wrapped class.", - element = this + element = this, ) internal val IrDeclarationWithName.fqName: FqName get() = fqNameWhenAvailable ?: throw AnvilCompilationException( message = "Couldn't find FqName for $name", - element = this + element = this, ) internal val IrClassSymbol.fqName: FqName get() = owner.fqName diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/ModuleMergerIr.kt b/compiler/src/main/java/com/squareup/anvil/compiler/ModuleMergerIr.kt index 95540522c..79246f82f 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/ModuleMergerIr.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/ModuleMergerIr.kt @@ -33,14 +33,14 @@ import org.jetbrains.kotlin.name.Name internal class ModuleMergerIr( private val classScanner: ClassScanner, - private val moduleDescriptorFactory: RealAnvilModuleDescriptor.Factory + private val moduleDescriptorFactory: RealAnvilModuleDescriptor.Factory, ) : IrGenerationExtension { // https://youtrack.jetbrains.com/issue/KT-56635 override val shouldAlsoBeAppliedInKaptStubGenerationMode: Boolean get() = true override fun generate( moduleFragment: IrModuleFragment, - pluginContext: IrPluginContext + pluginContext: IrPluginContext, ) { moduleFragment.transform( object : IrElementTransformerVoid() { @@ -58,12 +58,12 @@ internal class ModuleMergerIr( annotations = annotations, moduleFragment = moduleFragment, pluginContext = pluginContext, - declaration = declarationReference + declaration = declarationReference, ) return super.visitClass(declaration) } }, - null + null, ) } @@ -71,7 +71,7 @@ internal class ModuleMergerIr( annotations: List, moduleFragment: IrModuleFragment, pluginContext: IrPluginContext, - declaration: ClassReferenceIr + declaration: ClassReferenceIr, ) { val daggerAnnotationFqName = annotations[0].daggerAnnotationFqName @@ -90,7 +90,7 @@ internal class ModuleMergerIr( moduleFragment = moduleFragment, annotation = contributesToFqName, scope = annotation.scope, - moduleDescriptorFactory = moduleDescriptorFactory + moduleDescriptorFactory = moduleDescriptorFactory, ) } .filter { @@ -122,7 +122,7 @@ internal class ModuleMergerIr( message = "${contributedClass.fqName} is annotated with " + "@${ContributesTo::class.simpleName}, but this class is neither an interface " + "nor a Dagger module. Did you forget to add @${Module::class.simpleName}?", - classReference = contributedClass + classReference = contributedClass, ) } @@ -134,7 +134,7 @@ internal class ModuleMergerIr( throw AnvilCompilationExceptionClassReferenceIr( message = "${contributedClass.fqName} is contributed to the Dagger graph, but the " + "module is not public. Only public modules are supported.", - classReference = contributedClass + classReference = contributedClass, ) } } @@ -153,7 +153,7 @@ internal class ModuleMergerIr( .plus( excludedClass.annotations .find(contributesSubcomponentFqName) - .map { it.parentScope } + .map { it.parentScope }, ) .any { scope -> scope in scopes } @@ -163,7 +163,7 @@ internal class ModuleMergerIr( "${scopes.joinToString(prefix = "[", postfix = "]") { it.fqName.asString() }} " + "wants to exclude ${excludedClass.fqName}, but the excluded class isn't " + "contributed to the same scope.", - classReference = declaration + classReference = declaration, ) } } @@ -187,7 +187,7 @@ internal class ModuleMergerIr( message = "${contributedClass.fqName} wants to replace " + "${classToReplace.fqName}, but the class being " + "replaced is not a Dagger module.", - classReference = contributedClass + classReference = contributedClass, ) } @@ -196,7 +196,7 @@ internal class ModuleMergerIr( } fun replacedModulesByContributedBinding( - annotationFqName: FqName + annotationFqName: FqName, ): Sequence { return scopes.asSequence() .flatMap { scope -> @@ -206,7 +206,7 @@ internal class ModuleMergerIr( moduleFragment = moduleFragment, annotation = annotationFqName, scope = scope, - moduleDescriptorFactory = moduleDescriptorFactory + moduleDescriptorFactory = moduleDescriptorFactory, ) } .flatMap { contributedClass -> @@ -221,11 +221,11 @@ internal class ModuleMergerIr( } val replacedModulesByContributedBindings = replacedModulesByContributedBinding( - annotationFqName = contributesBindingFqName + annotationFqName = contributesBindingFqName, ) val replacedModulesByContributedMultibindings = replacedModulesByContributedBinding( - annotationFqName = contributesMultibindingFqName + annotationFqName = contributesMultibindingFqName, ) if (predefinedModules.isNotEmpty()) { @@ -234,7 +234,7 @@ internal class ModuleMergerIr( throw AnvilCompilationExceptionClassReferenceIr( message = "${declaration.fqName} includes and excludes modules " + "at the same time: ${intersect.joinToString { it.fqName.asString() }}", - classReference = declaration + classReference = declaration, ) } } @@ -244,7 +244,7 @@ internal class ModuleMergerIr( declaration, scopes, pluginContext, - moduleFragment + moduleFragment, ) val contributedModules = contributesAnnotations @@ -263,7 +263,7 @@ internal class ModuleMergerIr( callee = pluginContext .referenceConstructors(daggerAnnotationFqName.classIdBestGuess()) .single { it.owner.isPrimary }, - typeArguments = emptyList() + typeArguments = emptyList(), ) .apply { putValueArgument( @@ -273,11 +273,11 @@ internal class ModuleMergerIr( values = contributedModules .map { kClassReference( - classType = it.defaultType + classType = it.defaultType, ) } - .toList() - ) + .toList(), + ), ) fun copyArrayValue(name: String) { @@ -291,8 +291,8 @@ internal class ModuleMergerIr( elementType = varargArguments[0].varargElementType, // These are always IrExpression instances too values = varargArguments.flatMap { it.elements } - .filterIsInstance() - ) + .filterIsInstance(), + ), ) } @@ -324,7 +324,7 @@ internal class ModuleMergerIr( private fun checkSameScope( contributedClass: ClassReferenceIr, classToReplace: ClassReferenceIr, - scopes: List + scopes: List, ) { val contributesToOurScope = classToReplace.annotations .findAll(contributesToFqName, contributesBindingFqName, contributesMultibindingFqName) @@ -337,7 +337,7 @@ internal class ModuleMergerIr( message = "${contributedClass.fqName} with scopes " + "${scopes.joinToString(prefix = "[", postfix = "]") { it.fqName.asString() }} " + "wants to replace ${classToReplace.fqName}, but the replaced class isn't " + - "contributed to the same scope." + "contributed to the same scope.", ) } } @@ -346,7 +346,7 @@ internal class ModuleMergerIr( declaration: ClassReferenceIr, scopes: List, pluginContext: IrPluginContext, - moduleFragment: IrModuleFragment + moduleFragment: IrModuleFragment, ): Sequence { return classScanner .findContributedClasses( @@ -354,7 +354,7 @@ internal class ModuleMergerIr( moduleFragment = moduleFragment, annotation = contributesSubcomponentFqName, scope = null, - moduleDescriptorFactory = moduleDescriptorFactory + moduleDescriptorFactory = moduleDescriptorFactory, ) .filter { clazz -> clazz.annotations.find(contributesSubcomponentFqName).any { it.parentScope in scopes } 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 58d006684..e79f4d120 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/Utils.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/Utils.kt @@ -91,7 +91,7 @@ internal fun String.isAnvilModule(): Boolean { @Suppress("UNCHECKED_CAST") internal fun ClassId.classReferenceOrNull( - module: ModuleDescriptor + module: ModuleDescriptor, ): T? = asSingleFqName().toClassReferenceOrNull(module) as T? // If we're evaluating an anonymous inner class, it cannot merge anything and will cause @@ -109,9 +109,11 @@ internal inline fun Iterable.singleOrEmpty(predicate: (T) -> Boolean): T? var found = false for (element in this) { if (predicate(element)) { - if (found) throw IllegalArgumentException( - "Collection contains more than one matching element." - ) + if (found) { + throw IllegalArgumentException( + "Collection contains more than one matching element.", + ) + } single = element found = true } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/AnnotationReferenceExtensions.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/AnnotationReferenceExtensions.kt index 269999054..03ce1304b 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/AnnotationReferenceExtensions.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/AnnotationReferenceExtensions.kt @@ -24,7 +24,7 @@ internal fun AnnotationReference.parentScope(): ClassReference { ?.value() ?: throw AnvilCompilationExceptionAnnotationReference( message = "Couldn't find parentScope for $fqName.", - annotationReference = this + annotationReference = this, ) } @@ -35,7 +35,7 @@ internal fun AnnotationReference.ignoreQualifier(): Boolean { contributesBindingFqName -> 4 contributesMultibindingFqName -> 3 else -> return false - } + }, ) ?.value() ?: false @@ -49,7 +49,7 @@ internal fun AnnotationReference.priority(): Priority { } internal fun AnnotationReference.modules( - parameterIndex: Int = modulesIndex(fqName) + parameterIndex: Int = modulesIndex(fqName), ): List { return argumentAt(modulesName(fqName), parameterIndex) ?.value>() @@ -61,7 +61,7 @@ private fun modulesIndex(annotationFqName: FqName): Int { mergeComponentFqName, mergeSubcomponentFqName, mergeModulesFqName -> 1 contributesSubcomponentFqName -> 2 else -> throw NotImplementedError( - "Couldn't find index of modules argument for $annotationFqName." + "Couldn't find index of modules argument for $annotationFqName.", ) } } @@ -71,14 +71,14 @@ private fun modulesName(annotationFqName: FqName): String { mergeComponentFqName, mergeSubcomponentFqName, contributesSubcomponentFqName -> "modules" mergeModulesFqName -> "includes" else -> throw NotImplementedError( - "Couldn't find name of modules argument for $annotationFqName." + "Couldn't find name of modules argument for $annotationFqName.", ) } } internal fun List.find( annotationName: FqName, - scope: ClassReference? = null + scope: ClassReference? = null, ): List { return filter { it.fqName == annotationName && (scope == null || it.scopeOrNull() == scope) @@ -87,7 +87,7 @@ internal fun List.find( internal fun List.findAll( vararg annotationNames: FqName, - scope: ClassReference? = null + scope: ClassReference? = null, ): List { return filter { it.fqName in annotationNames && (scope == null || it.scopeOrNull() == scope) @@ -95,7 +95,7 @@ internal fun List.findAll( } internal fun List.checkNoDuplicateScope( - contributeAnnotation: Boolean + contributeAnnotation: Boolean, ) { // Exit early to avoid allocating additional collections. if (size < 2) return @@ -121,7 +121,7 @@ internal fun List.checkNoDuplicateScope( "${duplicates.keys.joinToString(prefix = "[", postfix = "]") { it.shortName }}. " + "Merging multiple times to the same scope is forbidden and all scopes must " + "be distinct." - } + }, ) } } @@ -150,7 +150,7 @@ internal fun List.checkNoDuplicateScopeAndBoundType it?.shortName ?: clazz.directSuperTypeReferences().single().asClassReference().shortName } + ". Contributing multiple times to the same scope with the same bound type is forbidden " + - "and all scope - bound type combinations must be distinct." + "and all scope - bound type combinations must be distinct.", ) } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/BindingModuleGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/BindingModuleGenerator.kt index 1a639b0f5..1b4a6f828 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/BindingModuleGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/BindingModuleGenerator.kt @@ -42,11 +42,11 @@ import java.io.File private val supportedFqNames = listOf( mergeComponentFqName, mergeSubcomponentFqName, - mergeModulesFqName + mergeModulesFqName, ) internal class BindingModuleGenerator( - private val classScanner: ClassScanner + private val classScanner: ClassScanner, ) : FlushingCodeGenerator { override fun isApplicable(context: AnvilContext): Boolean = !context.generateFactoriesOnly @@ -62,7 +62,7 @@ internal class BindingModuleGenerator( override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { val classes = projectFiles.classAndInnerClassReferences(module).toList() @@ -107,7 +107,7 @@ internal class BindingModuleGenerator( val content = daggerModuleContent( scopes = mergeAnnotations.map { it.scope() }, clazz = clazz, - generatedMethods = emptyList() + generatedMethods = emptyList(), ) mergedClasses[clazz] = file @@ -119,7 +119,7 @@ internal class BindingModuleGenerator( override fun flush( codeGenDir: File, - module: ModuleDescriptor + module: ModuleDescriptor, ): Collection { return mergedClasses.map { (mergedClass, daggerModuleFile) -> val annotations = mergedClass.annotations.filter { it.fqName in supportedFqNames } @@ -139,10 +139,10 @@ internal class BindingModuleGenerator( .findContributedClasses( module = module, annotation = contributesToFqName, - scope = scope.fqName + scope = scope.fqName, ) .filter { it.isAnnotatedWith(daggerModuleFqName) } - } + }, ) // Ignore replaced bindings specified by excluded modules for this scope. .filter { clazz -> clazz !in excludedClasses } @@ -162,14 +162,14 @@ internal class BindingModuleGenerator( fun getContributedBindingClasses( collectedClasses: List, annotationFqName: FqName, - isMultibinding: Boolean + isMultibinding: Boolean, ): List { val contributedBindingsDependencies = scopes.flatMap { scope -> classScanner.findContributedClasses( module, annotation = annotationFqName, - scope = scope.fqName + scope = scope.fqName, ) } @@ -214,14 +214,14 @@ internal class BindingModuleGenerator( getContributedBindingClasses( collectedClasses = contributedBindingClasses, annotationFqName = contributesBindingFqName, - isMultibinding = false + isMultibinding = false, ) .plus( getContributedBindingClasses( collectedClasses = contributedMultibindingClasses, annotationFqName = contributesMultibindingFqName, - isMultibinding = true - ) + isMultibinding = true, + ), ) .renameDuplicateFunctions() .sorted() @@ -229,7 +229,7 @@ internal class BindingModuleGenerator( val content = daggerModuleContent( scopes = scopes, clazz = mergedClass, - generatedMethods = generatedMethods + generatedMethods = generatedMethods, ) daggerModuleFile.writeText(content) @@ -241,7 +241,7 @@ internal class BindingModuleGenerator( private fun daggerModuleContent( scopes: List, clazz: ClassReference, - generatedMethods: List + generatedMethods: List, ): String { val className = clazz.generateClassName(separator = "", suffix = ANVIL_MODULE_SUFFIX) .relativeClassName @@ -263,7 +263,7 @@ internal class BindingModuleGenerator( addType( TypeSpec.companionObjectBuilder() .addFunctions(providerMethods.specs) - .build() + .build(), ) } } @@ -278,11 +278,11 @@ internal class BindingModuleGenerator( AnnotationSpec .builder(ContributesTo::class) .addMember("%T::class", scope.asClassName()) - .build() + .build(), ) } } - .build() + .build(), ) } } @@ -312,7 +312,9 @@ private sealed class GeneratedMethod : Comparable { companion object { val COMPARATOR = compareBy( - { it.spec.name }, { it.contributedClass }, { it.boundType } + { it.spec.name }, + { it.contributedClass }, + { it.boundType }, ) } } @@ -333,8 +335,8 @@ private fun List.findHighestPriorityBinding(): ContributedBi "${bindings[0].boundType.fqName}. The contributed binding classes are: " + bindings.joinToString( prefix = "[", - postfix = "]" - ) { it.contributedClass.fqName.asString() } + postfix = "]", + ) { it.contributedClass.fqName.asString() }, ) } @@ -342,7 +344,7 @@ private fun List.findHighestPriorityBinding(): ContributedBi } private fun ContributedBinding.toGeneratedMethod( - isMultibinding: Boolean + isMultibinding: Boolean, ): GeneratedMethod { val isMapMultibinding = mapKeys.isNotEmpty() @@ -370,7 +372,7 @@ private fun ContributedBinding.toGeneratedMethod( .addStatement("return %T", contributedClass.asClassName()) .build(), contributedClass = contributedClass, - boundType = boundType + boundType = boundType, ) } else { BindingMethod( @@ -387,12 +389,12 @@ private fun ContributedBinding.toGeneratedMethod( .addModifiers(ABSTRACT) .addParameter( name = contributedClass.shortName.decapitalize(), - type = contributedClass.asClassName() + type = contributedClass.asClassName(), ) .returns(boundType.asClassName()) .build(), contributedClass = contributedClass, - boundType = boundType + boundType = boundType, ) } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ClassReferenceExtensions.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ClassReferenceExtensions.kt index 70fca8764..b393f76ec 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ClassReferenceExtensions.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ClassReferenceExtensions.kt @@ -13,7 +13,7 @@ import com.squareup.anvil.compiler.internal.reference.allSuperTypeClassReference import org.jetbrains.kotlin.name.FqName internal fun ClassReference.checkNotMoreThanOneQualifier( - annotationFqName: FqName + annotationFqName: FqName, ) { // The class is annotated with @ContributesBinding, @ContributesMultibinding, or another Anvil annotation. // If there is less than 2 further annotations, then there can't be more than two qualifiers. @@ -24,7 +24,7 @@ internal fun ClassReference.checkNotMoreThanOneQualifier( throw AnvilCompilationExceptionClassReference( message = "Classes annotated with @${annotationFqName.shortName()} may not use more " + "than one @Qualifier.", - classReference = this + classReference = this, ) } } @@ -33,7 +33,7 @@ internal inline fun ClassReference.checkClassIsPublic(message: () -> String) { if (visibility() != Visibility.PUBLIC) { throw AnvilCompilationExceptionClassReference( classReference = this, - message = message() + message = message(), ) } } @@ -49,13 +49,13 @@ internal fun ClassReference.checkNotMoreThanOneMapKey() { throw AnvilCompilationExceptionClassReference( message = "Classes annotated with @${contributesMultibindingFqName.shortName()} may not " + "use more than one @MapKey.", - classReference = this + classReference = this, ) } } internal fun ClassReference.checkSingleSuperType( - annotationFqName: FqName + annotationFqName: FqName, ) { // If the bound type exists, then you're allowed to have multiple super types. Without the bound // type there must be exactly one super type. @@ -67,19 +67,19 @@ internal fun ClassReference.checkSingleSuperType( "specify the bound type. This is only allowed with exactly one direct super type. " + "If there are multiple or none, then the bound type must be explicitly defined in " + "the @${annotationFqName.shortName()} annotation.", - classReference = this + classReference = this, ) } } internal fun ClassReference.checkClassExtendsBoundType( - annotationFqName: FqName + annotationFqName: FqName, ) { val boundType = annotations.find { it.fqName == annotationFqName }?.boundTypeOrNull() ?: directSuperTypeReferences().singleOrNull()?.asClassReference() ?: throw AnvilCompilationExceptionClassReference( message = "Couldn't find the bound type.", - classReference = this + classReference = this, ) // The boundType is declared explicitly in the annotation. Since all classes extend Any, we can @@ -90,21 +90,21 @@ internal fun ClassReference.checkClassExtendsBoundType( throw AnvilCompilationExceptionClassReference( message = "${this.fqName} contributes a binding for ${boundType.fqName}, but doesn't " + "extend this type.", - classReference = this + classReference = this, ) } } internal fun ClassReference.atLeastOneAnnotation( annotationName: FqName, - scope: ClassReference? = null + scope: ClassReference? = null, ): List { return annotations.find(annotationName = annotationName, scope = scope) .ifEmpty { throw AnvilCompilationExceptionClassReference( classReference = this, message = "Class $fqName is not annotated with $annotationName" + - "${if (scope == null) "" else " with scope ${scope.fqName}"}." + "${if (scope == null) "" else " with scope ${scope.fqName}"}.", ) } } @@ -132,7 +132,7 @@ internal fun Collection.injectConstructor(): T? throw AnvilCompilationExceptionClassReference( classReference = constructors[0].declaringClass, message = "Type ${constructors[0].declaringClass.fqName} may only contain one injected " + - "constructor. Found: [$constructorsErrorMessage]" + "constructor. Found: [$constructorsErrorMessage]", ) } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/CodeGenerationExtension.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/CodeGenerationExtension.kt index cd78fd6a3..732a4240a 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/CodeGenerationExtension.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/CodeGenerationExtension.kt @@ -23,7 +23,7 @@ internal class CodeGenerationExtension( private val codeGenDir: File, codeGenerators: List, private val commandLineOptions: CommandLineOptions, - private val moduleDescriptorFactory: RealAnvilModuleDescriptor.Factory + private val moduleDescriptorFactory: RealAnvilModuleDescriptor.Factory, ) : AnalysisHandlerExtension { private var didRecompile = false @@ -46,7 +46,7 @@ internal class CodeGenerationExtension( projectContext: ProjectContext, files: Collection, bindingTrace: BindingTrace, - componentProvider: ComponentProvider + componentProvider: ComponentProvider, ): AnalysisResult? { // Tell the compiler that we have something to do in the analysisCompleted() method if // necessary. @@ -57,7 +57,7 @@ internal class CodeGenerationExtension( project: Project, module: ModuleDescriptor, bindingTrace: BindingTrace, - files: Collection + files: Collection, ): AnalysisResult? { if (didRecompile) return null didRecompile = true @@ -90,7 +90,7 @@ internal class CodeGenerationExtension( val virtualFile = LightVirtualFile( file.relativeTo(codeGenDir).path, KotlinFileType.INSTANCE, - content + content, ) psiManager.findFile(virtualFile) @@ -121,7 +121,7 @@ internal class CodeGenerationExtension( "\n\nThe content of the new file is:\n\n" + generatedFile.content.lines().joinToString(separator = "\n") { "\t$it" - } + }, ) } @@ -156,7 +156,7 @@ internal class CodeGenerationExtension( moduleDescriptor = anvilModule, additionalJavaRoots = emptyList(), additionalKotlinRoots = listOf(codeGenDir), - addToEnvironment = true + addToEnvironment = true, ) } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributedBinding.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributedBinding.kt index 5fb53d8c3..7fb5f0ec2 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributedBinding.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributedBinding.kt @@ -20,7 +20,7 @@ internal data class ContributedBinding( val qualifiers: List, val boundType: ClassReference, val priority: Priority, - val qualifiersKeyLazy: Lazy + val qualifiersKeyLazy: Lazy, ) internal fun AnnotationReference.toContributedBinding( @@ -48,7 +48,7 @@ internal fun AnnotationReference.toContributedBinding( qualifiers = qualifiers, boundType = boundType, priority = priority(), - qualifiersKeyLazy = declaringClass().qualifiersKeyLazy(boundType, ignoreQualifier) + qualifiersKeyLazy = declaringClass().qualifiersKeyLazy(boundType, ignoreQualifier), ) } @@ -64,7 +64,7 @@ private fun AnnotationReference.requireBoundType(module: ModuleDescriptor): Clas .firstOrNull { it.fqName == boundFromAnnotation.fqName } ?: throw AnvilCompilationException( "$fqName contributes a binding for ${boundFromAnnotation.fqName}, " + - "but doesn't extend this type." + "but doesn't extend this type.", ) boundType.checkNotGeneric(contributedClass = declaringClass()) @@ -79,7 +79,7 @@ private fun AnnotationReference.requireBoundType(module: ModuleDescriptor): Clas message = "$fqName contributes a binding, but does not " + "specify the bound type. This is only allowed with exactly one direct super type. " + "If there are multiple or none, then the bound type must be explicitly defined in " + - "the @$shortName annotation." + "the @$shortName annotation.", ) boundType.checkNotGeneric(contributedClass = declaringClass()) @@ -87,7 +87,7 @@ private fun AnnotationReference.requireBoundType(module: ModuleDescriptor): Clas } private fun ClassReference.checkNotGeneric( - contributedClass: ClassReference + contributedClass: ClassReference, ) { fun exceptionText(typeString: String): String { return "Class ${contributedClass.fqName} binds $fqName," + @@ -108,7 +108,7 @@ private fun ClassReference.checkNotGeneric( throw AnvilCompilationException( classDescriptor = clazz, - message = exceptionText(clazz.defaultType.describeTypeParameters()) + message = exceptionText(clazz.defaultType.describeTypeParameters()), ) } } @@ -119,7 +119,7 @@ private fun ClassReference.checkNotGeneric( throw AnvilCompilationException( message = exceptionText(typeString), - element = clazz.nameIdentifier + element = clazz.nameIdentifier, ) } } @@ -128,7 +128,7 @@ private fun ClassReference.checkNotGeneric( private fun ClassReference.qualifiersKeyLazy( boundType: ClassReference, - ignoreQualifier: Boolean + ignoreQualifier: Boolean, ): Lazy { // Careful! If we ever decide to support generic types, then we might need to use the // Kotlin type and not just the FqName. 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 0dfda3540..1eb097058 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 @@ -65,11 +65,11 @@ internal object ContributesBindingCodeGen : AnvilApplicabilityChecker { PropertySpec .builder( name = propertyName + REFERENCE_SUFFIX, - type = KClass::class.asClassName().parameterizedBy(originClass) + type = KClass::class.asClassName().parameterizedBy(originClass), ) .initializer("%T::class", originClass) .addModifiers(PUBLIC) - .build() + .build(), ) scopes.forEachIndexed { index, scope -> @@ -77,11 +77,11 @@ internal object ContributesBindingCodeGen : AnvilApplicabilityChecker { PropertySpec .builder( name = propertyName + SCOPE_SUFFIX + index, - type = KClass::class.asClassName().parameterizedBy(scope) + type = KClass::class.asClassName().parameterizedBy(scope), ) .initializer("%T::class", scope) .addModifiers(PUBLIC) - .build() + .build(), ) } } @@ -98,7 +98,8 @@ internal object ContributesBindingCodeGen : AnvilApplicabilityChecker { when { annotated !is KSClassDeclaration -> { env.logger.error( - "Only classes can be annotated with @ContributesBinding.", annotated + "Only classes can be annotated with @ContributesBinding.", + annotated, ) return@mapNotNull null } @@ -130,7 +131,7 @@ internal object ContributesBindingCodeGen : AnvilApplicabilityChecker { spec.writeTo( env.codeGenerator, aggregating = false, - originatingKSFiles = listOf(clazz.containingFile!!) + originatingKSFiles = listOf(clazz.containingFile!!), ) } @@ -150,7 +151,7 @@ internal object ContributesBindingCodeGen : AnvilApplicabilityChecker { override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { return projectFiles .classAndInnerClassReferences(module) @@ -181,7 +182,7 @@ internal object ContributesBindingCodeGen : AnvilApplicabilityChecker { codeGenDir = codeGenDir, packageName = spec.packageName, fileName = spec.name, - content = spec.toString() + content = spec.toString(), ) } .toList() 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 df90a7dc1..0a12e5bdf 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 @@ -53,7 +53,7 @@ internal object ContributesMultibindingCodeGen : AnvilApplicabilityChecker { fun generate( className: ClassName, - scopes: List + scopes: List, ): FileSpec { val fileName = className.generateClassName().simpleName val generatedPackage = HINT_MULTIBINDING_PACKAGE_PREFIX + @@ -66,11 +66,11 @@ internal object ContributesMultibindingCodeGen : AnvilApplicabilityChecker { PropertySpec .builder( name = propertyName + REFERENCE_SUFFIX, - type = KClass::class.asClassName().parameterizedBy(className) + type = KClass::class.asClassName().parameterizedBy(className), ) .initializer("%T::class", className) .addModifiers(PUBLIC) - .build() + .build(), ) scopes.forEachIndexed { index, scope -> @@ -78,11 +78,11 @@ internal object ContributesMultibindingCodeGen : AnvilApplicabilityChecker { PropertySpec .builder( name = propertyName + SCOPE_SUFFIX + index, - type = KClass::class.asClassName().parameterizedBy(scope) + type = KClass::class.asClassName().parameterizedBy(scope), ) .initializer("%T::class", scope) .addModifiers(PUBLIC) - .build() + .build(), ) } } @@ -100,7 +100,7 @@ internal object ContributesMultibindingCodeGen : AnvilApplicabilityChecker { if (clazz !is KSClassDeclaration) { env.logger.error( "@${ContributesMultibinding::class.simpleName} can only be applied to classes", - clazz + clazz, ) return@forEach } @@ -127,7 +127,7 @@ internal object ContributesMultibindingCodeGen : AnvilApplicabilityChecker { .writeTo( codeGenerator = env.codeGenerator, aggregating = false, - originatingKSFiles = listOf(clazz.containingFile!!) + originatingKSFiles = listOf(clazz.containingFile!!), ) } @@ -147,7 +147,7 @@ internal object ContributesMultibindingCodeGen : AnvilApplicabilityChecker { override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { return projectFiles .classAndInnerClassReferences(module) @@ -178,7 +178,7 @@ internal object ContributesMultibindingCodeGen : AnvilApplicabilityChecker { codeGenDir = codeGenDir, packageName = spec.packageName, fileName = spec.name, - content = spec.toString() + content = spec.toString(), ) } .toList() diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentGenerator.kt index 469d6342f..54b4e2987 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentGenerator.kt @@ -44,7 +44,7 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { return projectFiles .classAndInnerClassReferences(module) @@ -54,7 +54,7 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { throw AnvilCompilationExceptionClassReference( message = "${clazz.fqName} is annotated with " + "@${ContributesSubcomponent::class.simpleName}, but this class is not an interface.", - classReference = clazz + classReference = clazz, ) } @@ -62,7 +62,7 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { throw AnvilCompilationExceptionClassReference( message = "${clazz.fqName} is contributed to the Dagger graph, but the " + "interface is not public. Only public interfaces are supported.", - classReference = clazz + classReference = clazz, ) } @@ -95,22 +95,22 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { PropertySpec .builder( name = propertyName + REFERENCE_SUFFIX, - type = KClass::class.asClassName().parameterizedBy(className) + type = KClass::class.asClassName().parameterizedBy(className), ) .initializer("%T::class", className) .addModifiers(PUBLIC) - .build() + .build(), ) addProperty( PropertySpec .builder( name = propertyName + SCOPE_SUFFIX, - type = KClass::class.asClassName().parameterizedBy(parentScope) + type = KClass::class.asClassName().parameterizedBy(parentScope), ) .initializer("%T::class", parentScope) .addModifiers(PUBLIC) - .build() + .build(), ) } @@ -118,7 +118,7 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { codeGenDir = codeGenDir, packageName = generatedPackage, fileName = fileName, - content = content + content = content, ) } .toList() @@ -126,7 +126,7 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { private fun ClassReference.checkParentComponentInterface( innerClasses: List, - parentScope: ClassReference + parentScope: ClassReference, ) { val parentComponents = innerClasses .filter { @@ -141,7 +141,7 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { else -> throw AnvilCompilationExceptionClassReference( classReference = this, message = "Expected zero or one parent component interface within " + - "$fqName being contributed to the parent scope." + "$fqName being contributed to the parent scope.", ) } @@ -151,7 +151,7 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { if (functions.size >= 2) { throw AnvilCompilationExceptionClassReference( classReference = componentInterface, - message = "Expected zero or one function returning the subcomponent $fqName." + message = "Expected zero or one function returning the subcomponent $fqName.", ) } } @@ -164,7 +164,7 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { classReference = factoryClass, message = "Within a class using @${ContributesSubcomponent::class.simpleName} you " + "must use $contributesSubcomponentFactoryFqName and not " + - "$daggerSubcomponentFactoryFqName." + "$daggerSubcomponentFactoryFqName.", ) } @@ -175,7 +175,7 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { classReference = factoryClass, message = "Within a class using @${ContributesSubcomponent::class.simpleName} you " + "must use $contributesSubcomponentFactoryFqName and not " + - "$daggerSubcomponentBuilderFqName. Builders aren't supported." + "$daggerSubcomponentBuilderFqName. Builders aren't supported.", ) } @@ -187,14 +187,14 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { 1 -> factories[0] else -> throw AnvilCompilationExceptionClassReference( classReference = this, - message = "Expected zero or one factory within $fqName." + message = "Expected zero or one factory within $fqName.", ) } if (!factory.isInterface() && !factory.isAbstract()) { throw AnvilCompilationExceptionClassReference( classReference = factory, - message = "A factory must be an interface or an abstract class." + message = "A factory must be an interface or an abstract class.", ) } @@ -211,21 +211,21 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { throw AnvilCompilationExceptionClassReference( classReference = factory, message = "A factory must have exactly one abstract function returning the " + - "subcomponent $fqName." + "subcomponent $fqName.", ) } } private fun ClassReference.checkUsesSameScope( scope: ClassReference, - subcomponent: ClassReference + subcomponent: ClassReference, ) { annotations .filter { it.fqName == contributesSubcomponentFqName } .ifEmpty { throw AnvilCompilationExceptionClassReference( classReference = subcomponent, - message = "Couldn't find the annotation @ContributesSubcomponent for $fqName." + message = "Couldn't find the annotation @ContributesSubcomponent for $fqName.", ) } .forEach { annotation -> @@ -234,7 +234,7 @@ internal class ContributesSubcomponentGenerator : CodeGenerator { throw AnvilCompilationExceptionClassReference( classReference = subcomponent, message = "${subcomponent.fqName} with scope ${scope.fqName} wants to replace " + - "$fqName with scope ${otherScope.fqName}. The replacement must use the same scope." + "$fqName with scope ${otherScope.fqName}. The replacement must use the same scope.", ) } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentHandlerGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentHandlerGenerator.kt index 360d75b6b..f66c16004 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentHandlerGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentHandlerGenerator.kt @@ -62,7 +62,7 @@ import java.io.File * ``` */ internal class ContributesSubcomponentHandlerGenerator( - private val classScanner: ClassScanner + private val classScanner: ClassScanner, ) : CodeGenerator { private val triggers = mutableListOf() @@ -77,7 +77,7 @@ internal class ContributesSubcomponentHandlerGenerator( override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { if (isFirstRound) { isFirstRound = false @@ -150,7 +150,7 @@ internal class ContributesSubcomponentHandlerGenerator( .apply { fun addClassArrayMember( name: String, - references: List + references: List, ) { if (references.isNotEmpty()) { val classes = references.map { it.asClassName() } @@ -164,12 +164,12 @@ internal class ContributesSubcomponentHandlerGenerator( addClassArrayMember("modules", contribution.annotation.modules()) addClassArrayMember("exclude", contribution.annotation.exclude()) } - .build() + .build(), ) .addAnnotations( contribution.clazz.annotations .filter { it.isDaggerScope() } - .map { it.toAnnotationSpec() } + .map { it.toAnnotationSpec() }, ) .apply { if (factoryClass != null) { @@ -179,8 +179,10 @@ internal class ContributesSubcomponentHandlerGenerator( } .addType( generateParentComponent( - contribution, generatedAnvilSubcomponent, factoryClass - ) + contribution, + generatedAnvilSubcomponent, + factoryClass, + ), ) .build() .also { addType(it) } @@ -190,13 +192,13 @@ internal class ContributesSubcomponentHandlerGenerator( codeGenDir = codeGenDir, packageName = generatedPackage, fileName = componentClassName, - content = content + content = content, ) } } private fun generateFactory( - factoryReference: ClassReference + factoryReference: ClassReference, ): TypeSpec { val superclass = factoryReference.asClassName() @@ -217,7 +219,7 @@ internal class ContributesSubcomponentHandlerGenerator( } private fun generateDaggerModule( - factoryReference: ClassReference + factoryReference: ClassReference, ): TypeSpec { // This Dagger module will allow injecting the factory instance. return TypeSpec @@ -231,7 +233,7 @@ internal class ContributesSubcomponentHandlerGenerator( .addModifiers(ABSTRACT) .addParameter("factory", ClassName.bestGuess(SUBCOMPONENT_FACTORY)) .returns(factoryReference.asClassName()) - .build() + .build(), ) .build() } @@ -242,7 +244,8 @@ internal class ContributesSubcomponentHandlerGenerator( factoryClass: FactoryClassHolder?, ): TypeSpec { val parentComponentInterface = findParentComponentInterface( - contribution, factoryClass?.originalReference + contribution, + factoryClass?.originalReference, ) return TypeSpec @@ -258,7 +261,7 @@ internal class ContributesSubcomponentHandlerGenerator( name = parentComponentInterface ?.functionName ?: factoryClass?.let { "create${it.originalReference.fqName.shortName()}" } - ?: "create${generatedAnvilSubcomponent.relativeClassName}" + ?: "create${generatedAnvilSubcomponent.relativeClassName}", ) .addModifiers(ABSTRACT) .apply { @@ -272,14 +275,14 @@ internal class ContributesSubcomponentHandlerGenerator( returns(generatedAnvilSubcomponent.asClassName()) } } - .build() + .build(), ) .build() } private fun findParentComponentInterface( contribution: Contribution, - factoryClass: ClassReference? + factoryClass: ClassReference?, ): ParentComponentInterfaceHolder? { val contributedInnerComponentInterfaces = contribution.clazz .innerClasses() @@ -298,7 +301,7 @@ internal class ContributesSubcomponentHandlerGenerator( else -> throw AnvilCompilationExceptionClassReference( classReference = contribution.clazz, message = "Expected zero or one parent component interface within " + - "${contribution.clazz.fqName} being contributed to the parent scope." + "${contribution.clazz.fqName} being contributed to the parent scope.", ) } @@ -315,7 +318,7 @@ internal class ContributesSubcomponentHandlerGenerator( else -> throw AnvilCompilationExceptionClassReference( classReference = contribution.clazz, message = "Expected zero or one function returning the " + - "subcomponent ${contribution.clazz.fqName}." + "subcomponent ${contribution.clazz.fqName}.", ) } @@ -324,7 +327,7 @@ internal class ContributesSubcomponentHandlerGenerator( private fun findFactoryClass( contribution: Contribution, - generatedAnvilSubcomponent: ClassId + generatedAnvilSubcomponent: ClassId, ): FactoryClassHolder? { val contributionFqName = contribution.clazz.fqName @@ -337,7 +340,7 @@ internal class ContributesSubcomponentHandlerGenerator( if (!factory.isInterface() && !factory.isAbstract()) { throw AnvilCompilationExceptionClassReference( classReference = factory, - message = "A factory must be an interface or an abstract class." + message = "A factory must be an interface or an abstract class.", ) } @@ -349,7 +352,7 @@ internal class ContributesSubcomponentHandlerGenerator( throw AnvilCompilationExceptionClassReference( classReference = factory, message = "A factory must have exactly one abstract function returning the " + - "subcomponent $contributionFqName." + "subcomponent $contributionFqName.", ) } } @@ -360,7 +363,7 @@ internal class ContributesSubcomponentHandlerGenerator( 1 -> contributedFactories[0] else -> throw AnvilCompilationExceptionClassReference( classReference = contribution.clazz, - message = "Expected zero or one factory within $contributionFqName." + message = "Expected zero or one factory within $contributionFqName.", ) } @@ -368,13 +371,13 @@ internal class ContributesSubcomponentHandlerGenerator( originalReference = classReference, generatedFactoryName = generatedAnvilSubcomponent .createNestedClassId(Name.identifier(SUBCOMPONENT_FACTORY)) - .asClassName() + .asClassName(), ) } private fun checkReplacedSubcomponentWasNotAlreadyGenerated( contributedReference: ClassReference, - replacedReferences: List + replacedReferences: List, ) { replacedReferences.forEach { replacedReference -> if (processedEvents.any { it.contribution.clazz == replacedReference }) { @@ -382,14 +385,14 @@ internal class ContributesSubcomponentHandlerGenerator( classReference = contributedReference, message = "${contributedReference.fqName} tries to replace " + "${replacedReference.fqName}, but the code for ${replacedReference.fqName} was " + - "already generated. This is not supported." + "already generated. This is not supported.", ) } } } private fun populateInitialContributions( - module: ModuleDescriptor + module: ModuleDescriptor, ) { // Find all contributed subcomponents from precompiled dependencies and generate the // necessary code eventually if there's a trigger. @@ -397,11 +400,11 @@ internal class ContributesSubcomponentHandlerGenerator( .findContributedClasses( module = module, annotation = contributesSubcomponentFqName, - scope = null + scope = null, ) .map { clazz -> Contribution( - annotation = clazz.annotations.single { it.fqName == contributesSubcomponentFqName } + annotation = clazz.annotations.single { it.fqName == contributesSubcomponentFqName }, ) } @@ -426,7 +429,7 @@ internal class ContributesSubcomponentHandlerGenerator( } private class Trigger( - annotation: AnnotationReference + annotation: AnnotationReference, ) { val clazz = annotation.declaringClass() val scope = annotation.scope() @@ -457,7 +460,7 @@ internal class ContributesSubcomponentHandlerGenerator( } private class Contribution( - val annotation: AnnotationReference + val annotation: AnnotationReference, ) { val clazz = annotation.declaringClass() val scope = annotation.scope() @@ -490,7 +493,7 @@ internal class ContributesSubcomponentHandlerGenerator( private data class GenerateCodeEvent( val trigger: Trigger, - val contribution: Contribution + val contribution: Contribution, ) { val generatedAnvilSubcomponent = contribution.clazz.classId .generatedAnvilSubcomponent(trigger.clazz.classId) @@ -498,7 +501,7 @@ internal class ContributesSubcomponentHandlerGenerator( private class ParentComponentInterfaceHolder( componentInterface: ClassReference, - function: MemberFunctionReference + function: MemberFunctionReference, ) { val componentInterface = componentInterface.asClassName() val functionName = function.fqName.shortName().asString() @@ -506,7 +509,7 @@ internal class ContributesSubcomponentHandlerGenerator( private class FactoryClassHolder( val originalReference: ClassReference, - val generatedFactoryName: ClassName + val generatedFactoryName: ClassName, ) } 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 a2d85aa87..8843f7a35 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 @@ -72,11 +72,11 @@ internal object ContributesToCodeGen : AnvilApplicabilityChecker { PropertySpec .builder( name = propertyName + REFERENCE_SUFFIX, - type = KClass::class.asClassName().parameterizedBy(className) + type = KClass::class.asClassName().parameterizedBy(className), ) .initializer("%T::class", className) .addModifiers(PUBLIC) - .build() + .build(), ) scopes.forEachIndexed { index, scope -> @@ -84,11 +84,11 @@ internal object ContributesToCodeGen : AnvilApplicabilityChecker { PropertySpec .builder( name = propertyName + SCOPE_SUFFIX + index, - type = KClass::class.asClassName().parameterizedBy(scope) + type = KClass::class.asClassName().parameterizedBy(scope), ) .initializer("%T::class", scope) .addModifiers(PUBLIC) - .build() + .build(), ) } } @@ -157,7 +157,7 @@ internal object ContributesToCodeGen : AnvilApplicabilityChecker { override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { return projectFiles .classAndInnerClassReferences(module) @@ -197,7 +197,7 @@ internal object ContributesToCodeGen : AnvilApplicabilityChecker { codeGenDir = codeGenDir, packageName = spec.packageName, fileName = spec.name, - content = spec.toString() + content = spec.toString(), ) } .toList() diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/FlushingCodeGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/FlushingCodeGenerator.kt index 283576658..745269cbb 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/FlushingCodeGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/FlushingCodeGenerator.kt @@ -15,6 +15,6 @@ internal interface FlushingCodeGenerator : CodeGenerator { */ fun flush( codeGenDir: File, - module: ModuleDescriptor + module: ModuleDescriptor, ): Collection = emptyList() } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/MergeAnnotationsCheckGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/MergeAnnotationsCheckGenerator.kt index 0ce8a49eb..031a571f6 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/MergeAnnotationsCheckGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/MergeAnnotationsCheckGenerator.kt @@ -21,7 +21,7 @@ internal class MergeAnnotationsCheckGenerator : PrivateCodeGenerator() { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { projectFiles .classAndInnerClassReferences(module) @@ -31,7 +31,7 @@ internal class MergeAnnotationsCheckGenerator : PrivateCodeGenerator() { mergeComponentFqName, mergeSubcomponentFqName, mergeModulesFqName, - mergeInterfacesFqName + mergeInterfacesFqName, ) .ifEmpty { return@forEach } @@ -58,7 +58,7 @@ internal class MergeAnnotationsCheckGenerator : PrivateCodeGenerator() { distinctAnnotations.joinToString(prefix = "[", postfix = "]") { it.fqName.shortName().asString() } + - " and this is forbidden." + " and this is forbidden.", ) } } @@ -69,7 +69,7 @@ internal class MergeAnnotationsCheckGenerator : PrivateCodeGenerator() { classReference = declaringClass(), message = "When using @${fqName.shortName()} it's not allowed to " + "annotate the same class with @${daggerAnnotationFqName.shortName()}. " + - "The Dagger annotation will be generated." + "The Dagger annotation will be generated.", ) } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/PrivateCodeGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/PrivateCodeGenerator.kt index efb95033c..5a66a502f 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/PrivateCodeGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/PrivateCodeGenerator.kt @@ -16,7 +16,7 @@ internal abstract class PrivateCodeGenerator : CodeGenerator { final override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { generateCodePrivate(codeGenDir, module, projectFiles) return emptyList() @@ -25,6 +25,6 @@ internal abstract class PrivateCodeGenerator : CodeGenerator { protected abstract fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/RealAnvilContext.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/RealAnvilContext.kt index 27fe2c7ac..b0c1e87a8 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/RealAnvilContext.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/RealAnvilContext.kt @@ -12,26 +12,26 @@ internal data class RealAnvilContext( override val generateFactories: Boolean, override val generateFactoriesOnly: Boolean, override val disableComponentMerging: Boolean, - val nullableModule: ModuleDescriptor? + val nullableModule: ModuleDescriptor?, ) : AnvilContext { override val module: ModuleDescriptor get() = nullableModule ?: error("Module is not available in KSP.") } internal fun CommandLineOptions.toAnvilContext( - module: ModuleDescriptor + module: ModuleDescriptor, ): RealAnvilContext = RealAnvilContext( generateFactories = generateFactories, generateFactoriesOnly = generateFactoriesOnly, disableComponentMerging = disableComponentMerging, - nullableModule = module + nullableModule = module, ) internal fun SymbolProcessorEnvironment.toAnvilContext(): AnvilContext = RealAnvilContext( generateFactories = options.booleanOption(generateDaggerFactoriesName), generateFactoriesOnly = options.booleanOption(generateDaggerFactoriesOnlyName), disableComponentMerging = options.booleanOption(disableComponentMergingName), - nullableModule = null + nullableModule = null, ) private fun Map.booleanOption(key: String, default: Boolean = false): Boolean { 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 c5bd666c8..d89fbc4d0 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 @@ -38,7 +38,7 @@ internal object AnvilAnnotationDetectorCheck : AnvilApplicabilityChecker { mergeModulesFqName, contributesToFqName, contributesSubcomponentFqName, - contributesBindingFqName + contributesBindingFqName, ) override fun isApplicable(context: AnvilContext) = context.generateFactoriesOnly && @@ -60,7 +60,7 @@ internal object AnvilAnnotationDetectorCheck : AnvilApplicabilityChecker { throw KspAnvilException( message = MESSAGE, - node = clazz + node = clazz, ) } } @@ -74,7 +74,7 @@ internal object AnvilAnnotationDetectorCheck : AnvilApplicabilityChecker { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { val clazz = projectFiles .classAndInnerClassReferences(module) @@ -85,7 +85,7 @@ internal object AnvilAnnotationDetectorCheck : AnvilApplicabilityChecker { if (clazz != null) { throw AnvilCompilationExceptionClassReference( message = MESSAGE, - classReference = clazz + classReference = clazz, ) } } 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 a19db36de..3d00cf885 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 @@ -30,8 +30,9 @@ internal object AnvilMergeAnnotationDetectorCheck : AnvilApplicabilityChecker { mergeComponentFqName, mergeSubcomponentFqName, mergeInterfacesFqName, - mergeModulesFqName + mergeModulesFqName, ) + override fun isApplicable(context: AnvilContext) = context.disableComponentMerging internal class KspGenerator( @@ -51,7 +52,7 @@ internal object AnvilMergeAnnotationDetectorCheck : AnvilApplicabilityChecker { throw KspAnvilException( message = MESSAGE, - node = clazz + node = clazz, ) } } @@ -65,19 +66,18 @@ internal object AnvilMergeAnnotationDetectorCheck : AnvilApplicabilityChecker { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { val clazz = projectFiles .classAndInnerClassReferences(module) - .firstOrNull { - clazz -> + .firstOrNull { clazz -> ANNOTATIONS_TO_CHECK.any { clazz.isAnnotatedWith(it) } } if (clazz != null) { throw AnvilCompilationExceptionClassReference( message = MESSAGE, - classReference = clazz + classReference = clazz, ) } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedFactoryGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedFactoryGenerator.kt index 1d5a62813..0232785c8 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedFactoryGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedFactoryGenerator.kt @@ -50,7 +50,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { projectFiles .classAndInnerClassReferences(module) @@ -62,7 +62,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { private fun generateFactoryClass( codeGenDir: File, - clazz: ClassReference.Psi + clazz: ClassReference.Psi, ): GeneratedFile { val packageName = clazz.packageFqName.safePackageString() val delegateFactoryName = "delegateFactory" @@ -77,7 +77,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { message = "Invalid return type: ${clazz.fqName}. An assisted factory's " + "abstract method must return a type with an @AssistedInject-annotated constructor.", functionReference = function.function, - cause = e + cause = e, ) } @@ -88,7 +88,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { ?: throw AnvilCompilationExceptionClassReference( message = "Invalid return type: ${returnType.fqName}. An assisted factory's abstract " + "method must return a type with an @AssistedInject-annotated constructor.", - classReference = clazz + classReference = clazz, ) val functionParameters = function.parameterKeys @@ -101,7 +101,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { throw AnvilCompilationExceptionClassReference( message = "The parameters in the factory method must match the @Assisted parameters in " + "${returnType.fqName}.", - classReference = clazz + classReference = clazz, ) } @@ -128,7 +128,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { } append(key.typeName) }, - classReference = clazz + classReference = clazz, ) } @@ -144,7 +144,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { throw AnvilCompilationExceptionClassReference( message = "The parameters in the factory method must match the @Assisted parameters in " + "${returnType.fqName}.", - classReference = clazz + classReference = clazz, ) } @@ -178,14 +178,14 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { primaryConstructor( FunSpec.constructorBuilder() .addParameter(delegateFactoryName, generatedFactoryTypeName) - .build() + .build(), ) addProperty( PropertySpec.builder(delegateFactoryName, generatedFactoryTypeName) .initializer(delegateFactoryName) .addModifiers(PRIVATE) - .build() + .build(), ) } .addFunction( @@ -213,7 +213,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { addStatement("return $delegateFactoryName.get($argumentList)") } - .build() + .build(), ) .apply { TypeSpec.companionObjectBuilder() @@ -226,9 +226,9 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { .addStatement( "return %T.create(%T($delegateFactoryName))", InstanceFactory::class, - implParameterizedTypeName + implParameterizedTypeName, ) - .build() + .build(), ) .build() .let { @@ -264,7 +264,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { 0 -> throw AnvilCompilationExceptionClassReference( message = "The @AssistedFactory-annotated type is missing an abstract, non-default " + "method whose return type matches the assisted injection type.", - classReference = this + classReference = this, ) 1 -> assistedFunctions[0] else -> { @@ -276,7 +276,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { throw AnvilCompilationExceptionClassReference( message = "The @AssistedFactory-annotated type should contain a single abstract, " + "non-default method but found multiple: [$foundFunctions]", - classReference = this + classReference = this, ) } } @@ -291,16 +291,16 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { /** * Pair of parameter reference to parameter type. */ - val parameterPairs: List> + val parameterPairs: List>, ) { companion object { fun MemberFunctionReference.toAssistedFactoryFunction( - factoryClass: ClassReference.Psi + factoryClass: ClassReference.Psi, ): AssistedFactoryFunction { return AssistedFactoryFunction( function = this, parameterKeys = parameters.map { it.toAssistedParameterKey(factoryClass) }, - parameterPairs = parameters.map { it to it.resolveTypeName(factoryClass) } + parameterPairs = parameters.map { it to it.resolveTypeName(factoryClass) }, ) } } @@ -312,7 +312,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { // @Assisted("...") annotation. For each parameter the key must be unique. private data class AssistedParameterKey( val typeName: TypeName, - val identifier: String + val identifier: String, ) { // Key value is similar to a hash function. There used to be a special case for KotlinTypes @@ -322,7 +322,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { companion object { fun ParameterReference.toAssistedParameterKey( - factoryClass: ClassReference.Psi + factoryClass: ClassReference.Psi, ): AssistedParameterKey { return AssistedParameterKey( typeName = resolveTypeName(factoryClass), @@ -331,7 +331,7 @@ internal class AssistedFactoryGenerator : PrivateCodeGenerator() { ?.let { annotation -> annotation.argumentAt("value", index = 0)?.value() } - .orEmpty() + .orEmpty(), ) } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedInjectGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedInjectGenerator.kt index 1a31f14a8..23a886c96 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedInjectGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/AssistedInjectGenerator.kt @@ -45,7 +45,7 @@ internal class AssistedInjectGenerator : PrivateCodeGenerator() { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { projectFiles .classAndInnerClassReferences(module) @@ -62,7 +62,7 @@ internal class AssistedInjectGenerator : PrivateCodeGenerator() { private fun generateFactoryClass( codeGenDir: File, clazz: ClassReference.Psi, - constructor: MemberFunctionReference.Psi + constructor: MemberFunctionReference.Psi, ): GeneratedFile { val packageName = clazz.packageFqName.safePackageString() val classIdName = clazz.generateClassName(suffix = "_Factory") @@ -95,7 +95,7 @@ internal class AssistedInjectGenerator : PrivateCodeGenerator() { addParameter(parameter.name, parameter.providerTypeName) } } - .build() + .build(), ) parametersNotAssisted.forEach { parameter -> @@ -103,7 +103,7 @@ internal class AssistedInjectGenerator : PrivateCodeGenerator() { PropertySpec.builder(parameter.name, parameter.providerTypeName) .initializer(parameter.name) .addModifiers(PRIVATE) - .build() + .build(), ) } } @@ -117,7 +117,7 @@ internal class AssistedInjectGenerator : PrivateCodeGenerator() { val argumentList = constructorParameters.asArgumentList( asProvider = true, - includeModule = false + includeModule = false, ) if (memberInjectParameters.isEmpty()) { @@ -129,7 +129,7 @@ internal class AssistedInjectGenerator : PrivateCodeGenerator() { addStatement("return $instanceName") } } - .build() + .build(), ) .apply { TypeSpec.companionObjectBuilder() @@ -146,16 +146,16 @@ internal class AssistedInjectGenerator : PrivateCodeGenerator() { val argumentList = parametersNotAssisted.asArgumentList( asProvider = false, - includeModule = false + includeModule = false, ) addStatement( "return %T($argumentList)", - factoryClassParameterized + factoryClassParameterized, ) } .returns(factoryClassParameterized) - .build() + .build(), ) .addFunction( FunSpec.builder("newInstance") @@ -167,7 +167,7 @@ internal class AssistedInjectGenerator : PrivateCodeGenerator() { constructorParameters.forEach { parameter -> addParameter( name = parameter.name, - type = parameter.originalTypeName + type = parameter.originalTypeName, ) } val argumentsWithoutModule = constructorParameters.joinToString { it.name } @@ -175,7 +175,7 @@ internal class AssistedInjectGenerator : PrivateCodeGenerator() { addStatement("return %T($argumentsWithoutModule)", classType) } .returns(classType) - .build() + .build(), ) .build() .let { @@ -191,7 +191,7 @@ internal class AssistedInjectGenerator : PrivateCodeGenerator() { private fun checkAssistedParametersAreDistinct( clazz: ClassReference, - parameters: List + parameters: List, ) { // Parameters are identical, if there types and identifier match. val duplicateAssistedParameters = parameters 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 683c57f31..558ba1ec3 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 @@ -32,7 +32,7 @@ internal class BindsMethodValidator : PrivateCodeGenerator() { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { projectFiles .classAndInnerClassReferences(module) @@ -55,7 +55,7 @@ internal class BindsMethodValidator : PrivateCodeGenerator() { if (!function.isAbstract()) { throw AnvilCompilationExceptionFunctionReference( message = "@Binds methods must be abstract", - functionReference = function + functionReference = function, ) } @@ -66,13 +66,13 @@ internal class BindsMethodValidator : PrivateCodeGenerator() { throw AnvilCompilationExceptionFunctionReference( message = "@Binds methods must have exactly one parameter, " + "whose type is assignable to the return type", - functionReference = function + functionReference = function, ) } function.returnTypeOrNull() ?: throw AnvilCompilationExceptionFunctionReference( message = "@Binds methods must return a value (not void)", - functionReference = function + functionReference = function, ) if (!function.parameterMatchesReturnType() && !function.receiverMatchesReturnType()) { @@ -90,7 +90,7 @@ internal class BindsMethodValidator : PrivateCodeGenerator() { message = "@Binds methods' parameter type must be assignable to the return type. " + "Expected binding of type $returnType but impl parameter of type " + "${paramSuperTypes.first()} $superTypesMessage", - functionReference = function + functionReference = function, ) } } 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 9caa25f58..43195509b 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 @@ -53,18 +53,17 @@ internal object ComponentDetectorCheck : AnvilApplicabilityChecker { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { val clazz = - projectFiles.classAndInnerClassReferences(module).firstOrNull { - clazz -> + projectFiles.classAndInnerClassReferences(module).firstOrNull { clazz -> ANNOTATIONS_TO_CHECK.any { clazz.isAnnotatedWith(it) } } if (clazz != null) { throw AnvilCompilationExceptionClassReference( message = MESSAGE, - classReference = clazz + classReference = clazz, ) } } 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 dc4a7420b..6b16dca5d 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 @@ -46,7 +46,7 @@ internal fun List.mapToConstructorParameters(): List, - instanceName: String + instanceName: String, ): FunSpec.Builder = apply { memberInjectParameters.forEach { parameter -> @@ -133,7 +133,7 @@ internal fun ClassReference.memberInjectParameters(): List, - implementingClass: ClassReference + implementingClass: ClassReference, ): List { return properties .filter { it.isAnnotatedWith(injectFqName) } @@ -142,7 +142,7 @@ private fun ClassReference.declaredMemberInjectParameters( val uniqueName = property.name.uniqueParameterName(superParameters, acc) acc + property.toMemberInjectParameter( uniqueName = uniqueName, - implementingClass = implementingClass + implementingClass = implementingClass, ) } } @@ -163,7 +163,7 @@ private fun ClassReference.declaredMemberInjectParameters( */ internal fun List.asArgumentList( asProvider: Boolean, - includeModule: Boolean + includeModule: Boolean, ): String { return this .let { list -> @@ -183,7 +183,9 @@ internal fun List.asArgumentList( else -> "${parameter.name}.get()" } } - } else list.map { it.name } + } else { + list.map { it.name } + } } .let { if (includeModule) { @@ -199,7 +201,7 @@ internal fun List.asArgumentList( private fun MemberPropertyReference.toMemberInjectParameter( uniqueName: String, - implementingClass: ClassReference + implementingClass: ClassReference, ): MemberInjectParameter { if ( !isLateinit() && @@ -211,7 +213,7 @@ private fun MemberPropertyReference.toMemberInjectParameter( throw AnvilCompilationExceptionPropertyReference( propertyReference = this, message = "Dagger does not support injection into private fields. Either use a " + - "'lateinit var' or '@JvmField'." + "'lateinit var' or '@JvmField'.", ) } @@ -235,7 +237,7 @@ private fun MemberPropertyReference.toMemberInjectParameter( ?.optionallyParameterizedByNames( unwrappedType.unwrappedTypes.mapNotNull { it.resolveGenericTypeNameOrNull(implementingClass) - } + }, ) ?.withJvmSuppressWildcardsIfNeeded(this, unwrappedType) } else { @@ -255,7 +257,8 @@ private fun MemberPropertyReference.toMemberInjectParameter( .asString() val memberInjectorClass = ClassName( - declaringClass.packageFqName.asString(), memberInjectorClassName + declaringClass.packageFqName.asString(), + memberInjectorClassName, ) val isSetterInjected = this.setterAnnotations.any { it.fqName == injectFqName } @@ -289,7 +292,7 @@ private fun MemberPropertyReference.toMemberInjectParameter( accessName = accessName, qualifierAnnotationSpecs = qualifierAnnotations, injectedFieldSignature = fqName, - resolvedProviderTypeName = resolvedTypeName?.wrapInProvider() ?: providerTypeName + resolvedProviderTypeName = resolvedTypeName?.wrapInProvider() ?: providerTypeName, ) } @@ -300,7 +303,7 @@ private fun TypeReference.isGenericExcludingTypeAliases(): Boolean { } private fun ClassName.optionallyParameterizedByNames( - typeNames: List + typeNames: List, ): TypeName { return if (typeNames.isEmpty()) { this @@ -310,7 +313,7 @@ private fun ClassName.optionallyParameterizedByNames( } internal fun ClassName.optionallyParameterizedBy( - typeParameters: List + typeParameters: List, ): TypeName { return if (typeParameters.isEmpty()) { this @@ -321,7 +324,7 @@ internal fun ClassName.optionallyParameterizedBy( internal fun assertNoDuplicateFunctions( declaringClass: ClassReference, - functions: Sequence + functions: Sequence, ) { // Check for duplicate function names. val duplicateFunctions = functions @@ -332,7 +335,7 @@ internal fun assertNoDuplicateFunctions( throw AnvilCompilationExceptionClassReference( classReference = declaringClass, message = "Cannot have more than one binding method with the same name in " + - "a single module: ${duplicateFunctions.keys.joinToString()}" + "a single module: ${duplicateFunctions.keys.joinToString()}", ) } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt index 8f6afcb0c..5378072a5 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/InjectConstructorFactoryGenerator.kt @@ -38,7 +38,7 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { projectFiles .classAndInnerClassReferences(module) @@ -55,7 +55,7 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() { private fun generateFactoryClass( codeGenDir: File, clazz: ClassReference.Psi, - constructor: MemberFunctionReference.Psi + constructor: MemberFunctionReference.Psi, ): GeneratedFile { val classId = clazz.generateClassName(suffix = "_Factory") @@ -93,7 +93,7 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() { addParameter(parameter.name, parameter.providerTypeName) } } - .build() + .build(), ) allParameters.forEach { parameter -> @@ -101,7 +101,7 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() { PropertySpec.builder(parameter.name, parameter.providerTypeName) .initializer(parameter.name) .addModifiers(PRIVATE) - .build() + .build(), ) } } @@ -113,7 +113,7 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() { .apply { val newInstanceArgumentList = constructorParameters.asArgumentList( asProvider = true, - includeModule = false + includeModule = false, ) if (memberInjectParameters.isEmpty()) { @@ -125,7 +125,7 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() { addStatement("return $instanceName") } } - .build() + .build(), ) .apply { val builder = if (canGenerateAnObject) this else TypeSpec.companionObjectBuilder() @@ -146,17 +146,17 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() { val argumentList = allParameters.asArgumentList( asProvider = false, - includeModule = false + includeModule = false, ) addStatement( "return %T($argumentList)", - factoryClassParameterized + factoryClassParameterized, ) } } .returns(factoryClassParameterized) - .build() + .build(), ) .addFunction( FunSpec.builder("newInstance") @@ -168,7 +168,7 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() { constructorParameters.forEach { parameter -> addParameter( name = parameter.name, - type = parameter.originalTypeName + type = parameter.originalTypeName, ) } val argumentsWithoutModule = constructorParameters.joinToString { it.name } @@ -176,7 +176,7 @@ internal class InjectConstructorFactoryGenerator : PrivateCodeGenerator() { addStatement("return %T($argumentsWithoutModule)", classType) } .returns(classType) - .build() + .build(), ) .build() .let { diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MapKeyCreatorGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MapKeyCreatorGenerator.kt index 0a7637572..c3e2e9283 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MapKeyCreatorGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MapKeyCreatorGenerator.kt @@ -63,7 +63,7 @@ internal class MapKeyCreatorGenerator : PrivateCodeGenerator() { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { projectFiles .classAndInnerClassReferences(module) @@ -82,7 +82,7 @@ internal class MapKeyCreatorGenerator : PrivateCodeGenerator() { private fun generateCreatorClass( codeGenDir: File, - clazz: ClassReference + clazz: ClassReference, ): GeneratedFile { // // Given this // @MapKey(unwrapValue = false) @@ -107,7 +107,7 @@ internal class MapKeyCreatorGenerator : PrivateCodeGenerator() { if (!clazz.isAnnotationClass()) { throw AnvilCompilationExceptionClassReference( message = "@MapKey is only applicable to annotation classes.", - classReference = clazz + classReference = clazz, ) } @@ -137,7 +137,7 @@ internal class MapKeyCreatorGenerator : PrivateCodeGenerator() { annotationClass.asTypeName().rawTypeOrNull() ?: throw AnvilCompilationExceptionClassReference( message = "@MapKey is only applicable to non-generic annotation classes.", - classReference = annotationClass + classReference = annotationClass, ) } .toSortedMap() @@ -149,7 +149,7 @@ internal class MapKeyCreatorGenerator : PrivateCodeGenerator() { addType( TypeSpec.objectBuilder(generatedClassName) .addFunctions(creatorFunctions) - .build() + .build(), ) } @@ -176,7 +176,7 @@ internal class MapKeyCreatorGenerator : PrivateCodeGenerator() { .addStatement( "return %T(%L)", className, - properties.entries.map { it.value.callExpression }.joinToCode() + properties.entries.map { it.value.callExpression }.joinToCode(), ) .returns(className) .build() @@ -186,11 +186,11 @@ internal class MapKeyCreatorGenerator : PrivateCodeGenerator() { private class AnnotationProperty( val name: String, val javaType: TypeName, - val callExpression: CodeBlock + val callExpression: CodeBlock, ) { companion object { operator fun invoke( - property: MemberPropertyReference + property: MemberPropertyReference, ): AnnotationProperty { val name = property.name val typeName = property.type().asTypeName() @@ -209,7 +209,7 @@ private class AnnotationProperty( return AnnotationProperty( name, javaType, - codeBlock + codeBlock, ) } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt index 21b506be1..58603651d 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/MembersInjectorGenerator.kt @@ -40,7 +40,7 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { projectFiles .classAndInnerClassReferences(module) @@ -57,7 +57,7 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() { generateMembersInjectorClass( codeGenDir = codeGenDir, clazz = clazz, - parameters = clazz.memberInjectParameters() + parameters = clazz.memberInjectParameters(), ) } } @@ -65,7 +65,7 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() { private fun generateMembersInjectorClass( codeGenDir: File, clazz: ClassReference.Psi, - parameters: List + parameters: List, ): GeneratedFile { val classId = clazz.generateClassName(suffix = "_MembersInjector") val packageName = classId.packageFqName.safePackageString() @@ -110,7 +110,7 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() { addParameter(parameter.name, parameter.resolvedProviderTypeName) } } - .build() + .build(), ) parameters.forEach { parameter -> @@ -118,7 +118,7 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() { PropertySpec.builder(parameter.name, parameter.resolvedProviderTypeName) .initializer(parameter.name) .addModifiers(PRIVATE) - .build() + .build(), ) } } @@ -127,7 +127,7 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() { .addModifiers(OVERRIDE) .addParameter("instance", classType) .addMemberInjection(parameters, "instance") - .build() + .build(), ) .addType( TypeSpec @@ -146,11 +146,11 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() { addStatement( "return %T(${createArgumentList(false)})", - memberInjectorClass + memberInjectorClass, ) } .returns(membersInjectorType) - .build() + .build(), ) .apply { parameters @@ -173,7 +173,7 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() { addAnnotation( AnnotationSpec.builder(InjectedFieldSignature::class) .addMember("%S", parameter.injectedFieldSignature) - .build() + .build(), ) } } @@ -181,13 +181,13 @@ internal class MembersInjectorGenerator : PrivateCodeGenerator() { .addParameter("instance", classType) .addParameter(name, parameter.originalTypeName) .addStatement("instance.${parameter.originalName} = $name") - .build() + .build(), ) } } - .build() + .build(), ) - .build() + .build(), ) } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/Parameter.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/Parameter.kt index 963def43f..41f229aa3 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/Parameter.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/Parameter.kt @@ -24,7 +24,7 @@ sealed interface Parameter { // diffing the parameters easier. data class AssistedParameterKey( private val typeName: TypeName, - private val assistedIdentifier: String + private val assistedIdentifier: String, ) val originalTypeName: TypeName @@ -48,7 +48,7 @@ sealed interface Parameter { * unique parameter names will be [foo, foo2, foo3]. */ internal fun String.uniqueParameterName( - vararg superParameters: List + vararg superParameters: List, ): String { val numDuplicates = superParameters.sumOf { list -> @@ -75,8 +75,8 @@ internal data class ConstructorParameter( override val assistedIdentifier: String, override val assistedParameterKey: AssistedParameterKey = AssistedParameterKey( typeName, - assistedIdentifier - ) + assistedIdentifier, + ), ) : Parameter internal data class MemberInjectParameter( @@ -97,7 +97,7 @@ internal data class MemberInjectParameter( val injectedFieldSignature: FqName, override val assistedParameterKey: AssistedParameterKey = AssistedParameterKey( typeName, - assistedIdentifier + assistedIdentifier, ), - val resolvedProviderTypeName: ParameterizedTypeName = providerTypeName + val resolvedProviderTypeName: ParameterizedTypeName = providerTypeName, ) : Parameter diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt index e3bbd2a1a..9b5a06615 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryGenerator.kt @@ -50,7 +50,7 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { override fun generateCodePrivate( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ) { projectFiles .classAndInnerClassReferences(module) @@ -71,7 +71,7 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { codeGenDir, module, clazz, - CallableReference(function = function) + CallableReference(function = function), ) } @@ -89,7 +89,7 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { codeGenDir, module, clazz, - CallableReference(property = property) + CallableReference(property = property), ) } } @@ -99,7 +99,7 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { codeGenDir: File, module: ModuleDescriptor, clazz: ClassReference.Psi, - declaration: CallableReference + declaration: CallableReference, ): GeneratedFile { val isCompanionObject = declaration.declaringClass.isCompanion() val isObject = isCompanionObject || clazz.isObject() @@ -169,7 +169,7 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { addParameter(parameter.name, parameter.providerTypeName) } } - .build() + .build(), ) if (!isObject) { @@ -177,7 +177,7 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { PropertySpec.builder("module", moduleClass) .initializer("module") .addModifiers(PRIVATE) - .build() + .build(), ) } @@ -186,7 +186,7 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { PropertySpec.builder(parameter.name, parameter.providerTypeName) .initializer(parameter.name) .addModifiers(PRIVATE) - .build() + .build(), ) } } @@ -198,11 +198,11 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { .apply { val argumentList = parameters.asArgumentList( asProvider = true, - includeModule = !isObject + includeModule = !isObject, ) addStatement("return %N($argumentList)", byteCodeFunctionName) } - .build() + .build(), ) .apply { val builder = if (canGenerateAnObject) this else TypeSpec.companionObjectBuilder() @@ -223,14 +223,14 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { val argumentList = parameters.asArgumentList( asProvider = false, - includeModule = !isObject + includeModule = !isObject, ) addStatement("return %T($argumentList)", factoryClass) } } .returns(factoryClass) - .build() + .build(), ) .addFunction( FunSpec.builder(byteCodeFunctionName) @@ -243,7 +243,7 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { parameters.forEach { parameter -> addParameter( name = parameter.name, - type = parameter.originalTypeName + type = parameter.originalTypeName, ) } @@ -257,7 +257,7 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { isObject && returnTypeIsNullable -> addStatement( "return %T.$callableName$argumentsWithoutModule", - moduleClass + moduleClass, ) isObject && !returnTypeIsNullable -> addStatement( @@ -265,23 +265,23 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { "$argumentsWithoutModule, %S)", Preconditions::class, moduleClass, - "Cannot return null from a non-@Nullable @Provides method" + "Cannot return null from a non-@Nullable @Provides method", ) !isObject && returnTypeIsNullable -> addStatement( - "return module.$callableName$argumentsWithoutModule" + "return module.$callableName$argumentsWithoutModule", ) !isObject && !returnTypeIsNullable -> addStatement( "return %T.checkNotNull(module.$callableName" + "$argumentsWithoutModule, %S)", Preconditions::class, - "Cannot return null from a non-@Nullable @Provides method" + "Cannot return null from a non-@Nullable @Provides method", ) } } .returns(returnType) - .build() + .build(), ) .build() .let { @@ -299,11 +299,11 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { private fun checkFunctionIsNotAbstract( clazz: ClassReference.Psi, - function: MemberFunctionReference.Psi + function: MemberFunctionReference.Psi, ) { fun fail(): Nothing = throw AnvilCompilationExceptionFunctionReference( message = "@Provides methods cannot be abstract", - functionReference = function + functionReference = function, ) // If the function is abstract, then it's an error. @@ -332,14 +332,14 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { private class CallableReference( private val function: MemberFunctionReference.Psi? = null, - private val property: MemberPropertyReference.Psi? = null + private val property: MemberPropertyReference.Psi? = null, ) { init { if (function == null && property == null) { throw AnvilCompilationException( "Cannot create a CallableReference wrapper without a " + - "function OR a property" + "function OR a property", ) } } @@ -361,7 +361,7 @@ internal class ProvidesMethodFactoryGenerator : PrivateCodeGenerator() { it.returnTypeOrNull() ?: throw AnvilCompilationExceptionFunctionReference( message = "Dagger provider methods must specify the return type explicitly when using " + "Anvil. The return type cannot be inferred implicitly.", - functionReference = it + functionReference = it, ) } ?: property!!.type() val annotationReference: AnnotatedReference = function ?: property!! diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSAnnotationExtensions.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSAnnotationExtensions.kt index b9a008097..1497e8fc0 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSAnnotationExtensions.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSAnnotationExtensions.kt @@ -49,7 +49,7 @@ internal fun List.checkNoDuplicateScope( } internal fun List.checkNoDuplicateScopeAndBoundType( - annotatedType: KSClassDeclaration + annotatedType: KSClassDeclaration, ) { // Exit early to avoid allocating additional collections. if (size < 2) return @@ -75,7 +75,7 @@ internal fun List.checkNoDuplicateScopeAndBoundType( } + ". Contributing multiple times to the same scope with the same bound type is forbidden " + "and all scope - bound type combinations must be distinct.", - annotatedType + annotatedType, ) } } @@ -102,7 +102,7 @@ internal fun KSAnnotation.argumentAt( } private fun KSAnnotation.isTypeAnnotatedWith( - annotationFqName: FqName + annotationFqName: FqName, ): Boolean = annotationType.resolve() .declaration .isAnnotationPresent(annotationFqName.asString()) diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSClassDeclarationExtensions.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSClassDeclarationExtensions.kt index 24de770e3..72854ecea 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSClassDeclarationExtensions.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KSClassDeclarationExtensions.kt @@ -10,7 +10,7 @@ import com.squareup.anvil.compiler.contributesMultibindingFqName import org.jetbrains.kotlin.name.FqName internal fun KSClassDeclaration.checkNotMoreThanOneQualifier( - annotationFqName: FqName + annotationFqName: FqName, ) { val annotationsList = annotations.toList() // The class is annotated with @ContributesBinding, @ContributesMultibinding, or another Anvil annotation. @@ -22,7 +22,7 @@ internal fun KSClassDeclaration.checkNotMoreThanOneQualifier( throw KspAnvilException( message = "Classes annotated with @${annotationFqName.shortName()} may not use more " + "than one @Qualifier.", - node = this + node = this, ) } } @@ -48,14 +48,14 @@ internal fun KSClassDeclaration.checkNotMoreThanOneMapKey() { throw KspAnvilException( message = "Classes annotated with @${contributesMultibindingFqName.shortName()} may not " + "use more than one @MapKey.", - node = this + node = this, ) } } internal fun KSClassDeclaration.checkSingleSuperType( annotationFqName: FqName, - resolver: Resolver + resolver: Resolver, ) { // If the bound type exists, then you're allowed to have multiple super types. Without the bound // type there must be exactly one super type. @@ -70,14 +70,14 @@ internal fun KSClassDeclaration.checkSingleSuperType( "specify the bound type. This is only allowed with exactly one direct super type. " + "If there are multiple or none, then the bound type must be explicitly defined in " + "the @${annotationFqName.shortName()} annotation.", - node = this + node = this, ) } } internal fun KSClassDeclaration.checkClassExtendsBoundType( annotationFqName: FqName, - resolver: Resolver + resolver: Resolver, ) { val boundType = getKSAnnotationsByQualifiedName(annotationFqName.asString()) .firstOrNull() @@ -85,7 +85,7 @@ internal fun KSClassDeclaration.checkClassExtendsBoundType( ?: superTypesExcludingAny(resolver).singleOrNull()?.resolve() ?: throw KspAnvilException( message = "Couldn't find the bound type.", - node = this + node = this, ) // The boundType is declared explicitly in the annotation. Since all classes extend Any, we can @@ -97,13 +97,13 @@ internal fun KSClassDeclaration.checkClassExtendsBoundType( message = "${this.qualifiedName?.asString()} contributes a binding " + "for ${boundType.declaration.qualifiedName?.asString()}, but doesn't " + "extend this type.", - node = this + node = this, ) } } internal fun KSClassDeclaration.superTypesExcludingAny( - resolver: Resolver + resolver: Resolver, ): Sequence = superTypes .filterNot { it.resolve() == resolver.builtIns.anyType } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspAnvilException.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspAnvilException.kt index d6ab88a93..8a599a45f 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspAnvilException.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspAnvilException.kt @@ -5,5 +5,5 @@ import com.google.devtools.ksp.symbol.KSNode internal class KspAnvilException( override val message: String, val node: KSNode, - override val cause: Throwable? = null + override val cause: Throwable? = null, ) : Exception() diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspUtil.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspUtil.kt index 0865df1f4..42a7b81e1 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspUtil.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/ksp/KspUtil.kt @@ -8,12 +8,12 @@ import kotlin.reflect.KClass * Returns a sequence of [KSAnnotations][KSAnnotation] of the given [annotationKClass] type. */ internal fun KSAnnotated.getKSAnnotationsByType( - annotationKClass: KClass + annotationKClass: KClass, ): Sequence { return annotations.filter { it.shortName.getShortName() == annotationKClass.simpleName && it.annotationType.resolve() - .declaration.qualifiedName?.asString() == annotationKClass.qualifiedName + .declaration.qualifiedName?.asString() == annotationKClass.qualifiedName } } @@ -21,13 +21,13 @@ internal fun KSAnnotated.getKSAnnotationsByType( * Returns a sequence of [KSAnnotations][KSAnnotation] of the given [qualifiedName]. */ internal fun KSAnnotated.getKSAnnotationsByQualifiedName( - qualifiedName: String + qualifiedName: String, ): Sequence { val simpleName = qualifiedName.substringAfterLast(".") return annotations.filter { it.shortName.getShortName() == simpleName && it.annotationType.resolve() - .declaration.qualifiedName?.asString() == qualifiedName + .declaration.qualifiedName?.asString() == qualifiedName } } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotatedReferenceIr.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotatedReferenceIr.kt index 505d5f2d0..c007b72b3 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotatedReferenceIr.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotatedReferenceIr.kt @@ -11,7 +11,7 @@ internal interface AnnotatedReferenceIr { internal fun List.find( annotationName: FqName, - scopeName: FqName? = null + scopeName: FqName? = null, ): List { return filter { it.fqName == annotationName && (scopeName == null || it.scopeOrNull?.fqName == scopeName) @@ -20,7 +20,7 @@ internal fun List.find( internal fun List.findAll( vararg annotationNames: FqName, - scopeName: FqName? = null + scopeName: FqName? = null, ): List { return filter { it.fqName in annotationNames && (scopeName == null || it.scopeOrNull?.fqName == scopeName) diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationArgumentReferenceIr.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationArgumentReferenceIr.kt index ade7051f8..ecc98b450 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationArgumentReferenceIr.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationArgumentReferenceIr.kt @@ -11,7 +11,7 @@ import kotlin.LazyThreadSafetyMode.NONE internal class AnnotationArgumentReferenceIr( val argumentParameter: IrValueParameter, val argumentExpression: IrExpression, - val annotation: AnnotationReferenceIr + val annotation: AnnotationReferenceIr, ) { val name: String = argumentParameter.name.toString() @@ -64,11 +64,11 @@ internal class AnnotationArgumentReferenceIr( } internal fun Pair.toAnnotationArgumentReference( - annotation: AnnotationReferenceIr + annotation: AnnotationReferenceIr, ): AnnotationArgumentReferenceIr { return AnnotationArgumentReferenceIr( argumentParameter = this.first, argumentExpression = this.second, - annotation = annotation + annotation = annotation, ) } diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationReferenceIr.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationReferenceIr.kt index 1356fdddf..9d725a3dc 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationReferenceIr.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/AnnotationReferenceIr.kt @@ -12,7 +12,7 @@ import kotlin.LazyThreadSafetyMode.NONE internal class AnnotationReferenceIr( val annotation: IrConstructorCall, val classReference: ClassReferenceIr, - declaringClass: ClassReferenceIr? + declaringClass: ClassReferenceIr?, ) { val fqName: FqName get() = classReference.fqName @@ -27,7 +27,7 @@ internal class AnnotationReferenceIr( val scope: ClassReferenceIr get() = scopeOrNull ?: throw AnvilCompilationException( element = annotation, - message = "Couldn't find scope for $fqName." + message = "Couldn't find scope for $fqName.", ) val scopeOrNull: ClassReferenceIr? by lazy(NONE) { @@ -40,7 +40,7 @@ internal class AnnotationReferenceIr( val declaringClass: ClassReferenceIr = declaringClassOrNull ?: throw AnvilCompilationExceptionAnnotationReferenceIr( annotationReference = this, - message = "The declaring class was null, this means the annotation wasn't used on a class." + message = "The declaring class was null, this means the annotation wasn't used on a class.", ) val parentScope: ClassReferenceIr by lazy(NONE) { @@ -48,7 +48,7 @@ internal class AnnotationReferenceIr( context.referenceClass(it.classId)?.toClassReference(context) } ?: throw AnvilCompilationException( element = annotation, - message = "Couldn't find parent scope for $fqName." + message = "Couldn't find parent scope for $fqName.", ) } @@ -85,21 +85,21 @@ internal class AnnotationReferenceIr( internal fun IrConstructorCall.toAnnotationReference( context: IrPluginContext, - declaringClass: ClassReferenceIr? + declaringClass: ClassReferenceIr?, ) = AnnotationReferenceIr( annotation = this, classReference = this.symbol.owner.parentAsClass.symbol.toClassReference(context), - declaringClass = declaringClass + declaringClass = declaringClass, ) @Suppress("FunctionName") internal fun AnvilCompilationExceptionAnnotationReferenceIr( annotationReference: AnnotationReferenceIr, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException = AnvilCompilationException( element = annotationReference.annotation, message = message, - cause = cause + cause = cause, ) diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/ClassReferenceIr.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/ClassReferenceIr.kt index 42fd7d337..3eddd1a5a 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/ClassReferenceIr.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/ClassReferenceIr.kt @@ -21,7 +21,7 @@ import kotlin.LazyThreadSafetyMode.NONE internal class ClassReferenceIr( val clazz: IrClassSymbol, - val context: IrPluginContext + val context: IrPluginContext, ) : AnnotatedReferenceIr { val fqName: FqName = clazz.fqName val packageFqName: FqName? = clazz.owner.packageFqName @@ -51,7 +51,7 @@ internal class ClassReferenceIr( DescriptorVisibilities.PROTECTED -> PROTECTED else -> throw AnvilCompilationExceptionClassReferenceIr( this, - "Encountered an unsupported visibility ${clazz.owner.visibility.name} for class $fqName" + "Encountered an unsupported visibility ${clazz.owner.visibility.name} for class $fqName", ) } } @@ -85,9 +85,9 @@ internal fun IrClassSymbol.toClassReference(context: IrPluginContext) = internal fun AnvilCompilationExceptionClassReferenceIr( classReference: ClassReferenceIr, message: String, - cause: Throwable? = null + cause: Throwable? = null, ): AnvilCompilationException = AnvilCompilationException( element = classReference.clazz, message = message, - cause = cause + cause = cause, ) diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/RealAnvilModuleDescriptor.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/RealAnvilModuleDescriptor.kt index e8aa3037f..bb6ad6fef 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/RealAnvilModuleDescriptor.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/reference/RealAnvilModuleDescriptor.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classId import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe class RealAnvilModuleDescriptor private constructor( - delegate: ModuleDescriptor + delegate: ModuleDescriptor, ) : AnvilModuleDescriptor, ModuleDescriptor by delegate { private val ktFileToClassReferenceMap = mutableMapOf>() @@ -100,7 +100,7 @@ class RealAnvilModuleDescriptor private constructor( override fun resolveFqNameOrNull( fqName: FqName, - lookupLocation: LookupLocation + lookupLocation: LookupLocation, ): ClassDescriptor? { return resolveDescriptorCache.getOrPut(fqName) { // In the case of a typealias, we need to look up the original reference instead. @@ -125,7 +125,7 @@ class RealAnvilModuleDescriptor private constructor( classDescriptor = descriptor, message = "Couldn't find the classId for $fqNameSafe. Are we stuck in a loop while " + "resolving super types? Note that it's not supported to contribute an inner class to " + - "a scope that is merged in an outer class." + "a scope that is merged in an outer class.", ) Descriptor(descriptor, classId, this) } as Descriptor @@ -161,7 +161,7 @@ class RealAnvilModuleDescriptor private constructor( private data class ClassReferenceCacheKey( private val fqName: FqName, - private val type: Type + private val type: Type, ) { enum class Type { PSI, diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/InterfaceMergerRepeatableTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/InterfaceMergerRepeatableTest.kt index 92f4e0d3d..e3d996d93 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/InterfaceMergerRepeatableTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/InterfaceMergerRepeatableTest.kt @@ -13,7 +13,7 @@ import kotlin.reflect.KClass @RunWith(Parameterized::class) class InterfaceMergerRepeatableTest( - private val annotationClass: KClass<*> + private val annotationClass: KClass<*>, ) { private val annotation = "@${annotationClass.simpleName}" @@ -21,7 +21,8 @@ class InterfaceMergerRepeatableTest( companion object { @Parameters(name = "{0}") - @JvmStatic fun annotationClasses(): Collection { + @JvmStatic + fun annotationClasses(): Collection { return buildList { add(MergeComponent::class) if (isFullTestRun()) { @@ -42,12 +43,12 @@ class InterfaceMergerRepeatableTest( $annotation(Any::class) $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "com.squareup.test.ComponentInterface merges multiple times to the same scope: [Any]. " + - "Merging multiple times to the same scope is forbidden and all scopes must be distinct." + "Merging multiple times to the same scope is forbidden and all scopes must be distinct.", ) } } @@ -65,13 +66,13 @@ class InterfaceMergerRepeatableTest( @MergeComponent(Any::class) @MergeSubcomponent(Unit::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "It's only allowed to have one single type of @Merge* annotation, however multiple " + "instances of the same annotation are allowed. You mix " + - "[MergeComponent, MergeSubcomponent] and this is forbidden." + "[MergeComponent, MergeSubcomponent] and this is forbidden.", ) } } @@ -93,7 +94,7 @@ class InterfaceMergerRepeatableTest( $annotation(Any::class) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isTrue() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -119,7 +120,7 @@ class InterfaceMergerRepeatableTest( $annotation(Any::class) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isTrue() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -147,7 +148,7 @@ class InterfaceMergerRepeatableTest( $annotation(Any::class) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isFalse() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -169,7 +170,7 @@ class InterfaceMergerRepeatableTest( $annotation(Any::class, exclude = [ContributingInterface::class]) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isFalse() } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/InterfaceMergerTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/InterfaceMergerTest.kt index f6b8b39d1..da80239ee 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/InterfaceMergerTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/InterfaceMergerTest.kt @@ -15,7 +15,7 @@ import kotlin.reflect.KClass @RunWith(Parameterized::class) class InterfaceMergerTest( - private val annotationClass: KClass<*> + private val annotationClass: KClass<*>, ) { private val annotation = "@${annotationClass.simpleName}" @@ -23,7 +23,8 @@ class InterfaceMergerTest( companion object { @Parameters(name = "{0}") - @JvmStatic fun annotationClasses(): Collection { + @JvmStatic + fun annotationClasses(): Collection { return buildList { add(MergeComponent::class) if (isFullTestRun()) { @@ -50,7 +51,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isTrue() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -72,7 +73,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends parentInterface).isTrue() } @@ -90,7 +91,7 @@ class InterfaceMergerTest( interface ContributingInterface interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isFalse() } @@ -108,7 +109,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isFalse() } @@ -127,11 +128,11 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat( classLoader.loadClass("com.other.ComponentInterface") extends - classLoader.loadClass("com.other.ContributingInterface") + classLoader.loadClass("com.other.ContributingInterface"), ).isTrue() } } @@ -145,7 +146,7 @@ class InterfaceMergerTest( $annotation(Any::class) abstract class MergingClass - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -172,7 +173,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isFalse() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -198,7 +199,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. Unfortunately, a different error is reported that the class is @@ -227,7 +228,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. Unfortunately, a different error is reported that the class is @@ -236,7 +237,7 @@ class InterfaceMergerTest( assertThat(messages).contains( "com.squareup.test.SecondContributingInterface with scopes [kotlin.Any] wants to replace " + "com.squareup.test.ContributingInterface, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -260,7 +261,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface : ContributingInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isTrue() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -288,7 +289,7 @@ class InterfaceMergerTest( ] ) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isFalse() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -316,7 +317,7 @@ class InterfaceMergerTest( ] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -324,7 +325,7 @@ class InterfaceMergerTest( assertThat(messages).contains( "com.squareup.test.ComponentInterface with scopes [kotlin.Any] wants to exclude " + "com.squareup.test.ContributingInterface, but the excluded class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -353,7 +354,7 @@ class InterfaceMergerTest( ] ) interface ComponentInterface : ContributingInterface, OtherInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -361,7 +362,7 @@ class InterfaceMergerTest( "ComponentInterface excludes types that it implements or extends. These types cannot " + "be excluded. Look at all the super types to find these classes: " + "com.squareup.test.ContributingInterface, " + - "com.squareup.test.SecondContributingInterface" + "com.squareup.test.SecondContributingInterface", ) } } @@ -385,7 +386,7 @@ class InterfaceMergerTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isTrue() assertThat(componentInterface extends secondContributingInterface).isFalse() @@ -417,7 +418,7 @@ class InterfaceMergerTest( @MergeSubcomponent(Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isTrue() assertThat(componentInterface extends secondContributingInterface).isFalse() @@ -431,7 +432,7 @@ class InterfaceMergerTest( val visibilities = setOf( "internal", "private", - "protected" + "protected", ) visibilities.forEach { visibility -> @@ -447,7 +448,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -471,7 +472,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends innerInterface).isTrue() } @@ -491,13 +492,13 @@ class InterfaceMergerTest( @ContributesTo(Any::class) interface InnerInterface } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "Couldn't find the classId for . Are we stuck in a loop while resolving super " + "types? Note that it's not supported to contribute an inner class to a scope that " + - "is merged in an outer class." + "is merged in an outer class.", ) } } @@ -517,12 +518,12 @@ class InterfaceMergerTest( @dagger.Module abstract class InnerModule } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "It seems like you tried to contribute an inner class to its outer class. This is " + - "not supported and results in a compiler error." + "not supported and results in a compiler error.", ) } } @@ -546,7 +547,7 @@ class InterfaceMergerTest( @ContributesTo(Unit::class) interface InnerInterface } - """ + """, ) { val innerInterface = classLoader .loadClass("com.squareup.test.SubcomponentInterface\$InnerInterface") @@ -567,7 +568,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val componentInterface = classLoader.loadClass("ComponentInterface") val contributingInterface = classLoader.loadClass("ContributingInterface") @@ -593,7 +594,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isTrue() assertThat(componentInterface extends secondContributingInterface).isFalse() @@ -617,7 +618,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(secondContributingInterface extends contributingInterface).isTrue() @@ -640,7 +641,7 @@ class InterfaceMergerTest( interface DoSomethingInterface { fun doSomething() } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -666,7 +667,7 @@ class InterfaceMergerTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isTrue() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -686,7 +687,7 @@ class InterfaceMergerTest( @ContributesTo(Any::class) @ContributesTo(Unit::class) interface ContributingInterface - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -707,7 +708,7 @@ class InterfaceMergerTest( $annotation(Unit::class) interface SubcomponentInterface """, - previousCompilationResult = firstResult + previousCompilationResult = firstResult, ) { assertThat(componentInterface extends contributingInterface).isTrue() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -736,7 +737,7 @@ class InterfaceMergerTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isFalse() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -769,13 +770,13 @@ class InterfaceMergerTest( $annotation(Int::class) interface SubcomponentInterface2 - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "com.squareup.test.SecondContributingInterface with scopes [kotlin.Int] wants to " + "replace com.squareup.test.ContributingInterface, but the replaced class isn't " + - "contributed to the same scope." + "contributed to the same scope.", ) } } @@ -800,7 +801,7 @@ class InterfaceMergerTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(componentInterface extends contributingInterface).isFalse() assertThat(componentInterface extends secondContributingInterface).isTrue() @@ -832,7 +833,7 @@ class InterfaceMergerTest( // Note that the number is missing after the scope. public val com_squareup_test_ContributingInterface_scope: KClass = Any::class - """.trimIndent() + """.trimIndent(), ) { assertThat(exitCode).isEqualTo(OK) } @@ -846,7 +847,7 @@ class InterfaceMergerTest( $annotation(Any::class) interface ComponentInterface """, - previousCompilationResult = result + previousCompilationResult = result, ) { assertThat(componentInterface extends contributingInterface).isTrue() } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/MergeModulesTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/MergeModulesTest.kt index 3dd404241..2bc928b01 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/MergeModulesTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/MergeModulesTest.kt @@ -16,7 +16,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()).isEmpty() assertThat(daggerModule1.daggerModule.subcomponents).isEmpty() @@ -38,7 +38,7 @@ class MergeModulesTest { ] ) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(Boolean::class, Int::class) @@ -64,7 +64,7 @@ class MergeModulesTest { ] ) class DaggerModule1 - """ + """, ) { val module = daggerModule1.daggerModule assertThat(module.includes.withoutAnvilModule()).containsExactly(Boolean::class, Int::class) @@ -82,7 +82,7 @@ class MergeModulesTest { @MergeModules(Any::class) @dagger.Module class DaggerModule1 - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -104,7 +104,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule2.kotlin) @@ -131,7 +131,7 @@ class MergeModulesTest { ] ) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule2.kotlin, Int::class, Boolean::class) @@ -151,7 +151,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -180,7 +180,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule3.kotlin) @@ -210,7 +210,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule2.kotlin) @@ -242,7 +242,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule2.kotlin) @@ -274,7 +274,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -282,7 +282,7 @@ class MergeModulesTest { assertThat(messages).contains( "com.squareup.test.DaggerModule2 with scopes [kotlin.Any] wants to replace " + "com.squareup.test.ContributingInterface, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -310,7 +310,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -318,7 +318,7 @@ class MergeModulesTest { assertThat(messages).contains( "com.squareup.test.DaggerModule2 with scopes [kotlin.Any] wants to replace " + "com.squareup.test.ContributingInterface, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -346,7 +346,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()).isEmpty() assertThat(daggerModule1.anvilModule.declaredMethods).hasLength(1) @@ -376,7 +376,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()).isEmpty() assertThat(daggerModule1.anvilModule.declaredMethods).hasLength(1) @@ -406,7 +406,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -414,7 +414,7 @@ class MergeModulesTest { assertThat(messages).contains( "com.squareup.test.ContributingInterface with scopes [kotlin.Any] wants to replace " + "com.squareup.test.DaggerModule2, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -442,7 +442,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -450,7 +450,7 @@ class MergeModulesTest { assertThat(messages).contains( "com.squareup.test.ContributingInterface with scopes [kotlin.Any] wants to replace " + "com.squareup.test.DaggerModule2, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -474,7 +474,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -503,7 +503,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -511,7 +511,7 @@ class MergeModulesTest { assertThat(messages).contains( "com.squareup.test.DaggerModule2 with scopes [kotlin.Any] wants to replace " + "com.squareup.test.DaggerModule3, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -542,7 +542,7 @@ class MergeModulesTest { ] ) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule2.kotlin, daggerModule3.kotlin) @@ -572,7 +572,7 @@ class MergeModulesTest { ] ) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule3.kotlin) @@ -598,7 +598,7 @@ class MergeModulesTest { ] ) class DaggerModule1 - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -606,7 +606,7 @@ class MergeModulesTest { assertThat(messages).contains( "com.squareup.test.DaggerModule1 with scopes [kotlin.Any] wants to exclude " + "com.squareup.test.DaggerModule2, but the excluded class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -631,7 +631,7 @@ class MergeModulesTest { ] ) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anvilModule.declaredMethods).isEmpty() } @@ -657,7 +657,7 @@ class MergeModulesTest { ] ) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anvilModule.declaredMethods).isEmpty() } @@ -683,7 +683,7 @@ class MergeModulesTest { ] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -691,7 +691,7 @@ class MergeModulesTest { assertThat(messages).contains( "com.squareup.test.ComponentInterface with scopes [kotlin.Any] wants to exclude " + "com.squareup.test.ContributingInterface, but the excluded class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -716,7 +716,7 @@ class MergeModulesTest { ] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -724,7 +724,7 @@ class MergeModulesTest { assertThat(messages).contains( "com.squareup.test.ComponentInterface with scopes [kotlin.Any] wants to exclude " + "com.squareup.test.ContributingInterface, but the excluded class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -750,7 +750,7 @@ class MergeModulesTest { @MergeModules(Unit::class) class DaggerModule2 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule3.kotlin) @@ -763,7 +763,7 @@ class MergeModulesTest { val visibilities = setOf( "internal", "private", - "protected" + "protected", ) visibilities.forEach { visibility -> @@ -780,7 +780,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(exitCode).isError() // Position to the class. @@ -803,7 +803,7 @@ class MergeModulesTest { @dagger.Module abstract class InnerModule } - """ + """, ) { val innerModule = classLoader.loadClass("com.squareup.test.DaggerModule1\$InnerModule") @@ -824,7 +824,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(classLoader.loadClass("DaggerModule1").daggerModule.includes.withoutAnvilModule()) .containsExactly(classLoader.loadClass("DaggerModule2").kotlin) @@ -849,7 +849,7 @@ class MergeModulesTest { @MergeModules(Any::class) class DaggerModule1 - """ + """, ) { assertThat(daggerModule1.anvilModule.declaredMethods).hasLength(1) } @@ -877,7 +877,7 @@ class MergeModulesTest { ] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:19:11") @@ -903,7 +903,7 @@ class MergeModulesTest { @MergeModules(Unit::class) class DaggerModule3 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule2.kotlin) @@ -935,7 +935,7 @@ class MergeModulesTest { @MergeModules(Unit::class) class DaggerModule2 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule3.kotlin, daggerModule4.kotlin) @@ -967,7 +967,7 @@ class MergeModulesTest { @MergeModules(Unit::class) class DaggerModule2 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule4.kotlin) @@ -999,7 +999,7 @@ class MergeModulesTest { @MergeModules(Unit::class) class DaggerModule2 - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule4.kotlin) diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/ModuleMergerRepeatableTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/ModuleMergerRepeatableTest.kt index e6eb3018f..a4cea4981 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/ModuleMergerRepeatableTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/ModuleMergerRepeatableTest.kt @@ -15,7 +15,7 @@ import kotlin.reflect.KClass @RunWith(Parameterized::class) class ModuleMergerRepeatableTest( - private val annotationClass: KClass<*> + private val annotationClass: KClass<*>, ) { private val annotation = "@${annotationClass.simpleName}" @@ -23,7 +23,8 @@ class ModuleMergerRepeatableTest( companion object { @Parameters(name = "{0}") - @JvmStatic fun annotationClasses(): Collection { + @JvmStatic + fun annotationClasses(): Collection { return buildList { add(MergeComponent::class) if (isFullTestRun()) { @@ -44,12 +45,12 @@ class ModuleMergerRepeatableTest( $annotation(Any::class) $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "com.squareup.test.ComponentInterface merges multiple times to the same scope: [Any]. " + - "Merging multiple times to the same scope is forbidden and all scopes must be distinct." + "Merging multiple times to the same scope is forbidden and all scopes must be distinct.", ) } } @@ -67,13 +68,13 @@ class ModuleMergerRepeatableTest( @MergeComponent(Any::class) @MergeSubcomponent(Unit::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "It's only allowed to have one single type of @Merge* annotation, however multiple " + "instances of the same annotation are allowed. You mix " + - "[MergeComponent, MergeSubcomponent] and this is forbidden." + "[MergeComponent, MergeSubcomponent] and this is forbidden.", ) } } @@ -98,7 +99,7 @@ class ModuleMergerRepeatableTest( $annotation(Any::class) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent(annotationClass) assertThat(component.modules.withoutAnvilModule()) @@ -128,7 +129,7 @@ class ModuleMergerRepeatableTest( $annotation(Any::class) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent(annotationClass) assertThat(component.modules.withoutAnvilModule()) @@ -160,7 +161,7 @@ class ModuleMergerRepeatableTest( $annotation(Any::class) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent(annotationClass) assertThat(component.modules.withoutAnvilModule()).containsExactly(daggerModule2.kotlin) @@ -192,10 +193,10 @@ class ModuleMergerRepeatableTest( $annotation(Any::class) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { assertThat( - componentInterface.anyDaggerComponent(annotationClass).modules.withoutAnvilModule() + componentInterface.anyDaggerComponent(annotationClass).modules.withoutAnvilModule(), ).containsExactly(daggerModule1.kotlin) assertThat(componentInterface.anvilModule.declaredMethods).isEmpty() @@ -228,10 +229,10 @@ class ModuleMergerRepeatableTest( $annotation(Any::class) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { assertThat( - componentInterface.anyDaggerComponent(annotationClass).modules.withoutAnvilModule() + componentInterface.anyDaggerComponent(annotationClass).modules.withoutAnvilModule(), ).isEmpty() assertThat(componentInterface.anvilModule.declaredMethods).hasLength(1) } @@ -262,7 +263,7 @@ class ModuleMergerRepeatableTest( ) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent(annotationClass) assertThat(component.modules.withoutAnvilModule()).containsExactly(daggerModule2.kotlin) @@ -291,7 +292,7 @@ class ModuleMergerRepeatableTest( ) $annotation(Unit::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anvilModule.declaredMethods).isEmpty() } @@ -318,7 +319,7 @@ class ModuleMergerRepeatableTest( dependencies = [Int::class] ) interface ComponentInterface - """ + """, ) { val component = componentInterface.daggerComponent assertThat(component.modules.withoutAnvilModule()).containsExactly(Boolean::class, Int::class) diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/ModuleMergerTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/ModuleMergerTest.kt index 39ab47f4d..a5e4a98ee 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/ModuleMergerTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/ModuleMergerTest.kt @@ -21,7 +21,7 @@ import kotlin.reflect.KClass @RunWith(Parameterized::class) class ModuleMergerTest( - private val annotationClass: KClass<*> + private val annotationClass: KClass<*>, ) { private val annotation = "@${annotationClass.simpleName}" @@ -29,7 +29,8 @@ class ModuleMergerTest( companion object { @Parameters(name = "{0}") - @JvmStatic fun annotationClasses(): Collection { + @JvmStatic + fun annotationClasses(): Collection { return buildList { add(MergeComponent::class) if (isFullTestRun()) { @@ -48,7 +49,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()).isEmpty() @@ -73,7 +74,7 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent assertThat(component.modules.withoutAnvilModule()).containsExactly(Boolean::class, Int::class) @@ -101,7 +102,7 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { val component = componentInterface.daggerComponent assertThat(component.modules.withoutAnvilModule()).containsExactly(Boolean::class, Int::class) @@ -126,7 +127,7 @@ class ModuleMergerTest( $annotation(Any::class) @${daggerComponentClass.java.canonicalName} interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:7:11") @@ -147,7 +148,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent assertThat(component.modules.withoutAnvilModule()).containsExactly(daggerModule1.kotlin) @@ -168,7 +169,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent assertThat(component.modules.withoutAnvilModule()).containsExactly(daggerModule1.kotlin) @@ -195,7 +196,7 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent assertThat(component.modules.withoutAnvilModule()) @@ -216,7 +217,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:7:16") @@ -244,7 +245,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent assertThat(component.modules.withoutAnvilModule()).containsExactly(daggerModule2.kotlin) @@ -274,7 +275,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()) .containsExactly(daggerModule1.kotlin) @@ -306,7 +307,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()) .containsExactly(daggerModule1.kotlin) @@ -338,14 +339,14 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:17:16") assertThat(messages).contains( "com.squareup.test.DaggerModule1 with scopes [kotlin.Any] wants to replace " + "com.squareup.test.ContributingInterface, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -373,14 +374,14 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:17:16") assertThat(messages).contains( "com.squareup.test.DaggerModule1 with scopes [kotlin.Any] wants to replace " + "com.squareup.test.ContributingInterface, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -408,7 +409,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()).isEmpty() assertThat(componentInterface.anvilModule.declaredMethods).hasLength(1) @@ -438,7 +439,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()).isEmpty() assertThat(componentInterface.anvilModule.declaredMethods).hasLength(1) @@ -468,14 +469,14 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:17:11") assertThat(messages).contains( "com.squareup.test.ContributingInterface with scopes [kotlin.Any] wants to replace " + "com.squareup.test.DaggerModule1, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -503,14 +504,14 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:17:11") assertThat(messages).contains( "com.squareup.test.ContributingInterface with scopes [kotlin.Any] wants to replace " + "com.squareup.test.DaggerModule1, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -534,7 +535,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:13:16") @@ -562,14 +563,14 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:15:16") assertThat(messages).contains( "com.squareup.test.DaggerModule2 with scopes [kotlin.Any] wants to replace " + "com.squareup.test.DaggerModule1, but the replaced class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -600,7 +601,7 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent assertThat(component.modules.withoutAnvilModule()) @@ -631,7 +632,7 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent assertThat(component.modules.withoutAnvilModule()).containsExactly(daggerModule2.kotlin) @@ -661,14 +662,14 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:20:11") assertThat(messages).contains( "com.squareup.test.ComponentInterface with scopes [kotlin.Any] wants to exclude " + "com.squareup.test.DaggerModule1, but the excluded class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -696,7 +697,7 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { val component = componentInterface.anyDaggerComponent assertThat(component.modules.withoutAnvilModule()).containsExactly(daggerModule2.kotlin) @@ -727,7 +728,7 @@ class ModuleMergerTest( exclude = [DaggerModule1::class] ) interface ComponentInterface2 - """ + """, ) { val component1 = componentInterface.anyDaggerComponent assertThat(component1.modules.withoutAnvilModule()).containsExactly(daggerModule1.kotlin) @@ -758,7 +759,7 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anvilModule.declaredMethods).isEmpty() } @@ -784,7 +785,7 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anvilModule.declaredMethods).isEmpty() } @@ -810,14 +811,14 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:17:11") assertThat(messages).contains( "com.squareup.test.ComponentInterface with scopes [kotlin.Any] wants to exclude " + "com.squareup.test.ContributingInterface, but the excluded class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -842,14 +843,14 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:17:11") assertThat(messages).contains( "com.squareup.test.ComponentInterface with scopes [kotlin.Any] wants to exclude " + "com.squareup.test.ContributingInterface, but the excluded class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -875,7 +876,7 @@ class ModuleMergerTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()) .containsExactly(daggerModule1.kotlin) @@ -908,7 +909,7 @@ class ModuleMergerTest( @MergeSubcomponent(Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(componentInterface.daggerComponent.modules.withoutAnvilModule()) .containsExactly(daggerModule1.kotlin) @@ -921,7 +922,7 @@ class ModuleMergerTest( val visibilities = setOf( "internal", "private", - "protected" + "protected", ) visibilities.forEach { visibility -> @@ -938,7 +939,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:8:") @@ -962,7 +963,7 @@ class ModuleMergerTest( $annotation(Any::class) interface SubcomponentInterface - """ + """, ) { assertThat(subcomponentInterface.anyDaggerComponent.modules.withoutAnvilModule()) .containsExactly(innerModule.kotlin) @@ -983,13 +984,13 @@ class ModuleMergerTest( @dagger.Module abstract class InnerModule } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "Couldn't find the classId for . Are we stuck in a loop while resolving super " + "types? Note that it's not supported to contribute an inner class to a scope that " + - "is merged in an outer class." + "is merged in an outer class.", ) } } @@ -1011,7 +1012,7 @@ class ModuleMergerTest( @dagger.Module abstract class InnerModule } - """ + """, ) { val innerModule = classLoader .loadClass("com.squareup.test.SubcomponentInterface\$InnerModule") @@ -1033,7 +1034,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val component = classLoader.loadClass("ComponentInterface").anyDaggerComponent assertThat(component.modules.withoutAnvilModule()) @@ -1063,7 +1064,7 @@ class ModuleMergerTest( ] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:19:11") @@ -1079,11 +1080,11 @@ class ModuleMergerTest( $annotation interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( - "Couldn't find scope for ${annotationClass.java.canonicalName}" + "Couldn't find scope for ${annotationClass.java.canonicalName}", ) } } @@ -1108,7 +1109,7 @@ class ModuleMergerTest( $annotation(Unit::class) interface ComponentInterface - """ + """, ) { assertThat(daggerModule1.daggerModule.includes.withoutAnvilModule()) .containsExactly(daggerModule2.kotlin) @@ -1156,7 +1157,7 @@ class ModuleMergerTest( $annotation(scope = Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -1184,7 +1185,7 @@ class ModuleMergerTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()) .containsExactly(daggerModule1.kotlin, daggerModule2.kotlin) @@ -1206,7 +1207,7 @@ class ModuleMergerTest( @ContributesTo(Unit::class) @Module abstract class DaggerModule1 - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -1228,7 +1229,7 @@ class ModuleMergerTest( $annotation(Unit::class) interface SubcomponentInterface """, - previousCompilationResult = firstResult + previousCompilationResult = firstResult, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()) .containsExactly(daggerModule1.kotlin, daggerModule2.kotlin) @@ -1260,7 +1261,7 @@ class ModuleMergerTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()) .containsExactly(daggerModule2.kotlin) @@ -1296,13 +1297,13 @@ class ModuleMergerTest( $annotation(Int::class) interface SubcomponentInterface2 - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "com.squareup.test.DaggerModule2 with scopes [kotlin.Int] wants to replace " + "com.squareup.test.DaggerModule1, but the replaced class isn't contributed to the " + - "same scope." + "same scope.", ) } } @@ -1329,7 +1330,7 @@ class ModuleMergerTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()) .containsExactly(daggerModule2.kotlin) @@ -1363,7 +1364,7 @@ class ModuleMergerTest( // Note that the number is missing after the scope. public val com_squareup_test_DaggerModule1_scope: KClass = Any::class - """.trimIndent() + """.trimIndent(), ) { assertThat(exitCode).isEqualTo(OK) } @@ -1377,7 +1378,7 @@ class ModuleMergerTest( $annotation(Any::class) interface ComponentInterface """, - previousCompilationResult = result + previousCompilationResult = result, ) { assertThat(componentInterface.anyDaggerComponent.modules.withoutAnvilModule()) .containsExactly(daggerModule1.kotlin) diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt b/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt index 36aebeedc..1e341cd66 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/TestUtils.kt @@ -26,14 +26,14 @@ internal fun compile( codeGenerators: List = emptyList(), allWarningsAsErrors: Boolean = WARNINGS_AS_ERRORS, mode: AnvilCompilationMode = AnvilCompilationMode.Embedded(codeGenerators), - block: JvmCompilationResult.() -> Unit = { } + block: JvmCompilationResult.() -> Unit = { }, ): JvmCompilationResult = compileAnvil( sources = sources, allWarningsAsErrors = allWarningsAsErrors, previousCompilationResult = previousCompilationResult, enableDaggerAnnotationProcessor = enableDaggerAnnotationProcessor, mode = mode, - block = block + block = block, ) internal val JvmCompilationResult.contributingInterface: Class<*> @@ -132,7 +132,7 @@ internal val Class<*>.hintSubcomponentParentScopes: List> internal val Class<*>.anvilModule: Class<*> get() = classLoader.loadClass( - "$MODULE_PACKAGE_PREFIX.${generatedClassesString(separator = "")}$ANVIL_MODULE_SUFFIX" + "$MODULE_PACKAGE_PREFIX.${generatedClassesString(separator = "")}$ANVIL_MODULE_SUFFIX", ) private fun Class<*>.getHint(prefix: String): KClass<*>? = contributedProperties(prefix) diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleGeneratorTest.kt index da48ead6a..d6a2d0b2c 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleGeneratorTest.kt @@ -32,7 +32,7 @@ import kotlin.reflect.KClass @RunWith(Parameterized::class) class BindingModuleGeneratorTest( - private val annotationClass: KClass<*> + private val annotationClass: KClass<*>, ) { private val annotation = "@${annotationClass.simpleName}" @@ -40,7 +40,8 @@ class BindingModuleGeneratorTest( companion object { @Parameters(name = "{0}") - @JvmStatic fun annotationClasses(): Collection { + @JvmStatic + fun annotationClasses(): Collection { return buildList { add(MergeComponent::class) if (isFullTestRun()) { @@ -60,7 +61,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -85,7 +86,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -110,7 +111,7 @@ class BindingModuleGeneratorTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { if (annotationClass == MergeModules::class) { assertThat(componentInterface.daggerModule.includes.toList()) @@ -138,10 +139,10 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface } - """ + """, ) { assertThat( - classLoader.loadClass("com.squareup.test.SomeClass\$ComponentInterface").anvilModule + classLoader.loadClass("com.squareup.test.SomeClass\$ComponentInterface").anvilModule, ).isNotNull() } } @@ -163,7 +164,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -201,7 +202,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -244,7 +245,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -286,7 +287,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -328,7 +329,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -357,7 +358,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { classLoader.loadClass("ComponentInterface").daggerModule.includes.toList() @@ -368,7 +369,7 @@ class BindingModuleGeneratorTest( classLoader .loadClass("ComponentInterface") .anvilModule - .kotlin + .kotlin, ) } } @@ -391,7 +392,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() @@ -399,7 +400,7 @@ class BindingModuleGeneratorTest( assertThat(messages).contains( "Class com.squareup.test.ContributingInterface binds com.squareup.test.ParentInterface, " + "but the bound type contains type parameter(s) . Type parameters in bindings " + - "are not supported. This binding needs to be contributed in a Dagger module manually." + "are not supported. This binding needs to be contributed in a Dagger module manually.", ) } } @@ -423,7 +424,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() @@ -432,7 +433,7 @@ class BindingModuleGeneratorTest( "Class com.squareup.test.ContributingInterface binds com.squareup.test.ParentInterface, " + "but the bound type contains type parameter(s) . Type parameters in " + "bindings are not supported. This binding needs to be contributed in a Dagger module " + - "manually." + "manually.", ) } } @@ -460,7 +461,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class, exclude = [DaggerModule1::class]) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -503,7 +504,7 @@ class BindingModuleGeneratorTest( exclude = [ContributingInterface::class] ) interface ComponentInterface2 - """ + """, ) { val anvilModule1 = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -541,7 +542,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -581,7 +582,7 @@ class BindingModuleGeneratorTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { listOf(componentInterface, subcomponentInterface).forEach { component -> with(component.anvilModule.declaredMethods.single()) { @@ -607,7 +608,7 @@ class BindingModuleGeneratorTest( @ContributesBinding(Any::class) @ContributesBinding(Unit::class) interface ContributingInterface : ParentInterface - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -624,7 +625,7 @@ class BindingModuleGeneratorTest( $annotation(Unit::class) interface SubcomponentInterface """, - previousCompilationResult = previousResult + previousCompilationResult = previousResult, ) { listOf(componentInterface, subcomponentInterface).forEach { component -> with(component.anvilModule.declaredMethods.single()) { @@ -657,7 +658,7 @@ class BindingModuleGeneratorTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { with(componentInterface.anvilModule.declaredMethods.single()) { assertThat(returnType).isEqualTo(parentInterface1) @@ -692,7 +693,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val methods = componentInterface.anvilModule.declaredMethods.sortedBy { it.name } assertThat(methods).hasSize(2) @@ -733,7 +734,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val methods = componentInterface.anvilModule.declaredMethods.sortedBy { it.name } assertThat(methods).hasSize(2) @@ -746,7 +747,7 @@ class BindingModuleGeneratorTest( } with(methods[1]) { assertThat(returnType).isEqualTo( - classLoader.loadClass("com.squareup.test.other.ParentInterface") + classLoader.loadClass("com.squareup.test.other.ParentInterface"), ) assertThat(parameterTypes.toList()).containsExactly(contributingInterface) assertThat(isAbstract).isTrue() @@ -777,7 +778,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anvilModule.declaredMethods).isEmpty() } @@ -809,7 +810,7 @@ class BindingModuleGeneratorTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { with(componentInterface.anvilModule.declaredMethods.single()) { assertThat(returnType).isEqualTo(parentInterface) @@ -850,7 +851,7 @@ class BindingModuleGeneratorTest( exclude = [ContributingInterface::class] ) interface SubcomponentInterface - """ + """, ) { with(componentInterface.anvilModule.declaredMethods.single()) { assertThat(returnType).isEqualTo(parentInterface) @@ -887,7 +888,7 @@ class BindingModuleGeneratorTest( // Note that the number is missing after the scope. public val com_squareup_test_ContributingInterface_scope: KClass = Any::class - """.trimIndent() + """.trimIndent(), ) { assertThat(exitCode).isEqualTo(OK) } @@ -901,7 +902,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) interface ComponentInterface """, - previousCompilationResult = result + previousCompilationResult = result, ) { with(componentInterface.anvilModule.declaredMethods.single()) { assertThat(returnType).isEqualTo(parentInterface) @@ -932,7 +933,7 @@ class BindingModuleGeneratorTest( $annotation(Int::class) $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { listOf(componentInterface, subcomponentInterface).forEach { component -> with(component.anvilModule.declaredMethods.single()) { @@ -966,7 +967,7 @@ class BindingModuleGeneratorTest( $annotation(Any::class) $annotation(Unit::class, exclude = [ContributingInterface::class]) interface SubcomponentInterface - """ + """, ) { with(componentInterface.anvilModule.declaredMethods.single()) { assertThat(returnType).isEqualTo(parentInterface) @@ -996,7 +997,7 @@ class BindingModuleGeneratorTest( @`Fancy${'$'}DslMarker` $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleMultibindingMapTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleMultibindingMapTest.kt index 2652b0015..6f0e88191 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleMultibindingMapTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleMultibindingMapTest.kt @@ -29,7 +29,7 @@ import kotlin.reflect.KClass @RunWith(Parameterized::class) class BindingModuleMultibindingMapTest( - private val annotationClass: KClass<*> + private val annotationClass: KClass<*>, ) { private val annotation = "@${annotationClass.simpleName}" @@ -37,7 +37,8 @@ class BindingModuleMultibindingMapTest( companion object { @Parameters(name = "{0}") - @JvmStatic fun annotationClasses(): Collection { + @JvmStatic + fun annotationClasses(): Collection { return buildList { add(MergeComponent::class) if (isFullTestRun()) { @@ -70,7 +71,7 @@ class BindingModuleMultibindingMapTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -114,7 +115,7 @@ class BindingModuleMultibindingMapTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -167,7 +168,7 @@ class BindingModuleMultibindingMapTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -203,7 +204,7 @@ class BindingModuleMultibindingMapTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -244,7 +245,7 @@ class BindingModuleMultibindingMapTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -288,11 +289,11 @@ class BindingModuleMultibindingMapTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( - "Classes annotated with @ContributesMultibinding may not use more than one @MapKey." + "Classes annotated with @ContributesMultibinding may not use more than one @MapKey.", ) } } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleMultibindingSetTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleMultibindingSetTest.kt index 3ea88ed23..00216ba8d 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleMultibindingSetTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleMultibindingSetTest.kt @@ -30,7 +30,7 @@ import kotlin.reflect.KClass @RunWith(Parameterized::class) class BindingModuleMultibindingSetTest( - private val annotationClass: KClass<*> + private val annotationClass: KClass<*>, ) { private val annotation = "@${annotationClass.simpleName}" @@ -38,7 +38,8 @@ class BindingModuleMultibindingSetTest( companion object { @Parameters(name = "{0}") - @JvmStatic fun annotationClasses(): Collection { + @JvmStatic + fun annotationClasses(): Collection { return buildList { add(MergeComponent::class) if (isFullTestRun()) { @@ -66,7 +67,7 @@ class BindingModuleMultibindingSetTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -104,7 +105,7 @@ class BindingModuleMultibindingSetTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -148,7 +149,7 @@ class BindingModuleMultibindingSetTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -190,7 +191,7 @@ class BindingModuleMultibindingSetTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -233,7 +234,7 @@ class BindingModuleMultibindingSetTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -273,7 +274,7 @@ class BindingModuleMultibindingSetTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() @@ -281,7 +282,7 @@ class BindingModuleMultibindingSetTest( assertThat(messages).contains( "Class com.squareup.test.ContributingInterface binds com.squareup.test.ParentInterface, " + "but the bound type contains type parameter(s) . Type parameters in bindings " + - "are not supported. This binding needs to be contributed in a Dagger module manually." + "are not supported. This binding needs to be contributed in a Dagger module manually.", ) } } @@ -303,7 +304,7 @@ class BindingModuleMultibindingSetTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -339,7 +340,7 @@ class BindingModuleMultibindingSetTest( $annotation(Any::class, exclude = [DaggerModule1::class]) interface ComponentInterface - """ + """, ) { val modules = if (annotationClass == MergeModules::class) { componentInterface.daggerModule.includes.toList() @@ -382,7 +383,7 @@ class BindingModuleMultibindingSetTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { with(componentInterface.anvilModule.declaredMethods.single()) { assertThat(returnType).isEqualTo(parentInterface) @@ -422,7 +423,7 @@ class BindingModuleMultibindingSetTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { with(componentInterface.anvilModule.declaredMethods.single()) { assertThat(returnType).isEqualTo(parentInterface1) @@ -459,7 +460,7 @@ class BindingModuleMultibindingSetTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val methods = componentInterface.anvilModule.declaredMethods.sortedBy { it.name } assertThat(methods).hasSize(2) @@ -501,7 +502,7 @@ class BindingModuleMultibindingSetTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(componentInterface.anvilModule.declaredMethods).isEmpty() } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModulePriorityTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModulePriorityTest.kt index b6f22afce..771145554 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModulePriorityTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModulePriorityTest.kt @@ -21,7 +21,7 @@ import kotlin.reflect.KClass @RunWith(Parameterized::class) class BindingModulePriorityTest( - annotationClass: KClass<*> + annotationClass: KClass<*>, ) { private val annotation = "@${annotationClass.simpleName}" @@ -29,7 +29,8 @@ class BindingModulePriorityTest( companion object { @Parameters(name = "{0}") - @JvmStatic fun annotationClasses(): Collection { + @JvmStatic + fun annotationClasses(): Collection { return buildList { add(MergeComponent::class) if (isFullTestRun()) { @@ -63,7 +64,7 @@ class BindingModulePriorityTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -97,7 +98,7 @@ class BindingModulePriorityTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -126,13 +127,13 @@ class BindingModulePriorityTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "There are multiple contributed bindings with the same bound type. The bound type is " + - "com.squareup.test.ParentInterface. The contributed binding classes are: [" + "com.squareup.test.ParentInterface. The contributed binding classes are: [", ) // Check the contributed bindings separately, we cannot rely on the order in the string. assertThat(messages).contains("com.squareup.test.ContributingInterface") @@ -158,7 +159,7 @@ class BindingModulePriorityTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -187,7 +188,7 @@ class BindingModulePriorityTest( $annotation(Any::class, exclude = [ContributingInterface::class]) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -219,7 +220,7 @@ class BindingModulePriorityTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethods = componentInterface.anvilModule.declaredMethods .filter { it.returnType == parentInterface } @@ -227,10 +228,10 @@ class BindingModulePriorityTest( assertThat(bindingMethods).hasSize(2) assertThat( - bindingMethods.singleOrNull { it.parameterTypes.contains(contributingInterface) } + bindingMethods.singleOrNull { it.parameterTypes.contains(contributingInterface) }, ).isNotNull() assertThat( - bindingMethods.singleOrNull { it.parameterTypes.contains(secondContributingInterface) } + bindingMethods.singleOrNull { it.parameterTypes.contains(secondContributingInterface) }, ).isNotNull() } } @@ -256,13 +257,13 @@ class BindingModulePriorityTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "There are multiple contributed bindings with the same bound type. The bound type is " + - "com.squareup.test.ParentInterface. The contributed binding classes are: [" + "com.squareup.test.ParentInterface. The contributed binding classes are: [", ) // Check the contributed bindings separately, we cannot rely on the order in the string. assertThat(messages).contains("com.squareup.test.ContributingInterface") @@ -291,13 +292,13 @@ class BindingModulePriorityTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "There are multiple contributed bindings with the same bound type. The bound type is " + - "com.squareup.test.ParentInterface. The contributed binding classes are: [" + "com.squareup.test.ParentInterface. The contributed binding classes are: [", ) // Check the contributed bindings separately, we cannot rely on the order in the string. assertThat(messages).contains("com.squareup.test.ContributingInterface") @@ -326,7 +327,7 @@ class BindingModulePriorityTest( $annotation(Any::class, exclude = [ContributingInterface::class]) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -355,7 +356,7 @@ class BindingModulePriorityTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethods = componentInterface.anvilModule.declaredMethods assertThat(bindingMethods).hasLength(2) @@ -389,7 +390,7 @@ class BindingModulePriorityTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { with(componentInterface.anvilModule.declaredMethods.single()) { assertThat(returnType).isEqualTo(parentInterface) diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleQualifierTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleQualifierTest.kt index b8ccd54c7..227f601b0 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleQualifierTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/BindingModuleQualifierTest.kt @@ -25,7 +25,7 @@ import kotlin.reflect.KClass @RunWith(Parameterized::class) class BindingModuleQualifierTest( - annotationClass: KClass<*> + annotationClass: KClass<*>, ) { private val annotation = "@${annotationClass.simpleName}" @@ -33,7 +33,8 @@ class BindingModuleQualifierTest( companion object { @Parameters(name = "{0}") - @JvmStatic fun annotationClasses(): Collection { + @JvmStatic + fun annotationClasses(): Collection { return buildList { add(MergeComponent::class) if (isFullTestRun()) { @@ -64,7 +65,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -99,7 +100,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -134,7 +135,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -169,7 +170,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -201,7 +202,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -241,7 +242,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -288,7 +289,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -331,7 +332,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -368,7 +369,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() @@ -402,7 +403,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() val annotations = bindingMethod.annotations.map { it.annotationClass } @@ -432,7 +433,7 @@ class BindingModuleQualifierTest( $annotation(Any::class) interface ComponentInterface - """ + """, ) { val bindingMethod = componentInterface.anvilModule.declaredMethods.single() val annotations = bindingMethod.annotations.map { it.annotationClass } @@ -466,7 +467,7 @@ class BindingModuleQualifierTest( $annotation(Unit::class) interface SubcomponentInterface - """ + """, ) { with(componentInterface.anvilModule.declaredMethods.single()) { assertThat(returnType).isEqualTo(parentInterface) diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/CodeGenerationExtensionTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/CodeGenerationExtensionTest.kt index bfad55881..7908a69e1 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/CodeGenerationExtensionTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/CodeGenerationExtensionTest.kt @@ -39,7 +39,7 @@ class CodeGenerationExtensionTest { interface ComponentInterface2 """, - codeGenerators = listOf(codeGenerator) + codeGenerators = listOf(codeGenerator), ) { assertThat(exitCode).isError() @@ -49,7 +49,7 @@ class CodeGenerationExtensionTest { "leads to unexpected results. The relative path is: " + "generated/com/squareup/test/Abc.kt. The file was generated by class " + "com.squareup.anvil.compiler.internal.testing.SimpleCodeGeneratorKt" + - "\$simpleCodeGenerator\$1. The input files were [Source0.kt]." + "\$simpleCodeGenerator\$1. The input files were [Source0.kt].", ) } } @@ -76,7 +76,7 @@ class CodeGenerationExtensionTest { interface ComponentInterface2 """, - codeGenerators = listOf(codeGenerator) + codeGenerators = listOf(codeGenerator), ) { assertThat(exitCode).isEqualTo(OK) } @@ -95,7 +95,7 @@ class CodeGenerationExtensionTest { override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { generateCodeCalled = true return emptyList() @@ -108,7 +108,7 @@ class CodeGenerationExtensionTest { interface ComponentInterface1 """, - codeGenerators = listOf(codeGenerator) + codeGenerators = listOf(codeGenerator), ) { assertThat(exitCode).isEqualTo(OK) assertThat(isApplicableCalled).isTrue() @@ -137,7 +137,7 @@ class CodeGenerationExtensionTest { @InternalApi @ContributesBinding(Unit::class) class SomeClass @Inject constructor() : Type - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesBindingGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesBindingGeneratorTest.kt index 58983b92f..e07b6b07f 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesBindingGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesBindingGeneratorTest.kt @@ -17,12 +17,13 @@ import org.junit.runners.Parameterized @Suppress("RemoveRedundantQualifierName") @RunWith(Parameterized::class) class ContributesBindingGeneratorTest( - private val mode: AnvilCompilationMode + private val mode: AnvilCompilationMode, ) { companion object { @Parameterized.Parameters(name = "{0}") - @JvmStatic fun modes(): Collection { + @JvmStatic + fun modes(): Collection { return buildList { add(AnvilCompilationMode.Embedded()) add(AnvilCompilationMode.Ksp()) @@ -165,7 +166,7 @@ class ContributesBindingGeneratorTest( val visibilities = setOf( "internal", "private", - "protected" + "protected", ) visibilities.forEach { visibility -> @@ -187,7 +188,7 @@ class ContributesBindingGeneratorTest( assertThat(messages).contains("Source0.kt:8") assertThat(messages).contains( "com.squareup.test.ContributingInterface is binding a type, but the class is not " + - "public. Only public types are supported." + "public. Only public types are supported.", ) } } @@ -217,7 +218,7 @@ class ContributesBindingGeneratorTest( ) { assertThat(exitCode).isError() assertThat(messages).contains( - "Classes annotated with @ContributesBinding may not use more than one @Qualifier." + "Classes annotated with @ContributesBinding may not use more than one @Qualifier.", ) } } @@ -241,7 +242,7 @@ class ContributesBindingGeneratorTest( "com.squareup.test.ContributingInterface contributes a binding, but does not specify " + "the bound type. This is only allowed with exactly one direct super type. If there " + "are multiple or none, then the bound type must be explicitly defined in the " + - "@ContributesBinding annotation." + "@ContributesBinding annotation.", ) } } @@ -267,7 +268,7 @@ class ContributesBindingGeneratorTest( "com.squareup.test.ContributingInterface contributes a binding, but does not specify " + "the bound type. This is only allowed with exactly one direct super type. If there " + "are multiple or none, then the bound type must be explicitly defined in the " + - "@ContributesBinding annotation." + "@ContributesBinding annotation.", ) } } @@ -289,7 +290,7 @@ class ContributesBindingGeneratorTest( "com.squareup.test.ContributingInterface contributes a binding, but does not specify " + "the bound type. This is only allowed with exactly one direct super type. If there " + "are multiple or none, then the bound type must be explicitly defined in the " + - "@ContributesBinding annotation." + "@ContributesBinding annotation.", ) } } @@ -330,7 +331,7 @@ class ContributesBindingGeneratorTest( assertThat(exitCode).isError() assertThat(messages).contains( "com.squareup.test.ContributingInterface contributes a binding for " + - "com.squareup.test.ParentInterface, but doesn't extend this type." + "com.squareup.test.ParentInterface, but doesn't extend this type.", ) } } @@ -449,7 +450,7 @@ class ContributesBindingGeneratorTest( "com.squareup.test.ContributingInterface contributes multiple times to the same scope " + "using the same bound type: [ParentInterface]. Contributing multiple times to the " + "same scope with the same bound type is forbidden and all scope - bound type " + - "combinations must be distinct." + "combinations must be distinct.", ) } } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesMultibindingGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesMultibindingGeneratorTest.kt index 6a3969047..837fc5b35 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesMultibindingGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesMultibindingGeneratorTest.kt @@ -23,12 +23,13 @@ import org.junit.runners.Parameterized @Suppress("RemoveRedundantQualifierName") @RunWith(Parameterized::class) class ContributesMultibindingGeneratorTest( - private val mode: AnvilCompilationMode + private val mode: AnvilCompilationMode, ) { companion object { @Parameterized.Parameters(name = "{0}") - @JvmStatic fun modes(): Collection { + @JvmStatic + fun modes(): Collection { return buildList { add(AnvilCompilationMode.Embedded()) if (includeKspTests()) { @@ -173,7 +174,7 @@ class ContributesMultibindingGeneratorTest( val visibilities = setOf( "internal", "private", - "protected" + "protected", ) visibilities.forEach { visibility -> @@ -187,14 +188,14 @@ class ContributesMultibindingGeneratorTest( @ContributesMultibinding(Any::class, ParentInterface::class) $visibility class ContributingInterface : ParentInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. assertThat(messages).contains("Source0.kt:8") assertThat(messages).contains( "com.squareup.test.ContributingInterface is binding a type, but the class is not " + - "public. Only public types are supported." + "public. Only public types are supported.", ) } } @@ -225,7 +226,7 @@ class ContributesMultibindingGeneratorTest( ) { assertThat(exitCode).isError() assertThat(messages).contains( - "Classes annotated with @ContributesMultibinding may not use more than one @Qualifier." + "Classes annotated with @ContributesMultibinding may not use more than one @Qualifier.", ) } } @@ -249,7 +250,7 @@ class ContributesMultibindingGeneratorTest( "com.squareup.test.ContributingInterface contributes a binding, but does not specify " + "the bound type. This is only allowed with exactly one direct super type. If there " + "are multiple or none, then the bound type must be explicitly defined in the " + - "@ContributesMultibinding annotation." + "@ContributesMultibinding annotation.", ) } } @@ -275,7 +276,7 @@ class ContributesMultibindingGeneratorTest( "com.squareup.test.ContributingInterface contributes a binding, but does not specify " + "the bound type. This is only allowed with exactly one direct super type. If there " + "are multiple or none, then the bound type must be explicitly defined in the " + - "@ContributesMultibinding annotation." + "@ContributesMultibinding annotation.", ) } } @@ -297,7 +298,7 @@ class ContributesMultibindingGeneratorTest( "com.squareup.test.ContributingInterface contributes a binding, but does not specify " + "the bound type. This is only allowed with exactly one direct super type. If there " + "are multiple or none, then the bound type must be explicitly defined in the " + - "@ContributesMultibinding annotation." + "@ContributesMultibinding annotation.", ) } } @@ -342,7 +343,7 @@ class ContributesMultibindingGeneratorTest( assertThat(exitCode).isError() assertThat(messages).contains( "com.squareup.test.ContributingInterface contributes a binding for " + - "com.squareup.test.ParentInterface, but doesn't extend this type." + "com.squareup.test.ParentInterface, but doesn't extend this type.", ) } } @@ -414,7 +415,7 @@ class ContributesMultibindingGeneratorTest( @MergeComponent(Any::class) interface ComponentInterface """, - mode = localMode + mode = localMode, ) { assertThat(exitCode).isEqualTo(OK) assertThat(contributingInterface.hintMultibindingScope).isEqualTo(Any::class) @@ -472,7 +473,7 @@ class ContributesMultibindingGeneratorTest( @MergeComponent(Any::class) interface ComponentInterface """, - mode = localMode + mode = localMode, ) { assertThat(exitCode).isEqualTo(OK) assertThat(contributingInterface.hintMultibindingScope).isEqualTo(Any::class) @@ -572,7 +573,7 @@ class ContributesMultibindingGeneratorTest( "com.squareup.test.ContributingInterface contributes multiple times to the same scope " + "using the same bound type: [ParentInterface]. Contributing multiple times to the " + "same scope with the same bound type is forbidden and all scope - bound type " + - "combinations must be distinct." + "combinations must be distinct.", ) } } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentGeneratorTest.kt index b1ab3e0fb..387614d39 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentGeneratorTest.kt @@ -22,7 +22,7 @@ class ContributesSubcomponentGeneratorTest { @ContributesSubcomponent(Any::class, Unit::class) interface SubcomponentInterface - """ + """, ) { assertThat(subcomponentInterface.hintSubcomponent?.java).isEqualTo(subcomponentInterface) assertThat(subcomponentInterface.hintSubcomponentParentScope).isEqualTo(Unit::class) @@ -44,7 +44,7 @@ class ContributesSubcomponentGeneratorTest { @ContributesSubcomponent(Any::class, Unit::class) abstract class SubcomponentInterface - """ + """, ) { assertThat(subcomponentInterface.hintSubcomponent?.java).isEqualTo(subcomponentInterface) assertThat(subcomponentInterface.hintSubcomponentParentScope).isEqualTo(Unit::class) @@ -60,7 +60,7 @@ class ContributesSubcomponentGeneratorTest { @ContributesSubcomponent(parentScope = Unit::class, scope = Any::class) interface SubcomponentInterface - """ + """, ) { assertThat(subcomponentInterface.hintSubcomponent?.java).isEqualTo(subcomponentInterface) assertThat(subcomponentInterface.hintSubcomponentParentScope).isEqualTo(Unit::class) @@ -78,7 +78,7 @@ class ContributesSubcomponentGeneratorTest { @ContributesSubcomponent(Any::class, Unit::class) interface SubcomponentInterface } - """ + """, ) { val subcomponentInterface = classLoader .loadClass("com.squareup.test.Outer\$SubcomponentInterface") @@ -102,14 +102,14 @@ class ContributesSubcomponentGeneratorTest { @ContributesSubcomponent(Any::class, Unit::class) class SubcomponentInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. assertThat(messages).contains("Source0.kt:6:") assertThat(messages).contains( "com.squareup.test.SubcomponentInterface is annotated with @ContributesSubcomponent, " + - "but this class is not an interface." + "but this class is not an interface.", ) } @@ -121,14 +121,14 @@ class ContributesSubcomponentGeneratorTest { @ContributesSubcomponent(Any::class, Unit::class) object SubcomponentInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. assertThat(messages).contains("Source0.kt:6:") assertThat(messages).contains( "com.squareup.test.SubcomponentInterface is annotated with @ContributesSubcomponent, " + - "but this class is not an interface." + "but this class is not an interface.", ) } } @@ -137,7 +137,7 @@ class ContributesSubcomponentGeneratorTest { val visibilities = setOf( "internal", "private", - "protected" + "protected", ) visibilities.forEach { visibility -> @@ -149,14 +149,14 @@ class ContributesSubcomponentGeneratorTest { @ContributesSubcomponent(Any::class, Unit::class) $visibility interface SubcomponentInterface - """ + """, ) { assertThat(exitCode).isError() // Position to the class. assertThat(messages).contains("Source0.kt:6:") assertThat(messages).contains( "com.squareup.test.SubcomponentInterface is contributed to the Dagger graph, but the " + - "interface is not public. Only public interfaces are supported." + "interface is not public. Only public interfaces are supported.", ) } } @@ -178,7 +178,7 @@ class ContributesSubcomponentGeneratorTest { fun createComponent(): SubcomponentInterface } } - """ + """, ) { val parentComponent = subcomponentInterface.parentComponentInterface assertThat(parentComponent).isNotNull() @@ -208,13 +208,13 @@ class ContributesSubcomponentGeneratorTest { fun createComponent(): SubcomponentInterface } } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:7:11") assertThat(messages).contains( "Expected zero or one parent component interface within " + - "com.squareup.test.SubcomponentInterface being contributed to the parent scope." + "com.squareup.test.SubcomponentInterface being contributed to the parent scope.", ) } } @@ -236,13 +236,13 @@ class ContributesSubcomponentGeneratorTest { fun createComponent2(): SubcomponentInterface } } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:9:13") assertThat(messages).contains( "Expected zero or one function returning the subcomponent " + - "com.squareup.test.SubcomponentInterface." + "com.squareup.test.SubcomponentInterface.", ) } } @@ -268,12 +268,12 @@ class ContributesSubcomponentGeneratorTest { fun createComponent(): SubcomponentInterface } } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:8:11") assertThat(messages).contains( - "Expected zero or one factory within com.squareup.test.SubcomponentInterface." + "Expected zero or one factory within com.squareup.test.SubcomponentInterface.", ) } } @@ -295,7 +295,7 @@ class ContributesSubcomponentGeneratorTest { fun createComponent(): SubcomponentInterface = throw NotImplementedError() } } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:10:3") @@ -317,7 +317,7 @@ class ContributesSubcomponentGeneratorTest { fun createComponent(): SubcomponentInterface = throw NotImplementedError() } } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:10:9") @@ -340,13 +340,13 @@ class ContributesSubcomponentGeneratorTest { @Factory interface ComponentFactory } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:10:13") assertThat(messages).contains( "A factory must have exactly one abstract function returning the subcomponent " + - "com.squareup.test.SubcomponentInterface." + "com.squareup.test.SubcomponentInterface.", ) } } @@ -369,13 +369,13 @@ class ContributesSubcomponentGeneratorTest { fun createComponent2(): SubcomponentInterface } } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:10:13") assertThat(messages).contains( "A factory must have exactly one abstract function returning the subcomponent " + - "com.squareup.test.SubcomponentInterface." + "com.squareup.test.SubcomponentInterface.", ) } } @@ -397,13 +397,13 @@ class ContributesSubcomponentGeneratorTest { fun createComponent(): SubcomponentInterface = throw NotImplementedError() } } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:10:18") assertThat(messages).contains( "A factory must have exactly one abstract function returning the subcomponent " + - "com.squareup.test.SubcomponentInterface." + "com.squareup.test.SubcomponentInterface.", ) } } @@ -424,14 +424,14 @@ class ContributesSubcomponentGeneratorTest { fun createComponent(): SubcomponentInterface } } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:9:13") assertThat(messages).contains( "Within a class using @ContributesSubcomponent you must use " + "com.squareup.anvil.annotations.ContributesSubcomponent.Factory and not " + - "dagger.Subcomponent.Factory." + "dagger.Subcomponent.Factory.", ) } } @@ -452,14 +452,14 @@ class ContributesSubcomponentGeneratorTest { fun createComponent(): SubcomponentInterface } } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:9:13") assertThat(messages).contains( "Within a class using @ContributesSubcomponent you must use " + "com.squareup.anvil.annotations.ContributesSubcomponent.Factory and not " + - "dagger.Subcomponent.Builder. Builders aren't supported." + "dagger.Subcomponent.Builder. Builders aren't supported.", ) } } @@ -483,7 +483,7 @@ class ContributesSubcomponentGeneratorTest { replaces = [SubcomponentInterface1::class] ) interface SubcomponentInterface2 - """ + """, ) { assertThat(subcomponentInterface1.hintSubcomponent?.java).isEqualTo(subcomponentInterface1) assertThat(subcomponentInterface1.hintSubcomponentParentScope).isEqualTo(Unit::class) @@ -512,14 +512,14 @@ class ContributesSubcomponentGeneratorTest { replaces = [SubcomponentInterface1::class] ) interface SubcomponentInterface2 - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Source0.kt:16:11") assertThat(messages).contains( "com.squareup.test.SubcomponentInterface2 with scope kotlin.Any wants to replace " + "com.squareup.test.SubcomponentInterface1 with scope kotlin.Long. The replacement " + - "must use the same scope." + "must use the same scope.", ) } } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentHandlerGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentHandlerGeneratorTest.kt index 89451e2bb..cfd79751f 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentHandlerGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesSubcomponentHandlerGeneratorTest.kt @@ -42,7 +42,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val anvilComponent = subcomponentInterface.anvilComponent(componentInterface) assertThat(anvilComponent).isNotNull() @@ -66,7 +66,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeSubcomponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val anvilComponent = subcomponentInterface.anvilComponent(componentInterface) assertThat(anvilComponent).isNotNull() @@ -91,7 +91,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeInterfaces(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val anvilComponent = subcomponentInterface.anvilComponent(componentInterface) assertThat(anvilComponent).isNotNull() @@ -103,7 +103,7 @@ class ContributesSubcomponentHandlerGeneratorTest { assertThat( componentInterface extends subcomponentInterface .anvilComponent(componentInterface) - .parentComponentInterface + .parentComponentInterface, ).isTrue() } } @@ -121,7 +121,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeModules(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { assertThat(exitCode).isEqualTo(OK) @@ -144,7 +144,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { assertThat(exitCode).isEqualTo(OK) @@ -169,7 +169,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val subcomponentInterface = classLoader .loadClass("com.squareup.test.Outer\$SubcomponentInterface") @@ -199,10 +199,10 @@ class ContributesSubcomponentHandlerGeneratorTest { interface ComponentInterface } - """.trimIndent() + """.trimIndent(), ) { val anvilComponent = subcomponentInterface.anvilComponent( - classLoader.loadClass("com.squareup.test.Outer\$ComponentInterface") + classLoader.loadClass("com.squareup.test.Outer\$ComponentInterface"), ) assertThat(anvilComponent).isNotNull() @@ -232,7 +232,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @ContributesSubcomponent(Long::class, parentScope = Int::class) interface SubcomponentInterface3 - """.trimIndent() + """.trimIndent(), ) { var parentComponentInterface = componentInterface @@ -260,7 +260,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @ContributesSubcomponent(Any::class, parentScope = Unit::class) interface SubcomponentInterface1 - """.trimIndent() + """.trimIndent(), ) { assertThat(exitCode).isEqualTo(OK) } @@ -278,7 +278,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Int::class) interface ComponentInterface """.trimIndent(), - previousCompilationResult = firstCompilationResult + previousCompilationResult = firstCompilationResult, ) { val anvilComponent = classLoader .loadClass("com.squareup.test.SubcomponentInterface2") @@ -312,7 +312,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val annotation = subcomponentInterface.anvilComponent(componentInterface) .getAnnotation(MergeSubcomponent::class.java) @@ -338,7 +338,7 @@ class ContributesSubcomponentHandlerGeneratorTest { modules = [DaggerModule1::class] ) interface SubcomponentInterface - """.trimIndent() + """.trimIndent(), ) { assertThat(exitCode).isEqualTo(OK) } @@ -352,7 +352,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface """.trimIndent(), - previousCompilationResult = firstCompilationResult + previousCompilationResult = firstCompilationResult, ) { val annotation = subcomponentInterface.anvilComponent(componentInterface) .getAnnotation(MergeSubcomponent::class.java) @@ -395,13 +395,15 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val annotation = subcomponentInterface.anvilComponent(componentInterface) .getAnnotation(MergeSubcomponent::class.java) assertThat(annotation.exclude.toList()).containsExactly( - daggerModule1.kotlin, contributingInterface.kotlin, secondContributingInterface.kotlin + daggerModule1.kotlin, + contributingInterface.kotlin, + secondContributingInterface.kotlin, ) } } @@ -437,7 +439,7 @@ class ContributesSubcomponentHandlerGeneratorTest { ] ) interface SubcomponentInterface - """.trimIndent() + """.trimIndent(), ) { assertThat(exitCode).isEqualTo(OK) } @@ -451,13 +453,15 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface """.trimIndent(), - previousCompilationResult = firstCompilationResult + previousCompilationResult = firstCompilationResult, ) { val annotation = subcomponentInterface.anvilComponent(componentInterface) .getAnnotation(MergeSubcomponent::class.java) assertThat(annotation.exclude.toList()).containsExactly( - daggerModule1.kotlin, contributingInterface.kotlin, secondContributingInterface.kotlin + daggerModule1.kotlin, + contributingInterface.kotlin, + secondContributingInterface.kotlin, ) } } @@ -476,7 +480,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val parentComponent = subcomponentInterface.anvilComponent(componentInterface).parentComponentInterface @@ -510,7 +514,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val parentComponent = subcomponentInterface.anvilComponent(componentInterface).parentComponentInterface @@ -523,7 +527,7 @@ class ContributesSubcomponentHandlerGeneratorTest { .isEqualTo("createComponent") assertThat( - parentComponent extends subcomponentInterface.anyParentComponentInterface + parentComponent extends subcomponentInterface.anyParentComponentInterface, ).isTrue() assertThat(componentInterface extends parentComponent).isTrue() @@ -547,7 +551,7 @@ class ContributesSubcomponentHandlerGeneratorTest { fun integer(): Int } } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -561,7 +565,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface """, - previousCompilationResult = firstCompilationResult + previousCompilationResult = firstCompilationResult, ) { val parentComponent = subcomponentInterface.anvilComponent(componentInterface).parentComponentInterface @@ -574,7 +578,7 @@ class ContributesSubcomponentHandlerGeneratorTest { .isEqualTo("createComponent") assertThat( - parentComponent extends subcomponentInterface.anyParentComponentInterface + parentComponent extends subcomponentInterface.anyParentComponentInterface, ).isTrue() assertThat(componentInterface extends parentComponent).isTrue() @@ -601,12 +605,12 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val parentComponent = subcomponentInterface.anvilComponent(componentInterface).parentComponentInterface assertThat( - parentComponent extends subcomponentInterface.anyParentComponentInterface + parentComponent extends subcomponentInterface.anyParentComponentInterface, ).isFalse() } } @@ -644,7 +648,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface """, - enableDaggerAnnotationProcessor = true + enableDaggerAnnotationProcessor = true, ) { val daggerComponent = componentInterface.daggerComponent.declaredMethods .single { it.name == "create" } @@ -702,18 +706,18 @@ class ContributesSubcomponentHandlerGeneratorTest { interface ComponentInterface2 """, // Keep Dagger enabled, because it complained initially. - enableDaggerAnnotationProcessor = true + enableDaggerAnnotationProcessor = true, ) { assertThat(componentInterface1 extends subcomponentInterface1.anyParentComponentInterface) assertThat( componentInterface1 extends - subcomponentInterface1.anvilComponent(componentInterface1).parentComponentInterface + subcomponentInterface1.anvilComponent(componentInterface1).parentComponentInterface, ) assertThat(componentInterface2 extends subcomponentInterface2.anyParentComponentInterface) assertThat( componentInterface2 extends - subcomponentInterface2.anvilComponent(componentInterface2).parentComponentInterface + subcomponentInterface2.anvilComponent(componentInterface2).parentComponentInterface, ) // Note that NOT subcomponentInterface2 extends these parent component interface, but its @@ -722,8 +726,8 @@ class ContributesSubcomponentHandlerGeneratorTest { assertThat( subcomponentInterface2.anvilComponent(componentInterface2) extends subcomponentInterface1.anvilComponent( - subcomponentInterface2.anvilComponent(componentInterface2) - ).parentComponentInterface + subcomponentInterface2.anvilComponent(componentInterface2), + ).parentComponentInterface, ) } } @@ -744,7 +748,7 @@ class ContributesSubcomponentHandlerGeneratorTest { exclude = [SubcomponentInterface::class] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isEqualTo(OK) @@ -772,7 +776,7 @@ class ContributesSubcomponentHandlerGeneratorTest { exclude = [SubcomponentInterface::class] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isEqualTo(OK) @@ -800,7 +804,7 @@ class ContributesSubcomponentHandlerGeneratorTest { exclude = [SubcomponentInterface::class] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isEqualTo(OK) @@ -832,7 +836,7 @@ class ContributesSubcomponentHandlerGeneratorTest { scope = Any::class, ) interface ContributingInterface - """ + """, ) { // Fails because the component is never generated. assertFailsWith { @@ -843,7 +847,7 @@ class ContributesSubcomponentHandlerGeneratorTest { contributingInterface extends subcomponentInterface .anvilComponent(contributingInterface) - .parentComponentInterface + .parentComponentInterface, ).isTrue() } } @@ -864,13 +868,13 @@ class ContributesSubcomponentHandlerGeneratorTest { exclude = [SubcomponentInterface::class] ) interface ComponentInterface - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "com.squareup.test.ComponentInterface with scopes [kotlin.Any] wants to exclude " + "com.squareup.test.SubcomponentInterface, but the excluded class isn't contributed " + - "to the same scope." + "to the same scope.", ) } } @@ -901,7 +905,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val createFactoryFunction = subcomponentInterface.anvilComponent(componentInterface) .parentComponentInterface @@ -914,7 +918,7 @@ class ContributesSubcomponentHandlerGeneratorTest { assertThat( subcomponentInterface.anvilComponent(componentInterface).generatedFactory extends - subcomponentInterface.componentFactory + subcomponentInterface.componentFactory, ).isTrue() } } @@ -945,7 +949,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val createFactoryFunction = subcomponentInterface.anvilComponent(componentInterface) .parentComponentInterface @@ -958,7 +962,7 @@ class ContributesSubcomponentHandlerGeneratorTest { assertThat( subcomponentInterface.anvilComponent(componentInterface).generatedFactory extends - subcomponentInterface.componentFactory + subcomponentInterface.componentFactory, ).isTrue() } } @@ -983,7 +987,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val parentComponent = subcomponentInterface.anvilComponent(componentInterface).parentComponentInterface @@ -996,7 +1000,7 @@ class ContributesSubcomponentHandlerGeneratorTest { assertThat( subcomponentInterface.anvilComponent(componentInterface).generatedFactory extends - subcomponentInterface.componentFactory + subcomponentInterface.componentFactory, ).isTrue() } } @@ -1034,7 +1038,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface """, - enableDaggerAnnotationProcessor = true + enableDaggerAnnotationProcessor = true, ) { val daggerComponent = componentInterface.daggerComponent.declaredMethods .single { it.name == "create" } @@ -1094,7 +1098,7 @@ class ContributesSubcomponentHandlerGeneratorTest { class TestClass @Inject constructor(val factory: SubcomponentInterface.ComponentFactory) """, - enableDaggerAnnotationProcessor = true + enableDaggerAnnotationProcessor = true, ) { val daggerComponent = componentInterface.daggerComponent.declaredMethods .single { it.name == "create" } @@ -1156,7 +1160,7 @@ class ContributesSubcomponentHandlerGeneratorTest { class TestClass @Inject constructor(val factory: SubcomponentInterface.ComponentFactory) """, - enableDaggerAnnotationProcessor = true + enableDaggerAnnotationProcessor = true, ) { val daggerComponent = componentInterface2.daggerComponent.declaredMethods .single { it.name == "create" } @@ -1221,12 +1225,12 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface1 """.trimIndent(), - enableDaggerAnnotationProcessor = true + enableDaggerAnnotationProcessor = true, ) { assertThat(exitCode).isEqualTo(OK) assertThat( - componentInterface1 extends subcomponentInterface.anyParentComponentInterface + componentInterface1 extends subcomponentInterface.anyParentComponentInterface, ).isTrue() } @@ -1240,7 +1244,7 @@ class ContributesSubcomponentHandlerGeneratorTest { interface ComponentInterface2 """.trimIndent(), previousCompilationResult = firstCompilationResult, - enableDaggerAnnotationProcessor = true + enableDaggerAnnotationProcessor = true, ) { assertThat(exitCode).isEqualTo(OK) @@ -1291,7 +1295,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface2 - """ + """, ) { val modules1 = componentInterface1.getAnnotation(Component::class.java).modules.toList() val modules2 = componentInterface2.getAnnotation(Component::class.java).modules.toList() @@ -1354,7 +1358,7 @@ class ContributesSubcomponentHandlerGeneratorTest { class TestClass @Inject constructor(val factory: SubcomponentInterface.ComponentFactory) """, - enableDaggerAnnotationProcessor = true + enableDaggerAnnotationProcessor = true, ) { val daggerComponent1 = componentInterface1.daggerComponent.declaredMethods .single { it.name == "create" } @@ -1403,7 +1407,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val anvilComponent = subcomponentInterface.anvilComponent(componentInterface) assertThat(anvilComponent).isNotNull() @@ -1435,7 +1439,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """.trimIndent() + """.trimIndent(), ) { val anvilComponent = subcomponentInterface.anvilComponent(componentInterface) assertThat(anvilComponent).isNotNull() @@ -1485,7 +1489,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface1 """, - enableDaggerAnnotationProcessor = true + enableDaggerAnnotationProcessor = true, ) { val daggerComponent = componentInterface1.daggerComponent.declaredMethods .single { it.name == "create" } @@ -1532,7 +1536,7 @@ class ContributesSubcomponentHandlerGeneratorTest { interface ComponentInterface2 """, enableDaggerAnnotationProcessor = true, - previousCompilationResult = firstResult + previousCompilationResult = firstResult, ) { val daggerComponent = componentInterface2.daggerComponent.declaredMethods .single { it.name == "create" } @@ -1576,7 +1580,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Any::class) interface ComponentInterface2 - """ + """, ) { val parentComponentInterface1 = subcomponentInterface .anvilComponent(componentInterface1) @@ -1621,7 +1625,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @ContributesSubcomponent(scope = Any::class, parentScope = Unit::class) interface SubcomponentInterfacewithVeryVeryVeryVeryVeryVeryVeryLongName """, - enableDaggerAnnotationProcessor = true + enableDaggerAnnotationProcessor = true, ) { assertThat(exitCode).isEqualTo(OK) } @@ -1664,7 +1668,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface """, - codeGenerators = listOf(codeGenerator) + codeGenerators = listOf(codeGenerator), ) { val parentComponentInterface1 = subcomponentInterface1 .anvilComponent(componentInterface) @@ -1726,7 +1730,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface """, - codeGenerators = listOf(codeGenerator) + codeGenerators = listOf(codeGenerator), ) { val parentComponentInterface1 = subcomponentInterface1 .anvilComponent(componentInterface) @@ -1763,7 +1767,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """ + """, ) { val parentComponentInterface2 = subcomponentInterface2 .anvilComponent(componentInterface) @@ -1819,7 +1823,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """ + """, ) { val annotation = subcomponentInterface2.anvilComponent(componentInterface) .getAnnotation(MergeSubcomponent::class.java) @@ -1858,7 +1862,7 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface - """ + """, ) { val parentComponentInterface2 = subcomponentInterface2 .anvilComponent(componentInterface) @@ -1880,7 +1884,7 @@ class ContributesSubcomponentHandlerGeneratorTest { subcomponentInterface2 .anvilComponent(componentInterface) .interfaces - .toList() + .toList(), ).containsExactly(subcomponentInterface2) } } @@ -1928,13 +1932,13 @@ class ContributesSubcomponentHandlerGeneratorTest { @MergeComponent(Unit::class) interface ComponentInterface """, - codeGenerators = listOf(codeGenerator) + codeGenerators = listOf(codeGenerator), ) { assertThat(exitCode).isError() assertThat(messages).contains( "com.squareup.test.SubcomponentInterface2 tries to replace " + "com.squareup.test.SubcomponentInterface1, but the code for " + - "com.squareup.test.SubcomponentInterface1 was already generated. This is not supported." + "com.squareup.test.SubcomponentInterface1 was already generated. This is not supported.", ) } } @@ -1961,7 +1965,7 @@ class ContributesSubcomponentHandlerGeneratorTest { .joinToString(separator = "_") { it.simpleName } return classLoader.loadClass( - "$packagePrefix$packageName$packageSuffix.$className$ANVIL_SUBCOMPONENT_SUFFIX" + "$packagePrefix$packageName$packageSuffix.$className$ANVIL_SUBCOMPONENT_SUFFIX", ) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesToCodeGenTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesToCodeGenTest.kt index 882f538a7..ed251f594 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesToCodeGenTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ContributesToCodeGenTest.kt @@ -26,7 +26,8 @@ class ContributesToCodeGenTest( companion object { @Parameterized.Parameters(name = "{0}") - @JvmStatic fun modes(): Collection { + @JvmStatic + fun modes(): Collection { return listOf(AnvilCompilationMode.Embedded(), AnvilCompilationMode.Ksp()) } } @@ -192,7 +193,7 @@ class ContributesToCodeGenTest( assertThat(messages).contains( "com.squareup.test.DaggerModule1 contributes multiple times to the same scope: " + "[Any, Unit]. Contributing multiple times to the same scope is forbidden and all " + - "scopes must be distinct." + "scopes must be distinct.", ) } } @@ -313,7 +314,7 @@ class ContributesToCodeGenTest( assertThat(messages).contains("Source0.kt:6") assertThat(messages).contains( "com.squareup.test.DaggerModule1 is annotated with @ContributesTo, but this class " + - "is neither an interface nor a Dagger module. Did you forget to add @Module?" + "is neither an interface nor a Dagger module. Did you forget to add @Module?", ) } } @@ -322,7 +323,7 @@ class ContributesToCodeGenTest( val visibilities = setOf( "internal", "private", - "protected" + "protected", ) visibilities.forEach { visibility -> @@ -343,7 +344,7 @@ class ContributesToCodeGenTest( assertThat(messages).contains("Source0.kt:7") assertThat(messages).contains( "com.squareup.test.DaggerModule1 is contributed to the Dagger graph, but the " + - "module is not public. Only public modules are supported." + "module is not public. Only public modules are supported.", ) } } @@ -353,7 +354,7 @@ class ContributesToCodeGenTest( val visibilities = setOf( "internal", "private", - "protected" + "protected", ) visibilities.forEach { visibility -> @@ -373,7 +374,7 @@ class ContributesToCodeGenTest( assertThat(messages).contains("Source0.kt:6") assertThat(messages).contains( "com.squareup.test.ContributingInterface is contributed to the Dagger graph, but the " + - "module is not public. Only public modules are supported." + "module is not public. Only public modules are supported.", ) } } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ksp/SimpleSymbolProcessor.kt b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ksp/SimpleSymbolProcessor.kt index 4d1fa94fe..030ac94d0 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ksp/SimpleSymbolProcessor.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/codegen/ksp/SimpleSymbolProcessor.kt @@ -11,14 +11,14 @@ import java.io.OutputStreamWriter import java.nio.charset.StandardCharsets internal fun simpleSymbolProcessor( - mapper: AnvilSymbolProcessor.(resolver: Resolver) -> List + mapper: AnvilSymbolProcessor.(resolver: Resolver) -> List, ): SymbolProcessorProvider = AnvilSymbolProcessorProvider( - AnvilApplicabilityChecker.always() + AnvilApplicabilityChecker.always(), ) { env -> SimpleSymbolProcessor(env, mapper) } private class SimpleSymbolProcessor( override val env: SymbolProcessorEnvironment, - private val mapper: AnvilSymbolProcessor.(resolver: Resolver) -> List + private val mapper: AnvilSymbolProcessor.(resolver: Resolver) -> List, ) : AnvilSymbolProcessor() { override fun processChecked(resolver: Resolver): List { this.mapper(resolver) diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AnvilAnnotationDetectorCheckTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AnvilAnnotationDetectorCheckTest.kt index c95beb0c2..519c0c4ee 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AnvilAnnotationDetectorCheckTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AnvilAnnotationDetectorCheckTest.kt @@ -18,7 +18,7 @@ class AnvilAnnotationDetectorCheckTest { @dagger.Subcomponent interface ComponentInterface - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -33,7 +33,7 @@ class AnvilAnnotationDetectorCheckTest { @com.squareup.anvil.annotations.ContributesTo(Any::class) class AnyClass - """ + """, ) { assertError() } @@ -48,7 +48,7 @@ class AnvilAnnotationDetectorCheckTest { @com.squareup.anvil.annotations.ContributesBinding(Any::class) class AnyClass - """ + """, ) { assertError() } @@ -63,7 +63,7 @@ class AnvilAnnotationDetectorCheckTest { @com.squareup.anvil.annotations.ContributesSubcomponent(Any::class, Unit::class) class AnyClass - """ + """, ) { assertError() } @@ -78,7 +78,7 @@ class AnvilAnnotationDetectorCheckTest { @com.squareup.anvil.annotations.MergeComponent(Any::class) class AnyClass - """ + """, ) { assertError() } @@ -93,7 +93,7 @@ class AnvilAnnotationDetectorCheckTest { @com.squareup.anvil.annotations.MergeSubcomponent(Any::class) class AnyClass - """ + """, ) { assertError() } @@ -108,7 +108,7 @@ class AnvilAnnotationDetectorCheckTest { @com.squareup.anvil.annotations.compat.MergeModules(Any::class) class AnyClass - """ + """, ) { assertError() } @@ -123,7 +123,7 @@ class AnvilAnnotationDetectorCheckTest { @com.squareup.anvil.annotations.compat.MergeInterfaces(Any::class) class AnyClass - """ + """, ) { assertError() } @@ -135,18 +135,18 @@ class AnvilAnnotationDetectorCheckTest { assertThat(messages).contains( "This Gradle module is configured to ONLY generate Dagger factories with the " + "`generateDaggerFactoriesOnly` flag. However, this module contains code that uses " + - "other Anvil annotations. That's not supported." + "other Anvil annotations. That's not supported.", ) } private fun compile( @Language("kotlin") vararg sources: String, - block: JvmCompilationResult.() -> Unit = { } + block: JvmCompilationResult.() -> Unit = { }, ): JvmCompilationResult = compileAnvil( sources = sources, generateDaggerFactories = true, generateDaggerFactoriesOnly = true, allWarningsAsErrors = WARNINGS_AS_ERRORS, - block = block + block = block, ) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AnvilMergeAnnotationDetectorCheckTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AnvilMergeAnnotationDetectorCheckTest.kt index f62c7f976..e78a79e69 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AnvilMergeAnnotationDetectorCheckTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AnvilMergeAnnotationDetectorCheckTest.kt @@ -15,12 +15,13 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) class AnvilMergeAnnotationDetectorCheckTest( - private val mode: AnvilCompilationMode + private val mode: AnvilCompilationMode, ) { companion object { @Parameterized.Parameters(name = "{0}") - @JvmStatic fun modes(): Collection { + @JvmStatic + fun modes(): Collection { return listOf(AnvilCompilationMode.Embedded(), AnvilCompilationMode.Ksp()) } } @@ -36,7 +37,7 @@ class AnvilMergeAnnotationDetectorCheckTest( @com.squareup.anvil.annotations.ContributesTo(Any::class) object AnyClass """, - mode = mode + mode = mode, ) { assertThat(exitCode).isEqualTo(OK) } @@ -52,7 +53,7 @@ class AnvilMergeAnnotationDetectorCheckTest( @com.squareup.anvil.annotations.ContributesBinding(Any::class) class AnyClass : BaseType """, - mode = mode + mode = mode, ) { assertThat(exitCode).isEqualTo(OK) } @@ -68,7 +69,7 @@ class AnvilMergeAnnotationDetectorCheckTest( @com.squareup.anvil.annotations.MergeComponent(Any::class) class AnyClass """, - mode = mode + mode = mode, ) { assertError() } @@ -84,7 +85,7 @@ class AnvilMergeAnnotationDetectorCheckTest( @com.squareup.anvil.annotations.MergeSubcomponent(Any::class) class AnyClass """, - mode = mode + mode = mode, ) { assertError() } @@ -100,7 +101,7 @@ class AnvilMergeAnnotationDetectorCheckTest( @com.squareup.anvil.annotations.compat.MergeModules(Any::class) class AnyClass """, - mode = mode + mode = mode, ) { assertError() } @@ -116,7 +117,7 @@ class AnvilMergeAnnotationDetectorCheckTest( @com.squareup.anvil.annotations.compat.MergeInterfaces(Any::class) class AnyClass """, - mode = mode + mode = mode, ) { assertError() } @@ -128,7 +129,7 @@ class AnvilMergeAnnotationDetectorCheckTest( assertThat(messages).contains( "This Gradle module is configured to ONLY generate code with the " + "`disableComponentMerging` flag. However, this module contains code that uses " + - "Anvil @Merge* annotations. That's not supported." + "Anvil @Merge* annotations. That's not supported.", ) } @@ -136,12 +137,12 @@ class AnvilMergeAnnotationDetectorCheckTest( @Language("kotlin") vararg sources: String, codeGenerators: List = emptyList(), mode: AnvilCompilationMode = AnvilCompilationMode.Embedded(codeGenerators), - block: JvmCompilationResult.() -> Unit = { } + block: JvmCompilationResult.() -> Unit = { }, ): JvmCompilationResult = compileAnvil( sources = sources, disableComponentMerging = true, allWarningsAsErrors = WARNINGS_AS_ERRORS, block = block, - mode = mode + mode = mode, ) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedFactoryGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedFactoryGeneratorTest.kt index 8690c6ebf..7b65d7649 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedFactoryGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedFactoryGeneratorTest.kt @@ -26,12 +26,13 @@ import javax.inject.Provider @RunWith(Parameterized::class) class AssistedFactoryGeneratorTest( - private val useDagger: Boolean + private val useDagger: Boolean, ) { companion object { @Parameters(name = "Use Dagger: {0}") - @JvmStatic fun useDagger(): Collection { + @JvmStatic + fun useDagger(): Collection { return listOf(isFullTestRun(), false).distinct() } } @@ -127,7 +128,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(string: String): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass() @@ -175,7 +176,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory charSequence: CharSequence ): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -218,7 +219,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory @AssistedFactory interface AssistedServiceFactory : AssistedServiceFactorySuper - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -262,7 +263,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory @AssistedFactory interface AssistedServiceFactory : Mid - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -302,7 +303,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(stringFactory: (Int) -> String): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -344,7 +345,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(stringFactory: suspend (Int) -> String): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -386,7 +387,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(stringFactory: Function1): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -428,7 +429,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(stringFactory: (Int) -> String): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -470,7 +471,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(callback: ((Int) -> String)?): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance() @@ -511,7 +512,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(stringFactory: Function1): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -553,7 +554,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory @AssistedFactory interface AssistedServiceFactory : ReadOnlyProperty - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance() @@ -591,7 +592,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory @AssistedFactory interface AssistedServiceFactory : Function1<@JvmSuppressWildcards List, AssistedService> - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -634,7 +635,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory @AssistedFactory interface AssistedServiceFactory : AssistedServiceFactorySuper - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -674,7 +675,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory abstract class AssistedServiceFactory { abstract fun create(string: String): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -714,7 +715,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory abstract class AssistedServiceFactory { protected abstract fun create(string: String): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -756,7 +757,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(strings: List): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -865,7 +866,7 @@ public final class AssistedServiceFactory_Impl implement interface AssistedServiceFactory { fun create(string: T): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -905,7 +906,7 @@ public final class AssistedServiceFactory_Impl implement interface AssistedServiceFactory> { fun create(strings: T): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -926,8 +927,8 @@ public final class AssistedServiceFactory_Impl implement assertThat(assistedServiceInstance).isEqualTo( assistedService.createInstance( 5, - listOf("Hello") - ) + listOf("Hello"), + ), ) } } @@ -962,7 +963,7 @@ public final class AssistedServiceFactory_Impl implement interface AssistedServiceFactory where T : Appendable, T : CharSequence { fun create(stringBuilder: T): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -983,8 +984,8 @@ public final class AssistedServiceFactory_Impl implement assertThat(assistedServiceInstance).isEqualTo( assistedService.createInstance( 5, - StringBuilder("Hello") - ) + StringBuilder("Hello"), + ), ) } } @@ -1007,7 +1008,7 @@ public final class AssistedServiceFactory_Impl implement fun create(string: String): AssistedService } } - """ + """, ) { val factoryImplClass = classLoader .loadClass("com.squareup.test.AssistedService\$Factory").implClass() @@ -1050,7 +1051,7 @@ public final class AssistedServiceFactory_Impl implement } } } - """ + """, ) { val factoryImplClass = classLoader .loadClass("com.squareup.test.Outer\$AssistedService\$Factory").implClass() @@ -1159,7 +1160,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(string: String?): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -1197,12 +1198,12 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface Factory { fun create(string: String): AssistedService } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "Invalid return type: com.squareup.test.AssistedService. An assisted factory's " + - "abstract method must return a type with an @AssistedInject-annotated constructor." + "abstract method must return a type with an @AssistedInject-annotated constructor.", ) } } @@ -1223,13 +1224,13 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface Factory { fun create(string: String) } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Invalid return type:") assertThat(messages).contains( "An assisted factory's abstract method must return a type with an " + - "@AssistedInject-annotated constructor." + "@AssistedInject-annotated constructor.", ) } } @@ -1252,12 +1253,12 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(charSequence: CharSequence, other: String): AssistedService } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "The parameters in the factory method must match the @Assisted parameters " + - "in com.squareup.test.AssistedService." + "in com.squareup.test.AssistedService.", ) } } @@ -1280,12 +1281,12 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(charSequence: CharSequence, other: String): AssistedService } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "The parameters in the factory method must match the @Assisted parameters " + - "in com.squareup.test.AssistedService." + "in com.squareup.test.AssistedService.", ) } } @@ -1341,7 +1342,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(long: Long, other: String): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -1390,7 +1391,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory @Assisted("two") long22: Long ): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance() @@ -1432,7 +1433,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(ints: List, strings: List): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance() @@ -1474,7 +1475,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(number: S, string: T): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance() @@ -1493,7 +1494,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory .invoke(factoryImplInstance, 1, "Hello") assertThat(assistedServiceInstance).isEqualTo( - assistedService.createInstance("Hello", 1) + assistedService.createInstance("Hello", 1), ) } } @@ -1519,7 +1520,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory @Assisted("one") string1: String ): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance() @@ -1558,7 +1559,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(string: String): AssistedService } - """ + """, ) { val factoryImplClass = classLoader.loadClass("AssistedServiceFactory").implClass() val generatedFactoryInstance = classLoader.loadClass("AssistedService") @@ -1605,12 +1606,12 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory @Assisted("one") type2: Type ): AssistedService } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "@AssistedFactory method has duplicate @Assisted types: " + - "@Assisted(\"one\") com.squareup.test.Type" + "@Assisted(\"one\") com.squareup.test.Type", ) } } @@ -1634,18 +1635,18 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory fun create(string: String): AssistedService fun create2(string: String): AssistedService } - """ + """, ) { assertThat(exitCode).isError() assertThat( messages.lines() .first { it.startsWith("e:") } .removeParametersAndSort() - .removeNullabilityAnnotations() + .removeNullabilityAnnotations(), ).contains( "The @AssistedFactory-annotated type should contain a single abstract, non-default " + "method but found multiple: [com.squareup.test.AssistedServiceFactory.create, " + - "com.squareup.test.AssistedServiceFactory.create2]" + "com.squareup.test.AssistedServiceFactory.create2]", ) } } @@ -1672,18 +1673,18 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory : AssistedServiceFactory1 { fun create(string: String): AssistedService } - """ + """, ) { assertThat(exitCode).isError() assertThat( messages.lines() .first { it.startsWith("e:") } .removeParametersAndSort() - .removeNullabilityAnnotations() + .removeNullabilityAnnotations(), ).contains( "The @AssistedFactory-annotated type should contain a single abstract, non-default " + "method but found multiple: [com.squareup.test.AssistedServiceFactory.create, " + - "com.squareup.test.AssistedServiceFactory1.createParent]" + "com.squareup.test.AssistedServiceFactory1.createParent]", ) } } @@ -1707,18 +1708,18 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory : Provider{ fun create(string: String): AssistedService } - """ + """, ) { assertThat(exitCode).isError() assertThat( messages.lines() .first { it.startsWith("e:") } .removeParametersAndSort() - .removeNullabilityAnnotations() + .removeNullabilityAnnotations(), ).contains( "The @AssistedFactory-annotated type should contain a single abstract, non-default " + "method but found multiple: [com.squareup.test.AssistedServiceFactory.create, " + - "javax.inject.Provider.get]" + "javax.inject.Provider.get]", ) } } @@ -1751,7 +1752,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory return create() } } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -1773,12 +1774,12 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory @AssistedFactory interface AssistedServiceFactory - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "The @AssistedFactory-annotated type is missing an abstract, non-default method " + - "whose return type matches the assisted injection type." + "whose return type matches the assisted injection type.", ) } } @@ -1801,12 +1802,12 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory abstract class AssistedServiceFactory { fun create(string: String): AssistedService = throw NotImplementedError() } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "The @AssistedFactory-annotated type is missing an abstract, non-default method " + - "whose return type matches the assisted injection type." + "whose return type matches the assisted injection type.", ) } } @@ -1837,7 +1838,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory object DaggerModule1 { @Provides @Named("") fun provideService(): AssistedService = AssistedService(5, "Hello") } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass().createInstance(Provider { 5 }) @@ -1901,7 +1902,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(string: Lazy): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass() @@ -1967,7 +1968,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(string: Provider): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass() @@ -2031,7 +2032,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory interface AssistedServiceFactory { fun create(list: List>): AssistedService } - """ + """, ) { val factoryImplClass = assistedServiceFactory.implClass() val generatedFactoryInstance = assistedService.factoryClass() @@ -2068,7 +2069,7 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory private fun compile( @Language("kotlin") vararg sources: String, - block: JvmCompilationResult.() -> Unit = { } + block: JvmCompilationResult.() -> Unit = { }, ): JvmCompilationResult { return prepareCompilation() .compile(*sources) diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedInjectGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedInjectGeneratorTest.kt index ad5f114d0..1639ccb86 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedInjectGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedInjectGeneratorTest.kt @@ -19,12 +19,13 @@ import javax.inject.Provider @RunWith(Parameterized::class) class AssistedInjectGeneratorTest( - private val useDagger: Boolean + private val useDagger: Boolean, ) { companion object { @Parameters(name = "Use Dagger: {0}") - @JvmStatic fun useDagger(): Collection { + @JvmStatic + fun useDagger(): Collection { return listOf(isFullTestRun(), false).distinct() } } @@ -75,7 +76,7 @@ public final class AssistedService_Factory { val int: Int, @Assisted val string: String ) - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -146,7 +147,7 @@ public final class AssistedService_Factory { return true } } - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -178,7 +179,7 @@ public final class AssistedService_Factory { @Assisted("one") val string1: String, @Assisted("two") val string2: String ) - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -211,7 +212,7 @@ public final class AssistedService_Factory { @Assisted("one") val string1: String, @Assisted("two") val string2: String ) - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -245,12 +246,12 @@ public final class AssistedService_Factory { @Assisted val type1: SomeType, @Assisted val type2: SomeType ) - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "@AssistedInject constructor has duplicate @Assisted type: " + - "@Assisted com.squareup.test.SomeType" + "@Assisted com.squareup.test.SomeType", ) } } @@ -269,12 +270,12 @@ public final class AssistedService_Factory { @Assisted("one") val type1: SomeType, @Assisted(value = "one") val type2: SomeType ) - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "@AssistedInject constructor has duplicate @Assisted type: " + - "@Assisted(\"one\") com.squareup.test.SomeType" + "@Assisted(\"one\") com.squareup.test.SomeType", ) } } @@ -290,7 +291,7 @@ public final class AssistedService_Factory { data class AssistedService @AssistedInject constructor( val int: Int ) - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -323,7 +324,7 @@ public final class AssistedService_Factory { val int: Int, @Assisted val strings: List ) - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -356,7 +357,7 @@ public final class AssistedService_Factory { val int: Int, @Assisted val strings: T ) - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -389,7 +390,7 @@ public final class AssistedService_Factory { val int: Int, @Assisted val stringBuilder : T ) where T : Appendable, T : CharSequence - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -421,7 +422,7 @@ public final class AssistedService_Factory { @Assisted val strings: List, @Assisted val ints: List ) - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -454,7 +455,7 @@ public final class AssistedService_Factory { val int: Int, @Assisted val string: T ) - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -487,7 +488,7 @@ public final class AssistedService_Factory { val int: S, @Assisted val string: T ) - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -523,7 +524,7 @@ public final class AssistedService_Factory { ) } - """ + """, ) { val factoryClass = classLoader .loadClass("com.squareup.test.Outer\$AssistedService") @@ -592,7 +593,7 @@ public final class AssistedService_Factory { val int: Int?, @Assisted val string: String? ) - """ + """, ) { val factoryClass = assistedService.factoryClass() @@ -627,17 +628,17 @@ public final class AssistedService_Factory { ) { @AssistedInject constructor(@Assisted string: String) } - """ + """, ) { assertThat(exitCode).isError() assertThat( messages.lines() .first { it.startsWith("e:") } - .removeParametersAndSort() + .removeParametersAndSort(), ).contains( "Type com.squareup.test.AssistedService may only contain one injected constructor. " + "Found: [@dagger.assisted.AssistedInject com.squareup.test.AssistedService, " + - "@dagger.assisted.AssistedInject com.squareup.test.AssistedService]" + "@dagger.assisted.AssistedInject com.squareup.test.AssistedService]", ) } } @@ -657,17 +658,17 @@ public final class AssistedService_Factory { ) { @Inject constructor(@Assisted string: String) } - """ + """, ) { assertThat(exitCode).isError() assertThat( messages.lines() .first { it.startsWith("e:") } - .removeParametersAndSort() + .removeParametersAndSort(), ).contains( "Type com.squareup.test.AssistedService may only contain one injected constructor. " + "Found: [@Inject com.squareup.test.AssistedService, " + - "@dagger.assisted.AssistedInject com.squareup.test.AssistedService]" + "@dagger.assisted.AssistedInject com.squareup.test.AssistedService]", ) } } @@ -680,6 +681,6 @@ public final class AssistedService_Factory { enableDaggerAnnotationProcessor = useDagger, generateDaggerFactories = !useDagger, allWarningsAsErrors = WARNINGS_AS_ERRORS, - block = block + block = block, ) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/BindsMethodValidatorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/BindsMethodValidatorTest.kt index 3ec3c313f..90f2438eb 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/BindsMethodValidatorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/BindsMethodValidatorTest.kt @@ -15,12 +15,13 @@ import org.junit.runners.Parameterized.Parameters @RunWith(Parameterized::class) class BindsMethodValidatorTest( - private val useDagger: Boolean + private val useDagger: Boolean, ) { companion object { @Parameters(name = "Use Dagger: {0}") - @JvmStatic fun useDagger(): Collection { + @JvmStatic + fun useDagger(): Collection { return listOf(isFullTestRun(), false).distinct() } } @@ -45,16 +46,16 @@ class BindsMethodValidatorTest( @Binds abstract fun bindsBar(impl: Foo): Bar } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( - "@Binds methods' parameter type must be assignable to the return type" + "@Binds methods' parameter type must be assignable to the return type", ) if (!useDagger) { assertThat(messages).contains( "Expected binding of type Bar but impl parameter of type Foo only has the following " + - "supertypes: [Ipsum, Lorem]" + "supertypes: [Ipsum, Lorem]", ) } } @@ -78,15 +79,15 @@ class BindsMethodValidatorTest( @Binds abstract fun bindsBar(impl: Foo): Bar } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( - "@Binds methods' parameter type must be assignable to the return type" + "@Binds methods' parameter type must be assignable to the return type", ) if (!useDagger) { assertThat(messages).contains( - "Expected binding of type Bar but impl parameter of type Foo has no supertypes." + "Expected binding of type Bar but impl parameter of type Foo has no supertypes.", ) } } @@ -112,7 +113,7 @@ class BindsMethodValidatorTest( return impl } } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("@Binds methods must be abstract") @@ -137,12 +138,12 @@ class BindsMethodValidatorTest( @Binds abstract fun bindsBar(): Bar } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "@Binds methods must have exactly one parameter, " + - "whose type is assignable to the return type" + "whose type is assignable to the return type", ) } } @@ -166,12 +167,12 @@ class BindsMethodValidatorTest( @Binds abstract fun bindsBar(impl1: Foo, impl2: Hammer): Bar } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "@Binds methods must have exactly one parameter, " + - "whose type is assignable to the return type" + "whose type is assignable to the return type", ) } } @@ -195,12 +196,12 @@ class BindsMethodValidatorTest( @Binds abstract fun Foo.bindsBar(impl2: Hammer): Bar } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( "@Binds methods must have exactly one parameter, " + - "whose type is assignable to the return type" + "whose type is assignable to the return type", ) } } @@ -223,11 +224,11 @@ class BindsMethodValidatorTest( @Binds abstract fun bindsBar(impl1: Foo) } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains( - "@Binds methods must return a value (not void)" + "@Binds methods must return a value (not void)", ) } } @@ -250,7 +251,7 @@ class BindsMethodValidatorTest( @Binds abstract fun Foo.bindsBar(): Bar } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -351,7 +352,7 @@ class BindsMethodValidatorTest( fun providesFoo(): Foo = Foo() } } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -379,13 +380,13 @@ class BindsMethodValidatorTest( @Language("kotlin") vararg sources: String, previousCompilationResult: JvmCompilationResult? = null, enableDagger: Boolean = useDagger, - block: JvmCompilationResult.() -> Unit = { } + block: JvmCompilationResult.() -> Unit = { }, ): JvmCompilationResult = compileAnvil( sources = sources, enableDaggerAnnotationProcessor = enableDagger, generateDaggerFactories = !enableDagger, allWarningsAsErrors = WARNINGS_AS_ERRORS, previousCompilationResult = previousCompilationResult, - block = block + block = block, ) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/ComponentDetectorCheckTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/ComponentDetectorCheckTest.kt index 468432fd0..7deaa962f 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/ComponentDetectorCheckTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/ComponentDetectorCheckTest.kt @@ -15,12 +15,13 @@ import org.junit.runners.Parameterized @RunWith(Parameterized::class) class ComponentDetectorCheckTest( - private val mode: AnvilCompilationMode + private val mode: AnvilCompilationMode, ) { companion object { @Parameterized.Parameters(name = "{0}") - @JvmStatic fun modes(): Collection { + @JvmStatic + fun modes(): Collection { return listOf(AnvilCompilationMode.Embedded(), AnvilCompilationMode.Ksp()) } } @@ -35,7 +36,7 @@ class ComponentDetectorCheckTest( @Component interface ComponentInterface """, - mode = mode + mode = mode, ) { assertThat(exitCode).isError() // Position to the class. ) @@ -44,7 +45,7 @@ class ComponentDetectorCheckTest( "Anvil cannot generate the code for Dagger components or subcomponents. In these " + "cases the Dagger annotation processor is required. Enabling the Dagger " + "annotation processor and turning on Anvil to generate Dagger factories is " + - "redundant. Set 'generateDaggerFactories' to false." + "redundant. Set 'generateDaggerFactories' to false.", ) } } @@ -59,7 +60,7 @@ class ComponentDetectorCheckTest( @Subcomponent interface ComponentInterface """, - mode = mode + mode = mode, ) { assertThat(exitCode).isEqualTo(OK) } @@ -77,7 +78,7 @@ class ComponentDetectorCheckTest( interface ComponentInterface } """, - mode = mode + mode = mode, ) { assertThat(exitCode).isError() // Position to the class. @@ -86,7 +87,7 @@ class ComponentDetectorCheckTest( "Anvil cannot generate the code for Dagger components or subcomponents. In these " + "cases the Dagger annotation processor is required. Enabling the Dagger " + "annotation processor and turning on Anvil to generate Dagger factories is " + - "redundant. Set 'generateDaggerFactories' to false." + "redundant. Set 'generateDaggerFactories' to false.", ) } } @@ -103,7 +104,7 @@ class ComponentDetectorCheckTest( interface ComponentInterface } """, - mode = mode + mode = mode, ) { assertThat(exitCode).isEqualTo(OK) } @@ -113,12 +114,12 @@ class ComponentDetectorCheckTest( @Language("kotlin") vararg sources: String, codeGenerators: List = emptyList(), mode: AnvilCompilationMode = AnvilCompilationMode.Embedded(codeGenerators), - block: JvmCompilationResult.() -> Unit = { } + block: JvmCompilationResult.() -> Unit = { }, ): JvmCompilationResult = compileAnvil( sources = sources, generateDaggerFactories = true, allWarningsAsErrors = WARNINGS_AS_ERRORS, block = block, - mode = mode + mode = mode, ) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/InjectConstructorFactoryGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/InjectConstructorFactoryGeneratorTest.kt index 9da66ec9d..4dff9c490 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/InjectConstructorFactoryGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/InjectConstructorFactoryGeneratorTest.kt @@ -24,12 +24,13 @@ import javax.inject.Provider @RunWith(Parameterized::class) class InjectConstructorFactoryGeneratorTest( - private val useDagger: Boolean + private val useDagger: Boolean, ) { companion object { @Parameters(name = "Use Dagger: {0}") - @JvmStatic fun useDagger(): Collection { + @JvmStatic + fun useDagger(): Collection { return listOf(isFullTestRun(), false).distinct() } } @@ -76,7 +77,7 @@ public final class InjectClass_Factory implements Factory { import javax.inject.Inject class InjectClass @Inject constructor() - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -115,7 +116,7 @@ public final class InjectClass_Factory implements Factory { } class InjectClassFactory @Inject constructor(val factory: InjectClass.Factory) - """ + """, ) { // Loading one of the classes is all that's necessary to verify no conflicting imports were // generated @@ -175,7 +176,7 @@ public final class InjectClass_Factory implements Factory { val string: String, val int: Int ) - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -280,7 +281,7 @@ public final class InjectClass_Factory implements Factory { stringListProvider.get()[0] + lazyString.get() } } - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -290,7 +291,7 @@ public final class InjectClass_Factory implements Factory { Provider::class.java, Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) .inOrder() @@ -302,7 +303,7 @@ public final class InjectClass_Factory implements Factory { Provider { "a" }, Provider { "b" }, Provider { listOf("c") }, - Provider { "d" } + Provider { "d" }, ) assertThat(factoryInstance::class.java).isEqualTo(factoryClass) @@ -380,7 +381,7 @@ public final class InjectClass_Factory implements Factory { return string.get().get() } } - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -406,10 +407,10 @@ public final class InjectClass_Factory implements Factory { } } - @Test - @Ignore("This test is broken with Dagger as well.") // Notice in the get() function Dagger creates a Lazy of a Provider of Provider instead of a // Lazy of a Provider. + @Test + @Ignore("This test is broken with Dagger as well.") fun `a factory class is generated for an inject constructor with a provider argument wrapped in a lazy`() { /* package com.squareup.test; @@ -471,7 +472,7 @@ public final class InjectClass_Factory implements Factory { return string.get().get() } } - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -562,7 +563,7 @@ public final class InjectClass_Factory implements Factory { val path: Path, val setMultibinding: Set, ) - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -578,7 +579,7 @@ public final class InjectClass_Factory implements Factory { null, Provider { File("") }, Provider { File("").toPath() }, - Provider { emptySet() } + Provider { emptySet() }, ) assertThat(factoryInstance::class.java).isEqualTo(factoryClass) @@ -611,7 +612,7 @@ public final class InjectClass_Factory implements Factory { import javax.inject.Inject public class B @Inject constructor(): A.AA() - """ + """, ) { assertThat(classLoader.loadClass("b.B").factoryClass()).isNotNull() } @@ -676,7 +677,7 @@ public final class InjectClass_Factory implements Factory { val pair: Pair, List>, val set: Set ) - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -763,7 +764,7 @@ public final class OuterClass_InjectClass_Factory implements Factory { val string: String, val set: @JvmSuppressWildcards Set<(StringList) -> StringList> ) - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -925,7 +926,7 @@ public final class InjectClass_Factory implements Factory { import javax.inject.Inject data class injectClass @Inject constructor(val string: String) - """ + """, ) { val factoryClass = classLoader.loadClass("com.squareup.test.injectClass").factoryClass() @@ -1011,7 +1012,7 @@ public class InjectClass_Factory( return result } } - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -1069,7 +1070,7 @@ public class InjectClass_Factory( @Inject lateinit var base2: List } - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -1081,7 +1082,7 @@ public class InjectClass_Factory( Provider::class.java, Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) val name = "name" @@ -1097,7 +1098,7 @@ public class InjectClass_Factory( Provider { base2 }, Provider { middle1 }, Provider { middle2 }, - Provider { name } + Provider { name }, ) assertThat(factoryInstance::class.java).isEqualTo(factoryClass) @@ -1134,7 +1135,7 @@ public class InjectClass_Factory( @Inject lateinit var base2: List } - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -1143,7 +1144,7 @@ public class InjectClass_Factory( assertThat(constructor.parameterTypes.toList()) .containsExactly( Provider::class.java, - Provider::class.java + Provider::class.java, ) val base1 = listOf(3) @@ -1153,7 +1154,7 @@ public class InjectClass_Factory( val factoryInstance = factoryClass.createInstance( Provider { base1 }, - Provider { base2 } + Provider { base2 }, ) assertThat(factoryInstance::class.java).isEqualTo(factoryClass) @@ -1184,7 +1185,7 @@ public class InjectClass_Factory( @Inject lateinit var base2: List } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -1201,7 +1202,7 @@ public class InjectClass_Factory( lateinit var name: String } """, - previousCompilationResult = otherModuleResult + previousCompilationResult = otherModuleResult, ) { val factoryClass = injectClass.factoryClass() @@ -1211,7 +1212,7 @@ public class InjectClass_Factory( .containsExactly( Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) val name = "name" @@ -1223,7 +1224,7 @@ public class InjectClass_Factory( val factoryInstance = factoryClass.createInstance( Provider { base1 }, Provider { base2 }, - Provider { name } + Provider { name }, ) assertThat(factoryInstance::class.java).isEqualTo(factoryClass) @@ -1256,7 +1257,7 @@ public class InjectClass_Factory( @Inject lateinit var base2: List } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -1282,7 +1283,7 @@ public class InjectClass_Factory( lateinit var middle2: Set } """, - previousCompilationResult = otherModuleResult + previousCompilationResult = otherModuleResult, ) { val factoryClass = injectClass.factoryClass() @@ -1294,7 +1295,7 @@ public class InjectClass_Factory( Provider::class.java, Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) val name = "name" @@ -1310,7 +1311,7 @@ public class InjectClass_Factory( Provider { base2 }, Provider { middle1 }, Provider { middle2 }, - Provider { name } + Provider { name }, ) assertThat(factoryInstance::class.java).isEqualTo(factoryClass) @@ -1403,7 +1404,7 @@ public class InjectClass_Factory( return result } } - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -1414,7 +1415,7 @@ public class InjectClass_Factory( Provider::class.java, Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) val staticMethods = factoryClass.declaredMethods.filter { it.isStatic } @@ -1425,7 +1426,7 @@ public class InjectClass_Factory( Provider { "a" }, Provider { 1 }, Provider { "stringLazy" }, - Provider { "otherString" } + Provider { "otherString" }, ) assertThat(factoryInstance::class.java).isEqualTo(factoryClass) @@ -1491,7 +1492,7 @@ public final class InjectClass_Factory implements Factory { class otherClass { class inner @Inject constructor() } - """ + """, ) { val constructor = injectClass.factoryClass().declaredConstructors.single() assertThat(constructor.parameterTypes.toList()).containsExactly(Provider::class.java) @@ -1539,7 +1540,7 @@ public class InjectClass_Factory( class InjectClass @Inject constructor( val inner: Other.Inner ) - """ + """, ) { val constructor = injectClass.factoryClass().declaredConstructors.single() assertThat(constructor.parameterTypes.toList()).containsExactly(Provider::class.java) @@ -1589,7 +1590,7 @@ public class InjectClass_Factory( class InjectClass @Inject constructor( val inner: Other.Middle.Inner ) - """ + """, ) { val constructor = injectClass.factoryClass().declaredConstructors.single() assertThat(constructor.parameterTypes.toList()).containsExactly(Provider::class.java) @@ -1679,7 +1680,7 @@ public final class MyClass_Factory implements Factory { class MyClass @Inject constructor(arg: innerClass) { class innerClass @Inject constructor() } - """ + """, ) { val factoryClass = classLoader.loadClass("com.squareup.test.MyClass\$innerClass").factoryClass() @@ -1784,7 +1785,7 @@ public final class InjectClass_Factory implements Factory { class InjectClass @Inject constructor(dependencies: Dependencies) { class Dependencies @Inject constructor() } - """ + """, ) { val constructor = injectClass.factoryClass().declaredConstructors.single() assertThat(constructor.parameterTypes.toList()).containsExactly(Provider::class.java) @@ -1883,7 +1884,7 @@ public final class InjectClass_Factory implements Factory { open class ParentTwo(d: Dependencies) : ParentOne(d) class InjectClass @Inject constructor(d: Dependencies) : ParentTwo(d) - """ + """, ) { val constructor = injectClass.factoryClass().declaredConstructors.single() assertThat(constructor.parameterTypes.toList()).containsExactly(Provider::class.java) @@ -1948,7 +1949,7 @@ public final class InjectClass_Factory implements Factory { ) { interface Interceptor } - """ + """, ) { val constructor = injectClass.factoryClass().declaredConstructors.single() assertThat(constructor.parameterTypes.toList()).containsExactly(Provider::class.java) @@ -2005,7 +2006,7 @@ public final class InjectClass_Inner_Factory implements Factory implements Factory> { import javax.inject.Provider class InjectClass @Inject constructor(prov: Provider) - """ + """, ) { val constructor = classLoader.loadClass("com.squareup.test.InjectClass") .factoryClass().declaredConstructors.single() @@ -2110,7 +2111,7 @@ public final class InjectClass_Factory implements Factory> { import javax.inject.Inject class InjectClass @Inject constructor() - """ + """, ) { val constructor = classLoader.loadClass("com.squareup.test.InjectClass") .factoryClass().declaredConstructors.single() @@ -2170,7 +2171,7 @@ public final class InjectClass_Factory implements Factory { class InjectClass @Inject constructor( map: Map, @JvmSuppressWildcards Provider> ) - """ + """, ) { val constructor = classLoader.loadClass("com.squareup.test.InjectClass") .factoryClass().declaredConstructors.single() @@ -2214,7 +2215,7 @@ public final class InjectClass_Factory implements Factor import javax.inject.Provider class InjectClass @Inject constructor(element: Provider) - """ + """, ) { val constructor = classLoader.loadClass("com.squareup.test.InjectClass") .factoryClass().declaredConstructors.single() @@ -2260,7 +2261,7 @@ public class InjectClass_Factory( class InjectClass @Inject constructor( private val t: T ) where T : Appendable, T : CharSequence - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -2338,7 +2339,7 @@ public class InjectClass_Factory>( private val t: T, private val r: Lazy ) where T : Appendable, T : CharSequence - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -2350,15 +2351,17 @@ public class InjectClass_Factory>( assertThat(typeParams) .containsExactly( - "T", listOf("java.lang.Appendable", "java.lang.CharSequence"), - "R", listOf("java.util.Set") + "T", + listOf("java.lang.Appendable", "java.lang.CharSequence"), + "R", + listOf("java.util.Set"), ) val constructor = factoryClass.declaredConstructors.single() assertThat(constructor.parameterTypes.toList()) .containsExactly( Provider::class.java, - Provider::class.java + Provider::class.java, ) val staticMethods = factoryClass.declaredMethods.filter { it.isStatic } @@ -2421,7 +2424,7 @@ public class InjectClass_Factory( class InjectClass @Inject constructor( private val t: T ) where T : Appendable, T : Other - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -2476,7 +2479,7 @@ public class InjectClass_Factory>( class InjectClass> @Inject constructor( private val t: T ) - """ + """, ) { val factoryClass = injectClass.factoryClass() @@ -2514,7 +2517,7 @@ public class InjectClass_Factory>( import javax.inject.Inject class InjectClass @Inject constructor() - """ + """, ) { val factoryClass = classLoader.loadClass("InjectClass").factoryClass() @@ -2545,16 +2548,16 @@ public class InjectClass_Factory>( class InjectClass @Inject constructor() { @Inject constructor(string: String) } - """ + """, ) { assertThat(exitCode).isError() assertThat( messages.lines() .first { it.startsWith("e:") } - .removeParametersAndSort() + .removeParametersAndSort(), ).contains( "Type com.squareup.test.InjectClass may only contain one injected constructor. " + - "Found: [@Inject com.squareup.test.InjectClass, @Inject com.squareup.test.InjectClass]" + "Found: [@Inject com.squareup.test.InjectClass, @Inject com.squareup.test.InjectClass]", ) } } @@ -2580,7 +2583,7 @@ public class InjectClass_Factory>( class SomeClass @Inject constructor( state: State ) - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -2697,7 +2700,7 @@ public final class InjectClass_Factory implements Factory { @Qualifier annotation class StringQualifier(val value: String) - """ + """, ) { val constructor = injectClass.factoryClass().declaredConstructors.single() assertThat(constructor.parameterTypes.toList()).hasSize(8) @@ -2725,7 +2728,7 @@ public final class InjectClass_Factory implements Factory { class Factory } } - """ + """, ) { assertThat(classLoader.loadClass("com.squareup.test.A\$Achild\$Factory")).isNotNull() } @@ -2734,7 +2737,7 @@ public final class InjectClass_Factory implements Factory { private fun compile( @Language("kotlin") vararg sources: String, previousCompilationResult: JvmCompilationResult? = null, - block: JvmCompilationResult.() -> Unit = { } + block: JvmCompilationResult.() -> Unit = { }, ): JvmCompilationResult = compileAnvil( sources = sources, enableDaggerAnnotationProcessor = useDagger, @@ -2742,6 +2745,6 @@ public final class InjectClass_Factory implements Factory { // Many constructor parameters are unused. allWarningsAsErrors = false, previousCompilationResult = previousCompilationResult, - block = block + block = block, ) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MapKeyCreatorGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MapKeyCreatorGeneratorTest.kt index c7d8535df..8e3d556df 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MapKeyCreatorGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MapKeyCreatorGeneratorTest.kt @@ -16,12 +16,13 @@ import org.junit.runners.Parameterized.Parameters @RunWith(Parameterized::class) class MapKeyCreatorGeneratorTest( - private val useDagger: Boolean + private val useDagger: Boolean, ) { companion object { @Parameters(name = "Use Dagger: {0}") - @JvmStatic fun useDagger(): Collection { + @JvmStatic + fun useDagger(): Collection { return listOf(isFullTestRun(), false).distinct() } } @@ -64,7 +65,7 @@ class MapKeyCreatorGeneratorTest( val floatArrayValue: FloatArray, val doubleArrayValue: DoubleArray, ) - """ + """, ) { val mapKeyClass = classLoader.loadClass("com.squareup.test.ExampleMapKey") val creatorClass = classLoader.loadClass("com.squareup.test.ExampleMapKeyCreator") @@ -82,31 +83,56 @@ class MapKeyCreatorGeneratorTest( val mapKeyInstance = staticMethods.single { it.name == "createExampleMapKey" } .invoke( null, - /* stringValue*/ "stringValue", - /* stringArrayValue */ arrayOf("stringArrayValue"), - /* annotationValue */ TestAnnotation("annotationValue"), - /* annotationArrayValue */ arrayOf(TestAnnotation("annotationValue")), - /* enumValue */ TestEnum.A, - /* enumArrayValue */ arrayOf(TestEnum.A), - /* kClassValue */ String::class.java, - /* kClassStarValue */ String::class.java, - /* kClassArrayValue */ arrayOf(String::class.java), - /* booleanValue */ true, - /* byteValue */ 1.toByte(), - /* charValue */ 3.toChar(), - /* shortValue */ 2.toShort(), - /* intValue */ 4, - /* longValue */ 5L, - /* floatValue */ 6.0f, - /* doubleValue */ 7.0, - /* booleanArrayValue */ booleanArrayOf(true), - /* byteArrayValue */ byteArrayOf(1.toByte()), - /* charArrayValue */ charArrayOf(3.toChar()), - /* shortArrayValue */ shortArrayOf(2.toShort()), - /* intArrayValue */ intArrayOf(4), - /* longArrayValue */ longArrayOf(5L), - /* floatArrayValue */ floatArrayOf(6.0f), - /* doubleArrayValue */ doubleArrayOf(7.0), + /* stringValue*/ + "stringValue", + /* stringArrayValue */ + arrayOf("stringArrayValue"), + /* annotationValue */ + TestAnnotation("annotationValue"), + /* annotationArrayValue */ + arrayOf(TestAnnotation("annotationValue")), + /* enumValue */ + TestEnum.A, + /* enumArrayValue */ + arrayOf(TestEnum.A), + /* kClassValue */ + String::class.java, + /* kClassStarValue */ + String::class.java, + /* kClassArrayValue */ + arrayOf(String::class.java), + /* booleanValue */ + true, + /* byteValue */ + 1.toByte(), + /* charValue */ + 3.toChar(), + /* shortValue */ + 2.toShort(), + /* intValue */ + 4, + /* longValue */ + 5L, + /* floatValue */ + 6.0f, + /* doubleValue */ + 7.0, + /* booleanArrayValue */ + booleanArrayOf(true), + /* byteArrayValue */ + byteArrayOf(1.toByte()), + /* charArrayValue */ + charArrayOf(3.toChar()), + /* shortArrayValue */ + shortArrayOf(2.toShort()), + /* intArrayValue */ + intArrayOf(4), + /* longArrayValue */ + longArrayOf(5L), + /* floatArrayValue */ + floatArrayOf(6.0f), + /* doubleArrayValue */ + doubleArrayOf(7.0), ) assertThat(mapKeyInstance::class.java).isAssignableTo(mapKeyClass) @@ -128,7 +154,7 @@ class MapKeyCreatorGeneratorTest( annotation class ExampleMapKey( val value: RecursiveAnnotation, ) - """ + """, ) { val recursiveClass = classLoader.loadClass("com.squareup.test.RecursiveAnnotation") val mapKeyClass = classLoader.loadClass("com.squareup.test.ExampleMapKey") @@ -148,7 +174,8 @@ class MapKeyCreatorGeneratorTest( val mapKeyInstance = staticMethods.single { it.name == "createExampleMapKey" } .invoke( null, - /* stringValue*/ recursiveAnnotationInstance, + /* stringValue*/ + recursiveAnnotationInstance, ) assertThat(mapKeyInstance::class.java).isAssignableTo(mapKeyClass) @@ -171,7 +198,7 @@ class MapKeyCreatorGeneratorTest( annotation class ExampleMapKey2( val value: String, ) - """ + """, ) { classLoader.loadClass("com.squareup.test.ExampleMapKey") val creatorClass = classLoader.tryLoadClass("com.squareup.test.ExampleMapKeyCreator") @@ -197,7 +224,7 @@ class MapKeyCreatorGeneratorTest( val stringValue: String, ) } - """ + """, ) { val mapKeyClass = classLoader.loadClass("com.squareup.test.Container\$ExampleMapKey") val creatorClass = classLoader.loadClass("com.squareup.test.Container_ExampleMapKeyCreator") @@ -208,7 +235,8 @@ class MapKeyCreatorGeneratorTest( val mapKeyInstance = staticMethods.single { it.name == "createExampleMapKey" } .invoke( null, - /* stringValue*/ "stringValue", + /* stringValue*/ + "stringValue", ) assertThat(mapKeyInstance::class.java).isAssignableTo(mapKeyClass) @@ -217,12 +245,12 @@ class MapKeyCreatorGeneratorTest( private fun compile( @Language("kotlin") vararg sources: String, - block: JvmCompilationResult.() -> Unit = { } + block: JvmCompilationResult.() -> Unit = { }, ): JvmCompilationResult = compileAnvil( sources = sources, enableDaggerAnnotationProcessor = useDagger, generateDaggerFactories = !useDagger, allWarningsAsErrors = WARNINGS_AS_ERRORS, - block = block + block = block, ) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MembersInjectorGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MembersInjectorGeneratorTest.kt index d9cddecd6..27d8a2c75 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MembersInjectorGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/MembersInjectorGeneratorTest.kt @@ -32,12 +32,13 @@ import kotlin.test.assertFailsWith @Suppress("UNCHECKED_CAST") @RunWith(Parameterized::class) class MembersInjectorGeneratorTest( - private val useDagger: Boolean + private val useDagger: Boolean, ) { companion object { @Parameters(name = "Use Dagger: {0}") - @JvmStatic fun useDagger(): Collection { + @JvmStatic + fun useDagger(): Collection { return listOf(isFullTestRun(), false).distinct() } } @@ -215,7 +216,7 @@ public final class InjectClass_MembersInjector implements MembersInjector { @Qualifier annotation class StringQualifier(val value: String) - """ + """, ) { val membersInjector = injectClass.membersInjector() @@ -674,7 +675,7 @@ public final class ParentClass_NestedInjectClass_MembersInjector implements Memb } } } - """ + """, ) { val membersInjector = nestedInjectClass.membersInjector() @@ -739,7 +740,7 @@ public final class ParentClass_NestedInjectClass_MembersInjector implements Memb } } } - """ + """, ) { val errorMembersInjector = classLoader.loadClass("com.squareup.test.Base\$Error") @@ -754,13 +755,13 @@ public final class ParentClass_NestedInjectClass_MembersInjector implements Memb assertThat(constructor.parameterTypes.toList()) .containsExactly( Provider::class.java, - Provider::class.java + Provider::class.java, ) val membersInjectorInstance = constructor .newInstance( Provider { "a" }, - Provider { listOf(1, 2) } + Provider { listOf(1, 2) }, ) as MembersInjector val injectInstanceConstructor = injectClass.createInstance() @@ -874,7 +875,7 @@ public final class InjectClass_MembersInjector implements MembersInjector @@ -978,7 +979,7 @@ public final class InjectClass_MembersInjector implements MembersInjector } - """ + """, ) { val membersInjector = injectClass.membersInjector() @@ -1341,7 +1342,7 @@ public final class InjectClass_MembersInjector implements MembersInjector @@ -1427,7 +1428,7 @@ public final class InjectClass_MembersInjector implements MembersInjector { @Inject lateinit var string: String } - """ + """, ) { val membersInjector = injectClass.membersInjector() @@ -1447,7 +1448,7 @@ public final class InjectClass_MembersInjector implements MembersInjector { @Inject lateinit var unknownItems: List } - """ + """, ) { val membersInjector = injectClass.membersInjector() @@ -1483,7 +1484,7 @@ public final class InjectClass_MembersInjector implements MembersInjector implements MembersInjector val injectInstanceConstructor = injectClass.createInstance() @@ -1547,7 +1548,7 @@ public final class InjectClass_MembersInjector implements MembersInjector() { @Inject lateinit var bools: List } - """ + """, ) { val baseMembersInjector = classLoader.loadClass("com.squareup.test.Base") .membersInjector() @@ -1560,14 +1561,14 @@ public final class InjectClass_MembersInjector implements MembersInjector val injectInstanceConstructor = injectClass.createInstance() @@ -1635,7 +1636,7 @@ public final class InjectClass_MembersInjector implements MembersInject abstract class InjectClass { @Inject lateinit var string: String } - """ + """, ) { val membersInjector = injectClass.membersInjector() @@ -1668,7 +1669,7 @@ public final class InjectClass_MembersInjector implements MembersInject return string.hashCode() } } - """ + """, ) { val injectClass = classLoader.loadClass("InjectClass") val membersInjector = injectClass.membersInjector() @@ -1705,7 +1706,7 @@ public final class InjectClass_MembersInjector implements MembersInject abstract class Base { @Inject lateinit var string: String } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -1732,7 +1733,7 @@ public final class InjectClass_MembersInjector implements MembersInject } } """, - previousCompilationResult = otherModuleResult + previousCompilationResult = otherModuleResult, ) { val baseMembersInjector = classLoader.loadClass("com.squareup.test.Base") .membersInjector() @@ -1743,13 +1744,13 @@ public final class InjectClass_MembersInjector implements MembersInject assertThat(constructor.parameterTypes.toList()) .containsExactly( Provider::class.java, - Provider::class.java + Provider::class.java, ) val membersInjectorInstance = constructor .newInstance( Provider { "a" }, - Provider { listOf(1, 2) } + Provider { listOf(1, 2) }, ) as MembersInjector val injectInstanceConstructor = injectClass.createInstance() @@ -1779,7 +1780,7 @@ public final class InjectClass_MembersInjector implements MembersInject abstract class Base { @Inject lateinit var string: String } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -1811,7 +1812,7 @@ public final class InjectClass_MembersInjector implements MembersInject } } """, - previousCompilationResult = otherModuleResult + previousCompilationResult = otherModuleResult, ) { val baseMembersInjector = classLoader.loadClass("com.squareup.test.Base") .membersInjector() @@ -1825,14 +1826,14 @@ public final class InjectClass_MembersInjector implements MembersInject .containsExactly( Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) val membersInjectorInstance = constructor .newInstance( Provider { "a" }, Provider { listOf("b") }, - Provider { listOf(1, 2) } + Provider { listOf(1, 2) }, ) as MembersInjector val injectInstanceConstructor = injectClass.createInstance() @@ -1868,7 +1869,7 @@ public final class InjectClass_MembersInjector implements MembersInject abstract class Base2 : Base1() { @Inject lateinit var chars: List } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -1900,7 +1901,7 @@ public final class InjectClass_MembersInjector implements MembersInject } } """, - previousCompilationResult = otherModuleResult + previousCompilationResult = otherModuleResult, ) { val base1MembersInjector = classLoader.loadClass("com.squareup.test.Base1") @@ -1918,7 +1919,7 @@ public final class InjectClass_MembersInjector implements MembersInject Provider::class.java, Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) val membersInjectorInstance = constructor @@ -1926,7 +1927,7 @@ public final class InjectClass_MembersInjector implements MembersInject Provider { "a" }, Provider { listOf('b', 'c') }, Provider { listOf("d") }, - Provider { listOf(1, 2) } + Provider { listOf(1, 2) }, ) as MembersInjector val injectInstanceConstructor = injectClass.createInstance() @@ -1964,7 +1965,7 @@ public final class InjectClass_MembersInjector implements MembersInject abstract class Base2 : Base1() { @Inject override lateinit var string: String } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -1996,7 +1997,7 @@ public final class InjectClass_MembersInjector implements MembersInject } } """, - previousCompilationResult = otherModuleResult + previousCompilationResult = otherModuleResult, ) { val base1MembersInjector = classLoader.loadClass("com.squareup.test.Base1") @@ -2014,7 +2015,7 @@ public final class InjectClass_MembersInjector implements MembersInject Provider::class.java, Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) val membersInjectorInstance = constructor @@ -2022,7 +2023,7 @@ public final class InjectClass_MembersInjector implements MembersInject Provider { "a" }, Provider { "b" }, Provider { listOf("b") }, - Provider { listOf(1, 2) } + Provider { listOf(1, 2) }, ) as MembersInjector val injectInstanceConstructor = injectClass.createInstance() @@ -2076,7 +2077,7 @@ public final class InjectClass_MembersInjector implements MembersInject return true } } - """ + """, ) { val baseMembersInjector = classLoader.loadClass("com.squareup.test.Base") @@ -2091,14 +2092,14 @@ public final class InjectClass_MembersInjector implements MembersInject .containsExactly( Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) val membersInjectorInstance = constructor .newInstance( Provider { "a" }, Provider { "b" }, - Provider { listOf(1, 2) } + Provider { listOf(1, 2) }, ) as MembersInjector val injectInstanceConstructor = injectClass.createInstance() @@ -2145,7 +2146,7 @@ public final class InjectClass_MembersInjector implements MembersInject override fun hashCode() = stringList.hashCode() } - """ + """, ) { val injectClassMembersInjector = injectClass.membersInjector() @@ -2197,7 +2198,7 @@ public final class InjectClass_MembersInjector implements MembersInject override fun hashCode() = value.hashCode() } - """ + """, ) { val injectClassMembersInjector = injectClass.membersInjector() @@ -2257,7 +2258,7 @@ public final class InjectClass_MembersInjector implements MembersInject return result } } - """ + """, ) { val actualBaseMembersInjector = classLoader.loadClass("com.squareup.test.ActualBase") @@ -2269,13 +2270,13 @@ public final class InjectClass_MembersInjector implements MembersInject assertThat(constructor.parameterTypes.toList()) .containsExactly( Provider::class.java, - Provider::class.java + Provider::class.java, ) val membersInjectorInstance = constructor .newInstance( Provider { "a" }, - Provider { listOf(1, 2) } + Provider { listOf(1, 2) }, ) as MembersInjector val injectInstanceConstructor = injectClass.createInstance() @@ -2307,7 +2308,7 @@ public final class InjectClass_MembersInjector implements MembersInject } typealias Base = ActualBase - """ + """, ) { assertThat(exitCode).isEqualTo(OK) } @@ -2340,7 +2341,7 @@ public final class InjectClass_MembersInjector implements MembersInject } } """, - previousCompilationResult = otherModuleResult + previousCompilationResult = otherModuleResult, ) { val actualBaseMembersInjector = classLoader.loadClass("com.squareup.test.ActualBase") @@ -2352,13 +2353,13 @@ public final class InjectClass_MembersInjector implements MembersInject assertThat(constructor.parameterTypes.toList()) .containsExactly( Provider::class.java, - Provider::class.java + Provider::class.java, ) val membersInjectorInstance = constructor .newInstance( Provider { "a" }, - Provider { listOf(1, 2) } + Provider { listOf(1, 2) }, ) as MembersInjector val injectInstanceConstructor = injectClass.createInstance() @@ -2404,7 +2405,7 @@ public final class InjectClass_MembersInjector implements MembersInject override fun hashCode(): Int = string.hashCode() } - """ + """, ) { assertThat(exitCode).isEqualTo(OK) @@ -2426,7 +2427,7 @@ public final class InjectClass_MembersInjector implements MembersInject @Inject var injected: String? = null } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("Dagger does not support injection into private fields") @@ -2467,7 +2468,7 @@ public final class InjectClass_MembersInjector implements MembersInject return result } } - """ + """, ) { val membersInjector = injectClass.membersInjector() @@ -2505,13 +2506,13 @@ public final class InjectClass_MembersInjector implements MembersInject private fun compile( @Language("kotlin") vararg sources: String, previousCompilationResult: JvmCompilationResult? = null, - block: JvmCompilationResult.() -> Unit = { } + block: JvmCompilationResult.() -> Unit = { }, ): JvmCompilationResult = compileAnvil( sources = sources, enableDaggerAnnotationProcessor = useDagger, generateDaggerFactories = !useDagger, allWarningsAsErrors = WARNINGS_AS_ERRORS, previousCompilationResult = previousCompilationResult, - block = block + block = block, ) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/ProvidesMethodFactoryGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/ProvidesMethodFactoryGeneratorTest.kt index 6a4f349b2..906e08d31 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/ProvidesMethodFactoryGeneratorTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/ProvidesMethodFactoryGeneratorTest.kt @@ -32,12 +32,13 @@ import javax.inject.Provider @Suppress("UNCHECKED_CAST") @RunWith(Parameterized::class) class ProvidesMethodFactoryGeneratorTest( - private val useDagger: Boolean + private val useDagger: Boolean, ) { companion object { @Parameters(name = "Use Dagger: {0}") - @JvmStatic fun useDagger(): Collection { + @JvmStatic + fun useDagger(): Collection { return listOf(isFullTestRun(), false).distinct() } } @@ -88,7 +89,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory class DaggerModule1 { @dagger.Provides fun provideString(): String = "abc" } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -159,7 +160,7 @@ public final class DaggerModule1_ProvideFactoryFactory implements Factory class DaggerModule1 { @Provides fun provideString(): String = "abc" } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -306,7 +307,7 @@ public final class DaggerModule1_ProvideFileFactory implements Factory { class DaggerModule1 { @Provides fun provideFile(): java.io.File = java.io.File("") } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideFile") @@ -380,7 +381,7 @@ public final class DaggerModule1_ProvideFileFactory implements Factory { class DaggerModule1 { @Provides fun provideFile(): File = File("") } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideFile") @@ -451,7 +452,7 @@ public final class DaggerModule1_ProvideStringListFactory implements Factory = listOf("abc") } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideStringList") @@ -525,7 +526,7 @@ public final class DaggerModule1_ProvidePairFactory implements Factory, List> = Pair(Pair("", 1), listOf("")) } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("providePair") @@ -632,11 +633,11 @@ public final class DaggerModule1_ProvideIntFactory implements Factory { @dagger.Provides fun provideString(): String = "abc" @dagger.Provides fun provideInt(): Int = 5 } - """ + """, ) { fun verifyClassGenerated( providerMethodName: String, - expectedResult: T + expectedResult: T, ) { val factoryClass = daggerModule1.moduleFactoryClass(providerMethodName) @@ -708,7 +709,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory object DaggerModule1 { @dagger.Provides fun provideString(): String = "abc" } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -738,7 +739,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory class DaggerModule1 { @dagger.Provides internal fun provideString(): String = "abc" } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString\$main") @@ -807,7 +808,7 @@ public final class DaggerModule1_ProvideString$mainFactory implements Factory param2: CharSequence ): String = param1 + param2 } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -1081,7 +1082,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory param3: Provider> ): String = param1 + param2.get() + param3.get()[0] } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -1091,7 +1092,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory daggerModule1, Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) .inOrder() @@ -1184,7 +1185,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory param3: Lazy> ): String = param1 + param2.get() + param3.get()[0] } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -1194,7 +1195,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory daggerModule1, Provider::class.java, Provider::class.java, - Provider::class.java + Provider::class.java, ) .inOrder() @@ -1232,7 +1233,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory param: dagger.Lazy ): String = param.get() } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -1326,7 +1327,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory param2: Pair, List> ): String = param1[0] + param2.first.first + param2.second[0] } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -1344,7 +1345,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory null, module, Provider { listOf("a") }, - Provider { Pair(Pair("b", 1), listOf("c")) } + Provider { Pair(Pair("b", 1), listOf("c")) }, ) assertThat(factoryInstance::class.java).isEqualTo(factoryClass) @@ -1415,7 +1416,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory param2: CharSequence ): String = param1 + param2 } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -1502,7 +1503,7 @@ public final class DaggerModule1_Companion_ProvideStringFactory implements Facto ): String = param1 + param2 } } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString", companion = true) @@ -1577,7 +1578,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory class DaggerModule1 { @Provides fun provideString(): String? = null } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -1650,7 +1651,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory object DaggerModule1 { @Provides fun provideString(): String? = null } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -1740,7 +1741,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory return null } } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -1774,7 +1775,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory abstract class DaggerModule1 { @dagger.Binds abstract fun bindString(string: String): CharSequence } - """ + """, ) { if (useDagger) { assertThat(sourcesGeneratedByAnnotationProcessor).isEmpty() @@ -1830,7 +1831,7 @@ public final class DaggerModule1_Companion_ProvideStringFactory implements Facto @dagger.Provides fun provideString(): String = "abc" } } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString", companion = true) @@ -1897,7 +1898,7 @@ public final class ComponentInterface_InnerModule_ProvideStringFactory implement @dagger.Provides fun provideString(): String = "abc" } } - """ + """, ) { val factoryClass = innerModule.moduleFactoryClass("provideString") @@ -1931,7 +1932,7 @@ public final class ComponentInterface_InnerModule_ProvideStringFactory implement object DaggerModule1 { @Provides fun provideInnerClass(): OuterClass.InnerClass = OuterClass.InnerClass() } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideInnerClass") @@ -1991,7 +1992,7 @@ public final class ComponentInterface_InnerModule_Companion_ProvideStringFactory } } } - """ + """, ) { val factoryClass = innerModule.moduleFactoryClass("provideString", companion = true) @@ -2021,7 +2022,7 @@ public final class ComponentInterface_InnerModule_Companion_ProvideStringFactory abstract class DaggerModule1 { @dagger.Binds @dagger.multibindings.IntoSet abstract fun bindString(string: String): CharSequence } - """ + """, ) { if (useDagger) { assertThat(sourcesGeneratedByAnnotationProcessor).isEmpty() @@ -2073,7 +2074,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory object DaggerModule1 { @dagger.Provides @dagger.multibindings.IntoSet fun provideString(): String = "abc" } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -2139,7 +2140,7 @@ public final class DaggerModule1_ProvideStringFactory implements Factory = setOf("abc") } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -2210,7 +2211,7 @@ public final class DaggerModule1_ProvideFunctionFactory implements Factory string.length } } } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideFunction") @@ -2293,7 +2294,7 @@ public final class DaggerModule1_ProvideFunctionFactory implements Factory = java.lang.Runnable::class.java } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideClass") @@ -2499,7 +2500,7 @@ public final class DaggerComponentInterface implements ComponentInterface { object DaggerModule1 { @Provides fun provideRunner(): NamedRunnable = NamedRunnable {} } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideRunner") @@ -2523,7 +2524,7 @@ public final class DaggerComponentInterface implements ComponentInterface { object DaggerModule1 { @Provides fun provideDate(): Date = Date(1000) } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideDate") @@ -2553,7 +2554,7 @@ public final class DaggerComponentInterface implements ComponentInterface { class DaggerModule1 { @dagger.Provides fun provideString() = "abc" } - """ + """, ) { assumeFalse(useDagger) @@ -2561,7 +2562,7 @@ public final class DaggerComponentInterface implements ComponentInterface { assertThat(messages).contains("Source0.kt:5:3") assertThat(messages).contains( "Dagger provider methods must specify the return type explicitly when using Anvil. " + - "The return type cannot be inferred implicitly." + "The return type cannot be inferred implicitly.", ) } } @@ -2580,7 +2581,7 @@ public final class DaggerComponentInterface implements ComponentInterface { object DaggerModule1 { @Provides fun provideThing(): TestClassInUppercasePackage = TestClassInUppercasePackage() } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideThing") @@ -2610,7 +2611,7 @@ public final class DaggerComponentInterface implements ComponentInterface { return lowerCaseClassInUppercasePackage() } } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideThing") @@ -2639,7 +2640,7 @@ public final class DaggerComponentInterface implements ComponentInterface { object DaggerModule1 { @Provides fun provideThing(): InnerClass = InnerClass() } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideThing") @@ -2681,7 +2682,7 @@ public final class DaggerComponentInterface implements ComponentInterface { object DaggerModule1 { @Provides fun user(): User = User() } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("user") @@ -2743,7 +2744,7 @@ public final class DaggerModule1_GetStringFactory implements Factory { class DaggerModule1 { @get:Provides val string: String = "abc" } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("getString") @@ -2812,7 +2813,7 @@ public final class DaggerModule1_GetStringFactory implements Factory { object DaggerModule1 { @get:Provides val string: String = "abc" } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("getString") @@ -2884,7 +2885,7 @@ public final class DaggerModule1_GetStringFactory implements Factory { @get:Provides val string: String = "abc" } } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("getString", companion = true) @@ -2955,7 +2956,7 @@ public final class DaggerModule1_GetStringFactory implements Factory { class DaggerModule1 { @get:Provides val string: String? = null } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("getString") @@ -3026,7 +3027,7 @@ public final class DaggerModule1_GetStringFactory implements Factory { object DaggerModule1 { @get:Provides val string: String? = null } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("getString") @@ -3064,7 +3065,7 @@ public final class DaggerModule1_GetStringFactory implements Factory { class DaggerModule1 { @Provides fun provideType(): Type = Type } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideType") @@ -3095,7 +3096,7 @@ public final class DaggerModule1_GetStringFactory implements Factory { class DaggerModule1 { @dagger.Provides fun provideString(): String = "abc" } - """ + """, ) { val daggerModule1 = classLoader.loadClass("DaggerModule1") val factoryClass = daggerModule1.moduleFactoryClass("provideString") @@ -3132,7 +3133,7 @@ public final class DaggerModule1_GetStringFactory implements Factory { abstract class DaggerModule1 { @Provides abstract fun provideString(): String } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("@Provides methods cannot be abstract") @@ -3151,7 +3152,7 @@ public final class DaggerModule1_GetStringFactory implements Factory { interface DaggerModule1 { @Provides fun provideString(): String = "" } - """ + """, ) { assertThat(exitCode).isError() assertThat(messages).contains("@Provides methods cannot be abstract") @@ -3172,7 +3173,7 @@ public final class DaggerModule1_GetStringFactory implements Factory { @Provides fun provideString(): String = "" } } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("provideString", companion = true) assertThat(factoryClass).isNotNull() @@ -3240,7 +3241,7 @@ public final class DaggerModule1_ProvideFunctionFactory implements Factory { fun get(): T } - """ + """, ) { assertThat(exitCode).isEqualTo(ExitCode.OK) } @@ -3259,7 +3260,7 @@ public final class DaggerModule1_ProvideFunctionFactory implements Factory = listOf("a") } - """ + """, ) { val factoryClass = daggerModule1.moduleFactoryClass("getIssues") @@ -3478,7 +3479,7 @@ public final class DaggerModule1_ProvideFunctionFactory implements Factory - if (psiRef.shortName in listOf("AnyQualifier", "Values", "ABC")) + if (psiRef.shortName in listOf("AnyQualifier", "Values", "ABC")) { return@simpleCodeGenerator null + } listOf(psiRef, psiRef.toDescriptorReference()).forEach { ref -> val argument = ref.annotations.single().arguments.single() @@ -91,8 +92,8 @@ class AnnotationReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -116,8 +117,9 @@ class AnnotationReferenceTest { allWarningsAsErrors = false, codeGenerators = listOf( simpleCodeGenerator { psiRef -> - if (psiRef.shortName in listOf("BindingKey")) + if (psiRef.shortName in listOf("BindingKey")) { return@simpleCodeGenerator null + } listOf(psiRef, psiRef.toDescriptorReference()).forEach { ref -> val argument = ref.annotations.single().arguments.single() @@ -129,8 +131,8 @@ class AnnotationReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -222,8 +224,9 @@ class AnnotationReferenceTest { allWarningsAsErrors = false, codeGenerators = listOf( simpleCodeGenerator { psiRef -> - if (psiRef.shortName in listOf("BindingKey", "SomeObject", "Abc", "Companion")) + if (psiRef.shortName in listOf("BindingKey", "SomeObject", "Abc", "Companion")) { return@simpleCodeGenerator null + } listOf(psiRef, psiRef.toDescriptorReference()).forEach { ref -> when (psiRef.shortName) { @@ -288,8 +291,8 @@ class AnnotationReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -314,8 +317,9 @@ class AnnotationReferenceTest { allWarningsAsErrors = false, codeGenerators = listOf( simpleCodeGenerator { psiRef -> - if (psiRef.shortName in listOf("BindingKey")) + if (psiRef.shortName in listOf("BindingKey")) { return@simpleCodeGenerator null + } listOf(psiRef, psiRef.toDescriptorReference()).forEach { ref -> val arguments = ref.annotations.single().arguments @@ -326,13 +330,13 @@ class AnnotationReferenceTest { assertThat(ref.annotations.single().toAnnotationSpec().toString()).isEqualTo( "@com.squareup.test.BindingKey(name = \"abc\", " + - "implementingClass = kotlin.Unit::class, thresholds = [1, 2, 3])" + "implementingClass = kotlin.Unit::class, thresholds = [1, 2, 3])", ) } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -355,21 +359,22 @@ class AnnotationReferenceTest { allWarningsAsErrors = false, codeGenerators = listOf( simpleCodeGenerator { psiRef -> - if (psiRef.shortName in listOf("BindingKey")) + if (psiRef.shortName in listOf("BindingKey")) { return@simpleCodeGenerator null + } listOf(psiRef, psiRef.toDescriptorReference()).forEach { ref -> val arguments = ref.annotations.single().arguments assertThat(arguments[0].value()).isEqualTo("Hello, World!") assertThat(ref.annotations.single().toAnnotationSpec().toString()).isEqualTo( - "@com.squareup.test.BindingKey(name = \"Hello, World!\")" + "@com.squareup.test.BindingKey(name = \"Hello, World!\")", ) } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -392,21 +397,22 @@ class AnnotationReferenceTest { allWarningsAsErrors = false, codeGenerators = listOf( simpleCodeGenerator { psiRef -> - if (psiRef.shortName in listOf("BindingKey")) + if (psiRef.shortName in listOf("BindingKey")) { return@simpleCodeGenerator null + } listOf(psiRef, psiRef.toDescriptorReference()).forEach { ref -> val arguments = ref.annotations.single().arguments assertThat(arguments[0].value()).isEqualTo("World!") assertThat(ref.annotations.single().toAnnotationSpec().toString()).isEqualTo( - "@com.squareup.test.BindingKey(name = \"World!\")" + "@com.squareup.test.BindingKey(name = \"World!\")", ) } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -442,21 +448,22 @@ class AnnotationReferenceTest { allWarningsAsErrors = false, codeGenerators = listOf( simpleCodeGenerator { psiRef -> - if (psiRef.shortName in listOf("BindingKey", "SomeObject", "Abc", "Companion")) + if (psiRef.shortName in listOf("BindingKey", "SomeObject", "Abc", "Companion")) { return@simpleCodeGenerator null + } listOf(psiRef, psiRef.toDescriptorReference()).forEach { ref -> val arguments = ref.annotations.single().arguments assertThat(arguments[0].value()).isEqualTo("Hello nested, World nested!") assertThat(ref.annotations.single().toAnnotationSpec().toString()).isEqualTo( - "@com.squareup.test.BindingKey(name = \"Hello nested, World nested!\")" + "@com.squareup.test.BindingKey(name = \"Hello nested, World nested!\")", ) } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -489,8 +496,8 @@ class AnnotationReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/ClassReferenceTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/ClassReferenceTest.kt index d2ff9454d..673a814e5 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/ClassReferenceTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/ClassReferenceTest.kt @@ -73,8 +73,8 @@ class ClassReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -152,8 +152,8 @@ class ClassReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -191,10 +191,10 @@ class ClassReferenceTest { assertThat(descriptorRef.isGenericClass()).isTrue() assertThat( - psiRef.constructors.single().parameters.single().type().isGenericType() + psiRef.constructors.single().parameters.single().type().isGenericType(), ).isTrue() assertThat( - descriptorRef.constructors.single().parameters.single().type().isGenericType() + descriptorRef.constructors.single().parameters.single().type().isGenericType(), ).isTrue() } "SomeClass2" -> { @@ -205,21 +205,21 @@ class ClassReferenceTest { assertThat( descriptorRef.functions.single { it.name == "string" } .returnType() - .isGenericType() + .isGenericType(), ).isFalse() assertThat( - psiRef.directSuperTypeReferences().single().isGenericType() + psiRef.directSuperTypeReferences().single().isGenericType(), ).isTrue() assertThat( - psiRef.directSuperTypeReferences().single().asClassReference().isGenericClass() + psiRef.directSuperTypeReferences().single().asClassReference().isGenericClass(), ).isTrue() assertThat( - descriptorRef.directSuperTypeReferences().single().isGenericType() + descriptorRef.directSuperTypeReferences().single().isGenericType(), ).isTrue() assertThat( descriptorRef.directSuperTypeReferences().single().asClassReference() - .isGenericClass() + .isGenericClass(), ).isTrue() } "SomeClass3" -> { @@ -227,7 +227,7 @@ class ClassReferenceTest { assertThat( descriptorRef.functions.single { it.name == "list" } .returnType() - .isGenericType() + .isGenericType(), ).isTrue() } "SomeClass4" -> { @@ -235,15 +235,15 @@ class ClassReferenceTest { assertThat( descriptorRef.functions.single { it.name == "list" } .returnType() - .isGenericType() + .isGenericType(), ).isTrue() } else -> throw NotImplementedError(psiRef.shortName) } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -264,20 +264,20 @@ class ClassReferenceTest { codeGenerators = listOf( simpleCodeGenerator { psiRef -> assertThat( - psiRef.module.resolveFqNameOrNull(FqName("com.squareup.test.AnyQualifier")) + psiRef.module.resolveFqNameOrNull(FqName("com.squareup.test.AnyQualifier")), ).isNotNull() assertThat( - psiRef.module.resolveFqNameOrNull(FqName("com.squareup.test.AnyQualifier.Values")) + psiRef.module.resolveFqNameOrNull(FqName("com.squareup.test.AnyQualifier.Values")), ).isNotNull() assertThat( - psiRef.module.resolveFqNameOrNull(FqName("com.squareup.test.AnyQualifier.Values.ABC")) + psiRef.module.resolveFqNameOrNull(FqName("com.squareup.test.AnyQualifier.Values.ABC")), ).isNotNull() null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -306,18 +306,18 @@ class ClassReferenceTest { "Other" -> Unit "SomeClass1" -> { assertThat( - psiRef.directSuperTypeReferences().single().asClassReference().fqName + psiRef.directSuperTypeReferences().single().asClassReference().fqName, ).isEqualTo(FqName("com.squareup.other.Other")) assertThat( - descriptorRef.directSuperTypeReferences().single().asClassReference().fqName + descriptorRef.directSuperTypeReferences().single().asClassReference().fqName, ).isEqualTo(FqName("com.squareup.other.Other")) } else -> throw NotImplementedError(psiRef.shortName) } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -397,19 +397,19 @@ class ClassReferenceTest { assertThat(psiTypeSpec.toString()).contains( "public class Class, kotlin.Int>>" + "S : kotlin.collections.Map, kotlin.Int>>", ) assertThat(descriptorTypeSpec.toString()).contains( "public class Class, kotlin.Int>>" + "S : kotlin.collections.Map, kotlin.Int>>", ) } else -> throw NotImplementedError(psiRef.shortName) } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -495,8 +495,8 @@ class ClassReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -543,8 +543,8 @@ class ClassReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } 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 ab7c1c911..8b425cb54 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 @@ -64,8 +64,8 @@ class MemberFunctionReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -102,7 +102,9 @@ class MemberFunctionReferenceTest { assertThat(psiRef.functions).hasSize(0) assertThat(descriptorRef.functions).hasSize(3) assertThat(descriptorRef.functions.map { it.name }).containsExactly( - "equals", "toString", "hashCode" + "equals", + "toString", + "hashCode", ) } "SomeClass2" -> { @@ -153,8 +155,8 @@ class MemberFunctionReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -224,21 +226,21 @@ class MemberFunctionReferenceTest { assertThat( psiFunction .resolveGenericReturnType(implementingClass2.toPsiReference()) - .fqName + .fqName, ).isEqualTo(FqName("kotlin.String")) assertThat( psiFunction .resolveGenericReturnType(implementingClass2.toDescriptorReference()) - .fqName + .fqName, ).isEqualTo(FqName("kotlin.String")) assertThat( descriptorFunction - .resolveGenericReturnType(implementingClass2.toPsiReference()).fqName + .resolveGenericReturnType(implementingClass2.toPsiReference()).fqName, ).isEqualTo(FqName("kotlin.String")) assertThat( descriptorFunction - .resolveGenericReturnType(implementingClass2.toDescriptorReference()).fqName + .resolveGenericReturnType(implementingClass2.toDescriptorReference()).fqName, ).isEqualTo(FqName("kotlin.String")) val implementingClass3 = FqName("com.squareup.test.SomeClass3") @@ -246,22 +248,22 @@ class MemberFunctionReferenceTest { assertThat( psiFunction.resolveGenericReturnType(implementingClass3.toPsiReference()) - .fqName + .fqName, ).isEqualTo(FqName("kotlin.String")) assertThat( psiFunction.resolveGenericReturnType(implementingClass3.toDescriptorReference()) - .fqName + .fqName, ).isEqualTo(FqName("kotlin.String")) assertThat( descriptorFunction .resolveGenericReturnType(implementingClass3.toPsiReference()) - .fqName + .fqName, ).isEqualTo(FqName("kotlin.String")) assertThat( descriptorFunction .resolveGenericReturnType(implementingClass3.toDescriptorReference()) - .fqName + .fqName, ).isEqualTo(FqName("kotlin.String")) } "GenericInterface2" -> { @@ -277,20 +279,20 @@ class MemberFunctionReferenceTest { assertThat( descriptorFunction .resolveGenericReturnType(implementingClass.toPsiReference()) - .fqName + .fqName, ).isEqualTo(FqName("kotlin.String")) assertThat( descriptorFunction .resolveGenericReturnType(implementingClass.toDescriptorReference()) - .fqName + .fqName, ).isEqualTo(FqName("kotlin.String")) } else -> throw NotImplementedError() } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -328,19 +330,19 @@ class MemberFunctionReferenceTest { assertThat( psiFunction.parameters.single().typeOrNull() ?.asClassReferenceOrNull() - ?.fqName + ?.fqName, ).isEqualTo(FqName("kotlin.String")) assertThat( descriptorFunction.parameters.single().typeOrNull() ?.asClassReferenceOrNull() - ?.fqName + ?.fqName, ).isEqualTo(FqName("kotlin.String")) assertThat( - psiFunction.parameters.single().typeOrNull()?.asTypeNameOrNull() + psiFunction.parameters.single().typeOrNull()?.asTypeNameOrNull(), ).isNotNull() assertThat( - descriptorFunction.parameters.single().typeOrNull()?.asTypeNameOrNull() + descriptorFunction.parameters.single().typeOrNull()?.asTypeNameOrNull(), ).isNotNull() } "GenericInterface1" -> { @@ -357,20 +359,20 @@ class MemberFunctionReferenceTest { assertThat( psiFunction.parameters.single() - .resolveTypeNameOrNull(implementingClass1.toPsiReference()) + .resolveTypeNameOrNull(implementingClass1.toPsiReference()), ).isNotNull() assertThat( psiFunction.parameters.single() - .resolveTypeNameOrNull(implementingClass1.toDescriptorReference()) + .resolveTypeNameOrNull(implementingClass1.toDescriptorReference()), ).isNotNull() assertThat( descriptorFunction.parameters.single() - .resolveTypeNameOrNull(implementingClass1.toPsiReference()) + .resolveTypeNameOrNull(implementingClass1.toPsiReference()), ).isNotNull() assertThat( descriptorFunction.parameters.single() - .resolveTypeNameOrNull(implementingClass1.toDescriptorReference()) + .resolveTypeNameOrNull(implementingClass1.toDescriptorReference()), ).isNotNull() val implementingClass2 = FqName("com.squareup.test.SomeClass2") @@ -378,20 +380,20 @@ class MemberFunctionReferenceTest { assertThat( psiFunction.parameters.single() - .resolveTypeNameOrNull(implementingClass2.toPsiReference()) + .resolveTypeNameOrNull(implementingClass2.toPsiReference()), ).isNotNull() assertThat( psiFunction.parameters.single() - .resolveTypeNameOrNull(implementingClass2.toDescriptorReference()) + .resolveTypeNameOrNull(implementingClass2.toDescriptorReference()), ).isNotNull() assertThat( descriptorFunction.parameters.single() - .resolveTypeNameOrNull(implementingClass2.toPsiReference()) + .resolveTypeNameOrNull(implementingClass2.toPsiReference()), ).isNotNull() assertThat( descriptorFunction.parameters.single() - .resolveTypeNameOrNull(implementingClass2.toDescriptorReference()) + .resolveTypeNameOrNull(implementingClass2.toDescriptorReference()), ).isNotNull() } "GenericInterface2" -> { @@ -400,7 +402,7 @@ class MemberFunctionReferenceTest { val descriptorFunction = descriptorRef.functions.single { it.name == "hello" } assertThat( - descriptorFunction.parameters.single().type().asClassReferenceOrNull() + descriptorFunction.parameters.single().type().asClassReferenceOrNull(), ).isNull() val implementingClass = FqName("com.squareup.test.SomeClass2") @@ -408,19 +410,19 @@ class MemberFunctionReferenceTest { assertThat( descriptorFunction.parameters.single() - .resolveTypeNameOrNull(implementingClass.toPsiReference()) + .resolveTypeNameOrNull(implementingClass.toPsiReference()), ).isNotNull() assertThat( descriptorFunction.parameters.single() - .resolveTypeNameOrNull(implementingClass.toDescriptorReference()) + .resolveTypeNameOrNull(implementingClass.toDescriptorReference()), ).isNotNull() } else -> throw NotImplementedError() } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/MemberPropertyReferenceTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/MemberPropertyReferenceTest.kt index 7ed844d12..5310669c5 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/MemberPropertyReferenceTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/MemberPropertyReferenceTest.kt @@ -28,14 +28,14 @@ class MemberPropertyReferenceTest { assertThat(ref.propertyTypeNames()) .containsExactly( "name: kotlin.String", - "age: kotlin.Int" + "age: kotlin.Int", ) .inOrder() } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -61,14 +61,14 @@ class MemberPropertyReferenceTest { assertThat(ref.propertyTypeNames()) .containsExactly( "name: kotlin.String", - "age: kotlin.Int" + "age: kotlin.Int", ) .inOrder() } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -94,14 +94,14 @@ class MemberPropertyReferenceTest { assertThat(ref.propertyTypeNames()) .containsExactly( "name: kotlin.String", - "age: kotlin.Int" + "age: kotlin.Int", ) .inOrder() } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -134,8 +134,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -168,8 +168,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -196,8 +196,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -233,8 +233,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -270,8 +270,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -307,8 +307,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -335,14 +335,14 @@ class MemberPropertyReferenceTest { assertThat(ref.propertyTypeNames()) .containsExactly( "age: kotlin.Int", - "name: kotlin.String" + "name: kotlin.String", ) .inOrder() } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -376,8 +376,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -408,8 +408,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -449,8 +449,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -483,8 +483,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -523,8 +523,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -557,8 +557,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -597,8 +597,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -630,8 +630,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -671,8 +671,8 @@ class MemberPropertyReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -699,14 +699,14 @@ class MemberPropertyReferenceTest { assertThat(ref.propertyTypeNames()) .containsExactly( "name: kotlin.String", - "age: kotlin.Int" + "age: kotlin.Int", ) .inOrder() } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -738,14 +738,14 @@ class MemberPropertyReferenceTest { assertThat(ref.propertyTypeNames()) .containsExactly( "name: kotlin.String", - "age: kotlin.Int" + "age: kotlin.Int", ) .inOrder() } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TopLevelFunctionReferenceTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TopLevelFunctionReferenceTest.kt index d834094d7..997e8fb28 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TopLevelFunctionReferenceTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TopLevelFunctionReferenceTest.kt @@ -28,7 +28,7 @@ class TopLevelFunctionReferenceTest { package com.squareup.test private fun abc() = Unit - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.abc")) assertThat(ref.parameters).isEmpty() @@ -51,7 +51,7 @@ class TopLevelFunctionReferenceTest { package com.squareup.test fun abc(string: String): String = string - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.abc")) assertThat(ref.parameters.single().type().asClassReference().fqName.asString()) @@ -70,7 +70,7 @@ class TopLevelFunctionReferenceTest { @PublishedApi internal fun abc(): Int? = null - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.abc")) assertThat(ref.parameters).isEmpty() @@ -89,7 +89,7 @@ class TopLevelFunctionReferenceTest { package com.squareup.test fun abc(): T = throw NotImplementedError() - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.abc")) assertThat(ref.parameters).isEmpty() @@ -105,7 +105,7 @@ class TopLevelFunctionReferenceTest { package com.squareup.test fun abc(param1: T, param2: () -> T): T? = null - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.abc")) assertThat(ref.parameters).hasSize(2) @@ -120,7 +120,7 @@ class TopLevelFunctionReferenceTest { private fun functionTest( @Language("kotlin") vararg sources: String, - assert: (TopLevelFunctionReference) -> Unit + assert: (TopLevelFunctionReference) -> Unit, ) { compile( *sources, @@ -132,7 +132,7 @@ class TopLevelFunctionReferenceTest { override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { projectFiles .topLevelFunctionReferences(module) @@ -141,8 +141,8 @@ class TopLevelFunctionReferenceTest { return emptyList() } - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TopLevelPropertyReferenceTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TopLevelPropertyReferenceTest.kt index 0620337e7..65c1f0da2 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TopLevelPropertyReferenceTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TopLevelPropertyReferenceTest.kt @@ -28,7 +28,7 @@ class TopLevelPropertyReferenceTest { package com.squareup.test private val prop = Unit - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.prop")) assertThat(ref.annotations).isEmpty() @@ -53,7 +53,7 @@ class TopLevelPropertyReferenceTest { package com.squareup.test var prop: String = "" - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.prop")) assertThat(ref.annotations).isEmpty() @@ -73,7 +73,7 @@ class TopLevelPropertyReferenceTest { @PublishedApi internal val prop: Int? = null - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.prop")) assertThat(ref.annotations.single().fqName.asString()) @@ -96,7 +96,7 @@ class TopLevelPropertyReferenceTest { import javax.inject.Inject @set:Inject var prop: String = "" - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.prop")) assertThat(ref.annotations.single().fqName.asString()) @@ -119,7 +119,7 @@ class TopLevelPropertyReferenceTest { import javax.inject.Inject @get:Inject var prop: String = "" - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.prop")) assertThat(ref.annotations.single().fqName.asString()) @@ -140,7 +140,7 @@ class TopLevelPropertyReferenceTest { package com.squareup.test lateinit var prop6: String - """ + """, ) { ref -> assertThat(ref.fqName).isEqualTo(FqName("com.squareup.test.prop6")) assertThat(ref.annotations).isEmpty() @@ -155,7 +155,7 @@ class TopLevelPropertyReferenceTest { private fun propertyTest( @Language("kotlin") vararg sources: String, - assert: (TopLevelPropertyReference) -> Unit + assert: (TopLevelPropertyReference) -> Unit, ) { compile( sources = sources, @@ -167,7 +167,7 @@ class TopLevelPropertyReferenceTest { override fun generateCode( codeGenDir: File, module: ModuleDescriptor, - projectFiles: Collection + projectFiles: Collection, ): Collection { projectFiles .topLevelPropertyReferences(module) @@ -176,8 +176,8 @@ class TopLevelPropertyReferenceTest { return emptyList() } - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TypeReferenceTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TypeReferenceTest.kt index 77503b756..702e265c3 100644 --- a/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TypeReferenceTest.kt +++ b/compiler/src/test/java/com/squareup/anvil/compiler/internal/reference/TypeReferenceTest.kt @@ -46,8 +46,8 @@ class TypeReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -86,8 +86,8 @@ class TypeReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -114,7 +114,7 @@ class TypeReferenceTest { .unwrappedTypes .single() // String .resolveGenericTypeNameOrNull(ref) - .toString() + .toString(), ).isEqualTo("kotlin.String") } } @@ -122,8 +122,8 @@ class TypeReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -151,7 +151,7 @@ class TypeReferenceTest { .unwrappedTypes .single() // T .resolveGenericTypeNameOrNull(ref) - .toString() + .toString(), ).isEqualTo("T") } } @@ -159,8 +159,8 @@ class TypeReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -193,7 +193,7 @@ class TypeReferenceTest { .unwrappedTypes .single() // T .resolveGenericTypeNameOrNull(ref) - .toString() + .toString(), ).isEqualTo("kotlin.Int") } } @@ -201,8 +201,8 @@ class TypeReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -228,19 +228,19 @@ class TypeReferenceTest { listOf(psiRef, psiRef.toDescriptorReference()).forEach { ref -> assertThat( ref.properties.single { it.name == "map1" }.type().unwrappedTypes - .map { it.asClassReference().shortName } + .map { it.asClassReference().shortName }, ).containsExactly("Any", "Any").inOrder() assertThat( ref.properties.single { it.name == "map2" }.type().unwrappedTypes - .map { it.asClassReference().shortName } + .map { it.asClassReference().shortName }, ).containsExactly("Int", "Any").inOrder() assertThat( ref.properties.single { it.name == "map3" }.type().unwrappedTypes - .map { it.asClassReference().shortName } + .map { it.asClassReference().shortName }, ).containsExactly("Any", "String").inOrder() assertThat( ref.properties.single { it.name == "map4" }.type().unwrappedTypes - .map { it.asClassReference().shortName } + .map { it.asClassReference().shortName }, ).containsExactly("Int", "String").inOrder() } } @@ -248,8 +248,8 @@ class TypeReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } @@ -280,15 +280,15 @@ class TypeReferenceTest { listOf(psiRef, psiRef.toDescriptorReference()).forEach { ref -> assertThat( ref.properties.single { it.name == "map" }.type().unwrappedTypes - .map { it.asClassReference().shortName } + .map { it.asClassReference().shortName }, ).containsExactly("String", "Int").inOrder() assertThat( ref.properties.single { it.name == "single1" }.type().unwrappedTypes - .map { it.asClassReference().shortName } + .map { it.asClassReference().shortName }, ).containsExactly("Int", "String", "Long").inOrder() assertThat( ref.properties.single { it.name == "single2" }.type().unwrappedTypes - .map { it.asClassReference().shortName } + .map { it.asClassReference().shortName }, ).containsExactly("Int", "Int", "Int").inOrder() } } @@ -296,8 +296,8 @@ class TypeReferenceTest { } null - } - ) + }, + ), ) { assertThat(exitCode).isEqualTo(OK) } diff --git a/gradle-plugin/src/main/java/com/squareup/anvil/plugin/AnvilPlugin.kt b/gradle-plugin/src/main/java/com/squareup/anvil/plugin/AnvilPlugin.kt index 3804603c4..7cb20bcb4 100644 --- a/gradle-plugin/src/main/java/com/squareup/anvil/plugin/AnvilPlugin.kt +++ b/gradle-plugin/src/main/java/com/squareup/anvil/plugin/AnvilPlugin.kt @@ -105,7 +105,7 @@ internal open class AnvilPlugin : KotlinCompilerPluginSupportPlugin { } override fun applyToCompilation( - kotlinCompilation: KotlinCompilation<*> + kotlinCompilation: KotlinCompilation<*>, ): Provider> { kotlinCompilation.compilerOptions.options.let { @Suppress("DEPRECATION") @@ -114,7 +114,7 @@ internal open class AnvilPlugin : KotlinCompilerPluginSupportPlugin { kotlinCompilation.project.logger .error( "NOTE: Anvil is currently incompatible with the K2 compiler. Related GH issue:" + - "https://github.com/square/anvil/issues/733" + "https://github.com/square/anvil/issues/733", ) } } @@ -127,7 +127,7 @@ internal open class AnvilPlugin : KotlinCompilerPluginSupportPlugin { ) { throw GradleException( "You cannot set generateDaggerFactories to false and generateDaggerFactoriesOnly " + - "to true at the same time for variant ${variant.name}." + "to true at the same time for variant ${variant.name}.", ) } @@ -181,20 +181,20 @@ internal open class AnvilPlugin : KotlinCompilerPluginSupportPlugin { listOf( FilesSubpluginOption( key = "src-gen-dir", - files = listOf(srcGenDir) + files = listOf(srcGenDir), ), SubpluginOption( key = "generate-dagger-factories", - lazy { variant.variantFilter.generateDaggerFactories.toString() } + lazy { variant.variantFilter.generateDaggerFactories.toString() }, ), SubpluginOption( key = "generate-dagger-factories-only", - lazy { variant.variantFilter.generateDaggerFactoriesOnly.toString() } + lazy { variant.variantFilter.generateDaggerFactoriesOnly.toString() }, ), SubpluginOption( key = "disable-component-merging", - lazy { variant.variantFilter.disableComponentMerging.toString() } - ) + lazy { variant.variantFilter.disableComponentMerging.toString() }, + ), ) } } @@ -204,7 +204,7 @@ internal open class AnvilPlugin : KotlinCompilerPluginSupportPlugin { override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact( groupId = GROUP, artifactId = "compiler", - version = VERSION + version = VERSION, ) private fun disableCorrectErrorTypes(variant: Variant) { @@ -238,7 +238,7 @@ internal open class AnvilPlugin : KotlinCompilerPluginSupportPlugin { stubsTask.doFirstCompat { stubsTask.incremental = false stubsTask.log( - "Anvil: Incremental compilation enabled: ${stubsTask.incremental} (stub)" + "Anvil: Incremental compilation enabled: ${stubsTask.incremental} (stub)", ) } } @@ -249,7 +249,7 @@ internal open class AnvilPlugin : KotlinCompilerPluginSupportPlugin { private fun getConfiguration( project: Project, - buildType: String + buildType: String, ): Configuration { val name = if (buildType.isEmpty()) "anvil" else "anvil${buildType.replaceFirstChar(Char::uppercase)}" @@ -302,7 +302,7 @@ private fun T.doFirstCompat(block: (T) -> Unit) { */ private inline fun Project.namedLazy( name: String, - crossinline action: (TaskProvider) -> Unit + crossinline action: (TaskProvider) -> Unit, ) { try { action(tasks.named(name, T::class.java)) @@ -332,7 +332,7 @@ private inline fun Project.namedLazy( private fun Project.androidVariantsConfigure( @Suppress("TYPEALIAS_EXPANSION_DEPRECATION") - action: (BaseVariantDeprecated) -> Unit + action: (BaseVariantDeprecated) -> Unit, ) { val androidExtension = extensions.findByName("android") @@ -352,14 +352,14 @@ private fun Project.androidVariantsConfigure( // the 'java' plugin implicitly. One could also apply the 'java' plugin alone without the // application or library plugin, so 'java' must be included in this list. private val jvmPlugins = listOf( - "java" + "java", ) private val agpPlugins = listOf( "com.android.library", "com.android.application", "com.android.test", - "com.android.dynamic-feature" + "com.android.dynamic-feature", ) private const val KAPT_PLUGIN_ID = "org.jetbrains.kotlin.kapt" @@ -372,7 +372,7 @@ internal class Variant private constructor( val androidVariant: BaseVariantDeprecated?, val androidSourceSets: List?, val compilerPluginClasspathName: String, - val variantFilter: VariantFilter + val variantFilter: VariantFilter, ) { // E.g. compileKotlin, compileKotlinJvm, compileDebugKotlin. private val taskSuffix = compileTaskProvider.name.substringAfter("compile") @@ -383,7 +383,7 @@ internal class Variant private constructor( // Sanity check. require( kotlinCompilation.platformType != androidJvm || - kotlinCompilation is KotlinJvmAndroidCompilation + kotlinCompilation is KotlinJvmAndroidCompilation, ) { "The KotlinCompilation is KotlinJvmAndroidCompilation, but the platform type " + "is different." @@ -421,7 +421,7 @@ internal class Variant private constructor( compilerPluginClasspathName = PLUGIN_CLASSPATH_CONFIGURATION_NAME + kotlinCompilation.target.targetName.replaceFirstChar(Char::uppercase) + kotlinCompilation.name.replaceFirstChar(Char::uppercase), - variantFilter = variantFilter + variantFilter = variantFilter, ).also { // Sanity check. check(it.compileTaskProvider.name.startsWith("compile")) diff --git a/gradle-plugin/src/main/java/com/squareup/anvil/plugin/VariantFilter.kt b/gradle-plugin/src/main/java/com/squareup/anvil/plugin/VariantFilter.kt index 547b32233..72b5d59c0 100644 --- a/gradle-plugin/src/main/java/com/squareup/anvil/plugin/VariantFilter.kt +++ b/gradle-plugin/src/main/java/com/squareup/anvil/plugin/VariantFilter.kt @@ -46,7 +46,7 @@ public interface VariantFilter : Named { internal class CommonFilter( private val name: String, - private val extension: AnvilExtension + private val extension: AnvilExtension, ) : VariantFilter { override fun getName(): String = name override var ignore: Boolean = false @@ -88,11 +88,11 @@ internal class CommonFilter( } public class JvmVariantFilter internal constructor( - commonFilter: CommonFilter + commonFilter: CommonFilter, ) : VariantFilter by commonFilter public class AndroidVariantFilter internal constructor( commonFilter: CommonFilter, @Suppress("TYPEALIAS_EXPANSION_DEPRECATION") - public val androidVariant: BaseVariantDeprecated + public val androidVariant: BaseVariantDeprecated, ) : VariantFilter by commonFilter