Uast: handling annotations on the property receiver (KT-40539)

This commit is contained in:
Nicolay Mitropolsky
2020-07-27 21:46:38 +03:00
parent 325ad56dcd
commit c254651ed3
5 changed files with 15 additions and 3 deletions
@@ -60,7 +60,13 @@ open class KotlinUMethod(
.map { KotlinUAnnotation(it, this) }
}
private val receiver by lz { (sourcePsi as? KtCallableDeclaration)?.receiverTypeReference }
private val receiver by lz {
when (sourcePsi) {
is KtCallableDeclaration -> sourcePsi
is KtPropertyAccessor -> sourcePsi.property
else -> null
}?.receiverTypeReference
}
override val uastParameters by lz {
+3
View File
@@ -11,6 +11,9 @@ UFile (package = )
USimpleNameReferenceExpression (identifier = length)
UMethod (name = getRx)
UParameter (name = $this$getRx)
UAnnotation (fqName = MyReceiverAnnotation)
UNamedExpression (name = name)
ULiteralExpression (value = "RegExp")
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
+3
View File
@@ -11,6 +11,9 @@ UFile (package = )
USimpleNameReferenceExpression (identifier = length)
UMethod (name = getRx)
UParameter (name = $this$rx)
UAnnotation (fqName = MyReceiverAnnotation)
UNamedExpression (name = name)
ULiteralExpression (value = "RegExp")
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
+1 -1
View File
@@ -2,7 +2,7 @@ public final class ReceiverFunKt {
public static final fun foo(@MyReceiverAnnotation @org.jetbrains.annotations.NotNull $this$foo: java.lang.String) : int {
return this.length
}
public static final fun getRx(@org.jetbrains.annotations.NotNull $this$getRx: java.lang.String) : kotlin.text.Regex {
public static final fun getRx(@MyReceiverAnnotation(name = "RegExp") @org.jetbrains.annotations.NotNull $this$getRx: java.lang.String) : kotlin.text.Regex {
return toRegex()
}
}
+1 -1
View File
@@ -2,7 +2,7 @@ public final class ReceiverFunKt {
public static final fun foo(@MyReceiverAnnotation @org.jetbrains.annotations.NotNull $this$foo: java.lang.String) : int {
return this.length
}
public static final fun getRx(@org.jetbrains.annotations.NotNull $this$rx: java.lang.String) : kotlin.text.Regex {
public static final fun getRx(@MyReceiverAnnotation(name = "RegExp") @org.jetbrains.annotations.NotNull $this$rx: java.lang.String) : kotlin.text.Regex {
return toRegex()
}
}