Uast: handling annotations on the property receiver (KT-40539)
This commit is contained in:
@@ -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 {
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user