Skip to content

Commit

Permalink
ktlint
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Dec 5, 2023
1 parent 93966e6 commit 1f2bb52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker {
.filterIsInstance<KSClassDeclaration>()
.forEach { clazz ->
val classAndCompanion = sequenceOf(clazz)
.plus(clazz.declarations.filterIsInstance<KSClassDeclaration>().filter { it.isCompanionObject })
.plus(
clazz.declarations.filterIsInstance<KSClassDeclaration>().filter { it.isCompanionObject },
)

val functions = classAndCompanion.flatMap { it.getDeclaredFunctions() }
.filter { it.isAnnotationPresent<Provides>() }
Expand All @@ -100,7 +102,7 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker {
.filter { property ->
// Must be '@get:Provides'.
(property.getKSAnnotationsByType(Provides::class).singleOrNull()?.useSiteTarget == GET) ||
property.getter?.isAnnotationPresent<Provides>() == true
property.getter?.isAnnotationPresent<Provides>() == true
}
.map { property ->
CallableReference.from(property)
Expand All @@ -125,7 +127,6 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker {
return emptyList()
}


private fun checkFunctionIsNotAbstract(
clazz: KSClassDeclaration,
function: KSFunctionDeclaration,
Expand Down Expand Up @@ -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<PublishedApi>(),
Expand All @@ -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,
Expand Down Expand Up @@ -352,7 +357,7 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker {
}
append(declarationName.capitalize())
if (isMangled) {
append("\$${mangledNameSuffix}")
append("\$$mangledNameSuffix")
}
append("Factory")
}
Expand All @@ -368,7 +373,7 @@ object ProvidesMethodFactoryCodeGen : AnvilApplicabilityChecker {

val byteCodeFunctionName = when {
useGetPrefix -> "get" + callableName.capitalize()
isMangled -> "$callableName\$${mangledNameSuffix}"
isMangled -> "$callableName\$$mangledNameSuffix"
else -> callableName
}

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

0 comments on commit 1f2bb52

Please sign in to comment.