Fabio
02/16/2021, 10:20 PMit.type.resolve()
is a KSType
, and I see isAssignableFrom(KSType)
but still not sure how to compare it to a KClass
like Module::class.java
yigit
02/16/2021, 10:20 PMyigit
02/16/2021, 10:20 PMJiaxiang
02/16/2021, 10:33 PMKSType.declaration
will direct you to the KSClass
of that type. However it is recommended to use KSType
for comparing to handle subtypee, i.e. use the approach above.Fabio
02/16/2021, 10:33 PMyigit
02/16/2021, 10:34 PMobject
?yigit
02/16/2021, 10:34 PMyigit
02/16/2021, 10:35 PMResolver.getClassDeclarationByName("qalified name of Module")
and then get type from it as asStarProjectedType
yigit
02/16/2021, 10:35 PMFabio
02/17/2021, 7:48 AMval moduleKsType =
org.koin.core.module.Module::class.java
.let {
object : KSName {
override fun asString(): String = it.canonicalName
override fun getQualifier(): String = "Not important "
override fun getShortName(): String = it.simpleName
}
}
.let {
resolver.getClassDeclarationByName(it)
?.asStarProjectedType()
}
Fabio
02/17/2021, 7:52 AMval d: KSPropertyDeclaration
I'm doing
d.type.resolve().declaration == moduleKsType?.declaration
Fabio
02/17/2021, 7:53 AMis
keyword, as in obj is org.koin.core.module.Module
)Jiaxiang
02/17/2021, 7:38 PMresolver.getClassDeclarationByName(name: String)
function which will accept a string for name so you don’t have to create that long statement for creating a dummy KSName
object.Jiaxiang
02/17/2021, 7:42 PMfun <reified T> Resolver.getClassDeclarationByName()
which will help.yigit
02/17/2021, 7:55 PMFabio
02/17/2021, 10:13 PM