Hi, i want to detect annotated expressions. Does s...
# compiler
f
Hi, i want to detect annotated expressions. Does someone know which class i could use for that?
r
Depending on the phase you are working that would be different classes: KtAnnotationEntry, AnnotationDescriptor, IrAnnotationContainer, …
You can usually traverse the AST in those phases by using recursive visitors which there already a few out there used in the compiler and just intercept the visit for those types
f
okay, thank you, i will take a look
👍 1
s
If you are looking for annotated declarations (e.g. classes or function definitions), you can use
DeclarationChecker
with
AnnotationBasedExtension
to help you out. See
SerializationPluginDeclarationChecker
from Kotlin sources as example. In case of other expressions (e.g. actual method calls), it is a bit more complicated, so you'll have to traverse the tree yourself.