From 1f2bb52b16dddb8f66e05be275d117a788ed7410 Mon Sep 17 00:00:00 2001 From: Zac Sweers Date: Tue, 5 Dec 2023 00:39:14 -0500 Subject: [PATCH] ktlint --- .../dagger/ProvidesMethodFactoryCodeGen.kt | 19 ++++++++++++------- .../ProvidesMethodFactoryGeneratorTest.kt | 1 - 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryCodeGen.kt b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryCodeGen.kt index 0a13ef4f4..49ff14531 100644 --- a/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryCodeGen.kt +++ b/compiler/src/main/java/com/squareup/anvil/compiler/codegen/dagger/ProvidesMethodFactoryCodeGen.kt @@ -81,7 +81,9 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker { .filterIsInstance() .forEach { clazz -> val classAndCompanion = sequenceOf(clazz) - .plus(clazz.declarations.filterIsInstance().filter { it.isCompanionObject }) + .plus( + clazz.declarations.filterIsInstance().filter { it.isCompanionObject }, + ) val functions = classAndCompanion.flatMap { it.getDeclaredFunctions() } .filter { it.isAnnotationPresent() } @@ -100,7 +102,7 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker { .filter { property -> // Must be '@get:Provides'. (property.getKSAnnotationsByType(Provides::class).singleOrNull()?.useSiteTarget == GET) || - property.getter?.isAnnotationPresent() == true + property.getter?.isAnnotationPresent() == true } .map { property -> CallableReference.from(property) @@ -125,7 +127,6 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker { return emptyList() } - private fun checkFunctionIsNotAbstract( clazz: KSClassDeclaration, function: KSFunctionDeclaration, @@ -160,7 +161,9 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker { isCompanionObject = function.closestClassDeclaration()?.isCompanionObject == true, name = function.simpleName.asString(), isProperty = false, - constructorParameters = function.parameters.mapToConstructorParameters(function.typeParameters.toTypeParameterResolver()), + constructorParameters = function.parameters.mapToConstructorParameters( + function.typeParameters.toTypeParameterResolver(), + ), type = typeName, isNullable = type.isMarkedNullable, isPublishedApi = function.isAnnotationPresent(), @@ -186,7 +189,9 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker { @AutoService(CodeGenerator::class) internal class Embedded : PrivateCodeGenerator() { - override fun isApplicable(context: AnvilContext) = ProvidesMethodFactoryCodeGen.isApplicable(context) + override fun isApplicable(context: AnvilContext) = ProvidesMethodFactoryCodeGen.isApplicable( + context, + ) override fun generateCodePrivate( codeGenDir: File, @@ -352,7 +357,7 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker { } append(declarationName.capitalize()) if (isMangled) { - append("\$${mangledNameSuffix}") + append("\$$mangledNameSuffix") } append("Factory") } @@ -368,7 +373,7 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker { val byteCodeFunctionName = when { useGetPrefix -> "get" + callableName.capitalize() - isMangled -> "$callableName\$${mangledNameSuffix}" + isMangled -> "$callableName\$$mangledNameSuffix" else -> callableName } 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 cd313678e..4d690cee8 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 @@ -15,7 +15,6 @@ import com.squareup.anvil.compiler.internal.testing.createInstance import com.squareup.anvil.compiler.internal.testing.isStatic import com.squareup.anvil.compiler.internal.testing.moduleFactoryClass import com.squareup.anvil.compiler.isError -import com.squareup.anvil.compiler.isFullTestRun import com.squareup.anvil.compiler.useDaggerAndKspParams import com.tschuchort.compiletesting.JvmCompilationResult import com.tschuchort.compiletesting.KotlinCompilation.ExitCode