Expression Annotation parsed as org.jetbrains.uast.kotlin.UnknownKotlinExpression
Answered
package ru.wildberries.wms.components.annotations
@Target(AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
annotation class UseData
Please sign in to leave a comment.
Hi! Expression annotation is a Kotlin specific feature and is not supported by UAST. If you want to somehow work with expression under annotations you should better use regular `PsiElementVisitor` and get UElement by using `UastContext.toUElementOfType` (also it is a generally preferred way to write Uast-based inspections, not using UastVisitor)
class LambdaVisitor(val context: JavaContext, val declared: HashMap<String, Boolean>, val paramName: String, val call: UCallExpression, val isHaveArguments: Boolean) : AbstractUastVisitor() {
override fun visitElement(node: UElement): Boolean {
context.report(SHOW_TYPE, context.getLocation(node), "$node")
return super.visitElement(node)
}}
i make expression annotation @UseData
However, if I use it on degeneration, then the type of expression starts determined by the PSI tree as unknown.
Also, the annotation itself is not located via visitAnotation and in the PSI tree is of type org.jetbrains.uast.kotlin.UnknownKotlinExpression together with the element it marks.
without annotation placeName2 correctly parsed as KotlinUSimpleReferenceExpression