ursus
09/06/2021, 1:50 AMKtNamedFunction. Is there a way to check if the type it represents, is a subclass of some another type? Or is that simply too soon to say at that point?Youssef Shoaib [MOD]
09/06/2021, 2:18 AMAnalysisHanflerExtension.analysisCompleted then you can use the BindingContext.getType(KtElement) to get a KotlinType that you can call isSubtypeOf onursus
09/06/2021, 2:23 AMoverride fun generateCode(
codeGenDir: File,
module: ModuleDescriptor,
projectFiles: Collection<KtFile>
): Collection<GeneratedFile> {
so I traverte the KtFiles as needed and I generate code thereursus
09/06/2021, 2:26 AMYoussef Shoaib [MOD]
09/06/2021, 2:34 AMursus
09/06/2021, 2:36 AMinterface Bar
class Foo : Bar
@MyAnnotation fun foo() : Foo = Foo()
@MyAnnototation = validate Foo extends Bar, else fail buildYoussef Shoaib [MOD]
09/06/2021, 2:40 AMBindingContext which includes all the analysis information about types, functions, etc. Without it, you can't realistically determine whether a type extends another or notursus
09/06/2021, 2:41 AMursus
09/06/2021, 2:41 AMursus
09/06/2021, 3:30 AMannotatedEntries, and now how would I match one that has @Scope ?
@Scope <------
@Retention(AnnotationRetention.RUNTIME)
annotation class AppScoperaulraja
09/06/2021, 9:51 AMfun AnnotationDescriptor.containsMetaAnnotation(name: FqName): Boolean =
type.constructor.declarationDescriptor?.annotations?.hasAnnotation(name) == trueraulraja
09/06/2021, 9:52 AMappScopeEntry.containsMetaAnnotation(FqName("your.package.Scope"))ursus
09/06/2021, 5:42 PMKtAnnotationEntry ?
I have KtNamedFunction.annotationEntries : List<KtAnnotationEntry>ursus
09/06/2021, 5:53 PMit.annotationEntries.first().typeReference?.annotations
but its empty even though there are meta annotationsraulraja
09/06/2021, 6:00 PMKtAnnotationEntry or the type, you need as Youssef mentioned before, the BindingContextraulraja
09/06/2021, 6:03 PMursus
09/06/2021, 6:04 PMraulraja
09/06/2021, 7:37 PM@Context but not sure you can build that on top of Anvil without access to the BindingContext. You would need your own plugin that has access to the BindingContext in analysisCompleted, call checker or declaration chequer extension points and with that you can resolve calls, declarations and annotations.