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
0
5 comments
Official 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)

Avatar
Permanently deleted user

0
Avatar
Permanently deleted user
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)
}}
0
Avatar
Permanently deleted user

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.

0
Avatar
Permanently deleted user

without annotation placeName2 correctly parsed as KotlinUSimpleReferenceExpression

0

Please sign in to leave a comment.