Rafael Costa
03/06/2024, 3:07 PMFirstType and SecondType?
I am able to get the KSType corresponding to AbcType , but not the other two.
ExternalModuleDestinations is an annotation class ExternalModuleDestinations<T: SomeType> and ExternalDestination is also annotation class ExternalDestination<T: OtherType>.
@ExternalModuleDestinations<AbcType>(
overriding = [
ExternalDestination<FirstType>(),
ExternalDestination<SecondType>(),
]
)
class SomeClass
When I try, I just get T, not the actual types used here (FirstType and SecondType)Jiaxiang
03/06/2024, 8:58 PMExternalModuleDestinations ?Rafael Costa
03/06/2024, 9:19 PMJiaxiang
03/06/2024, 9:21 PMKSClassDeclaration of SomeClass, you can get the list of its annotations via KSClassDeclaration.annotations, iterate through the annotation list, find the annotation with type ExternalModuleDestinations, read the annotation values by KSAnnotation.argumentsRafael Costa
03/06/2024, 9:25 PMannotationType.arguments.first().resolve()Rafael Costa
03/06/2024, 9:25 PMJiaxiang
03/06/2024, 9:26 PMRafael Costa
03/06/2024, 9:37 PMit.annotationType.resolve().arguments.first().type!!.resolve()
Ƭt is a KSAnnotation from the ArrayList<KSAnnotation> I got from "overriding" argument.Rafael Costa
03/06/2024, 9:37 PMresolve then I get a KSTypeReference .. how can I convert that into KSType ?Rafael Costa
03/06/2024, 9:59 PMT if I was using declaration , like:
it.annotationType.resolve().declaration.typeParameters.first()
Since then I was actually going to the declaration of the annotation type (ExternalDestination )Rafael Costa
03/06/2024, 10:00 PM@ExternalModuleDestinations<AbcType>. In that case I do get AbcType with
ksAnnotation.annotationType.resolve().arguments.first().type!!.resolve()Rafael Costa
03/06/2024, 10:02 PMRafael Costa
03/07/2024, 11:30 AMJiaxiang
03/07/2024, 9:35 PM