Uast: support for annotated expressions (KT-35801)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
fun foo() {
|
||||
|
||||
@Suppress
|
||||
foo()
|
||||
|
||||
@Suppress
|
||||
val a = 1
|
||||
|
||||
@Suppress
|
||||
var b = 2
|
||||
|
||||
@Suppress
|
||||
b = a
|
||||
|
||||
@Suppress
|
||||
if (a > 2)
|
||||
a
|
||||
else
|
||||
b
|
||||
|
||||
val c = @Suppress a ?: b
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
UFile (package = )
|
||||
UClass (name = AnnotatedExpressionsKt)
|
||||
UMethod (name = foo)
|
||||
UBlockExpression
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UAnnotation (fqName = kotlin.Suppress)
|
||||
UIdentifier (Identifier (foo))
|
||||
USimpleNameReferenceExpression (identifier = foo, resolvesTo = null)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = a)
|
||||
UAnnotation (fqName = kotlin.Suppress)
|
||||
ULiteralExpression (value = 1)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = b)
|
||||
UAnnotation (fqName = kotlin.Suppress)
|
||||
ULiteralExpression (value = 2)
|
||||
UBinaryExpression (operator = =)
|
||||
UAnnotation (fqName = kotlin.Suppress)
|
||||
USimpleNameReferenceExpression (identifier = b)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
UIfExpression
|
||||
UAnnotation (fqName = kotlin.Suppress)
|
||||
UBinaryExpression (operator = >)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
ULiteralExpression (value = 2)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
USimpleNameReferenceExpression (identifier = b)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = c)
|
||||
UExpressionList (elvis)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = varae507364)
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
UAnnotation (fqName = kotlin.Suppress)
|
||||
UIfExpression
|
||||
UBinaryExpression (operator = !=)
|
||||
USimpleNameReferenceExpression (identifier = varae507364)
|
||||
ULiteralExpression (value = null)
|
||||
USimpleNameReferenceExpression (identifier = varae507364)
|
||||
USimpleNameReferenceExpression (identifier = b)
|
||||
@@ -0,0 +1,13 @@
|
||||
public final class AnnotatedExpressionsKt {
|
||||
public static final fun foo() : void {
|
||||
foo()
|
||||
@kotlin.Suppress var a: int = 1
|
||||
@kotlin.Suppress var b: int = 2
|
||||
b = a
|
||||
if (a > 2) a else b
|
||||
var c: int = elvis {
|
||||
var varae507364: int = a
|
||||
if (varae507364 != null) varae507364 else b
|
||||
}
|
||||
}
|
||||
}
|
||||
-2
@@ -16,11 +16,9 @@ UFile (package = )
|
||||
UExpressionList (elvis)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = var243c51a0)
|
||||
UAnnotation (fqName = null)
|
||||
UExpressionList (elvis)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = varc4aef569)
|
||||
UAnnotation (fqName = null)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 1))
|
||||
UIdentifier (Identifier (foo))
|
||||
USimpleNameReferenceExpression (identifier = foo, resolvesTo = null)
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ public final class ElvisKt {
|
||||
}
|
||||
public static final fun baz() : java.lang.String {
|
||||
return elvis {
|
||||
@null var var243c51a0: java.lang.String = elvis {
|
||||
@null var varc4aef569: java.lang.String = foo("Lorem ipsum")
|
||||
var var243c51a0: java.lang.String = elvis {
|
||||
var varc4aef569: java.lang.String = foo("Lorem ipsum")
|
||||
if (varc4aef569 != null) varc4aef569 else foo("dolor sit amet")
|
||||
}
|
||||
if (var243c51a0 != null) var243c51a0 else bar().toString()
|
||||
|
||||
@@ -31,7 +31,6 @@ UFile (package = )
|
||||
UExpressionList (elvis)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = var708e23eb)
|
||||
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
|
||||
USimpleNameReferenceExpression (identifier = arg)
|
||||
UIfExpression
|
||||
UBinaryExpression (operator = !=)
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ public final class TypeReferencesKt {
|
||||
public static final fun parameterizedFoo(@org.jetbrains.annotations.Nullable arg: T) : void {
|
||||
var a: T = arg
|
||||
var at: T = elvis {
|
||||
@org.jetbrains.annotations.Nullable var var708e23eb: T = arg
|
||||
var var708e23eb: T = arg
|
||||
if (var708e23eb != null) var708e23eb else return
|
||||
}
|
||||
var tl: java.util.List<? extends T> = listOf(at)
|
||||
|
||||
Reference in New Issue
Block a user