Uast: support for UYieldExpression (KT-35574)
This commit is contained in:
+7
-7
@@ -20,10 +20,10 @@ UFile (package = )
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "aaaa")
|
||||
UExpressionList (when_entry)
|
||||
UReturnExpression
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "bindingContext")
|
||||
UBreakExpression (label = null)
|
||||
UYieldExpression
|
||||
UReturnExpression
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "bindingContext")
|
||||
USwitchClauseExpressionWithBody
|
||||
UExpressionList (when_entry)
|
||||
UDeclarationsExpression
|
||||
@@ -44,6 +44,6 @@ UFile (package = )
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (component2))
|
||||
USimpleNameReferenceExpression (identifier = <anonymous class>, resolvesTo = null)
|
||||
UReturnExpression
|
||||
USimpleNameReferenceExpression (identifier = bindingContext)
|
||||
UBreakExpression (label = null)
|
||||
UYieldExpression
|
||||
UReturnExpression
|
||||
USimpleNameReferenceExpression (identifier = bindingContext)
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
UFile (package = )
|
||||
UClass (name = WhenAndDestructingKt)
|
||||
UMethod (name = getElementsAdditionalResolve)
|
||||
UParameter (name = string)
|
||||
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
|
||||
UBlockExpression
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = arr)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 2))
|
||||
UIdentifier (Identifier (listOf))
|
||||
USimpleNameReferenceExpression (identifier = listOf, resolvesTo = null)
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "1")
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "2")
|
||||
USwitchExpression
|
||||
USimpleNameReferenceExpression (identifier = string)
|
||||
UExpressionList (when)
|
||||
USwitchClauseExpressionWithBody
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "aaaa")
|
||||
UExpressionList (when_entry)
|
||||
UReturnExpression
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "bindingContext")
|
||||
UBreakExpression (label = null)
|
||||
USwitchClauseExpressionWithBody
|
||||
UExpressionList (when_entry)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = var837f1e82)
|
||||
UAnnotation (fqName = null)
|
||||
USimpleNameReferenceExpression (identifier = arr)
|
||||
ULocalVariable (name = bindingContext)
|
||||
UAnnotation (fqName = null)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = var837f1e82)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (component1))
|
||||
USimpleNameReferenceExpression (identifier = <anonymous class>, resolvesTo = null)
|
||||
ULocalVariable (name = statementFilter)
|
||||
UAnnotation (fqName = null)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = var837f1e82)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (component2))
|
||||
USimpleNameReferenceExpression (identifier = <anonymous class>, resolvesTo = null)
|
||||
UReturnExpression
|
||||
USimpleNameReferenceExpression (identifier = bindingContext)
|
||||
UBreakExpression (label = null)
|
||||
@@ -3,16 +3,14 @@ public final class WhenAndDestructingKt {
|
||||
var arr: java.util.List<? extends java.lang.String> = listOf("1", "2")
|
||||
switch (string) {
|
||||
"aaaa" -> {
|
||||
return "bindingContext"
|
||||
break
|
||||
yield return "bindingContext"
|
||||
}
|
||||
|
||||
-> {
|
||||
@null var var837f1e82: <ErrorType> = arr
|
||||
@null var bindingContext: java.lang.String = var837f1e82.<anonymous class>()
|
||||
@null var statementFilter: java.lang.String = var837f1e82.<anonymous class>()
|
||||
return bindingContext
|
||||
break
|
||||
yield return bindingContext
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
public final class WhenAndDestructingKt {
|
||||
public static final fun getElementsAdditionalResolve(@org.jetbrains.annotations.NotNull string: java.lang.String) : java.lang.String {
|
||||
var arr: java.util.List<? extends java.lang.String> = listOf("1", "2")
|
||||
switch (string) {
|
||||
"aaaa" -> {
|
||||
return "bindingContext"
|
||||
break
|
||||
}
|
||||
|
||||
-> {
|
||||
@null var var837f1e82: <ErrorType> = arr
|
||||
@null var bindingContext: java.lang.String = var837f1e82.<anonymous class>()
|
||||
@null var statementFilter: java.lang.String = var837f1e82.<anonymous class>()
|
||||
return bindingContext
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -13,13 +13,13 @@ UFile (package = )
|
||||
USimpleNameReferenceExpression (identifier = it)
|
||||
UTypeReferenceExpression (name = java.lang.String)
|
||||
UExpressionList (when_entry)
|
||||
USimpleNameReferenceExpression (identifier = bar)
|
||||
UBreakExpression (label = null)
|
||||
UYieldExpression
|
||||
USimpleNameReferenceExpression (identifier = bar)
|
||||
USwitchClauseExpressionWithBody
|
||||
UBinaryExpressionWithType
|
||||
USimpleNameReferenceExpression (identifier = it)
|
||||
UTypeReferenceExpression (name = java.lang.String)
|
||||
UExpressionList (when_entry)
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "<error>")
|
||||
UBreakExpression (label = null)
|
||||
UYieldExpression
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "<error>")
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
UFile (package = )
|
||||
UClass (name = WhenIsKt)
|
||||
UMethod (name = foo)
|
||||
UParameter (name = bar)
|
||||
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
|
||||
UBlockExpression
|
||||
UReturnExpression
|
||||
USwitchExpression
|
||||
USimpleNameReferenceExpression (identifier = bar)
|
||||
UExpressionList (when)
|
||||
USwitchClauseExpressionWithBody
|
||||
UBinaryExpressionWithType
|
||||
USimpleNameReferenceExpression (identifier = it)
|
||||
UTypeReferenceExpression (name = java.lang.String)
|
||||
UExpressionList (when_entry)
|
||||
USimpleNameReferenceExpression (identifier = bar)
|
||||
UBreakExpression (label = null)
|
||||
USwitchClauseExpressionWithBody
|
||||
UBinaryExpressionWithType
|
||||
USimpleNameReferenceExpression (identifier = it)
|
||||
UTypeReferenceExpression (name = java.lang.String)
|
||||
UExpressionList (when_entry)
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "<error>")
|
||||
UBreakExpression (label = null)
|
||||
+2
-4
@@ -2,13 +2,11 @@ public final class WhenIsKt {
|
||||
public static final fun foo(@org.jetbrains.annotations.NotNull bar: java.lang.Object) : java.lang.String {
|
||||
return switch (bar) {
|
||||
it is java.lang.String -> {
|
||||
bar
|
||||
break
|
||||
yield bar
|
||||
}
|
||||
|
||||
it !is java.lang.String -> {
|
||||
"<error>"
|
||||
break
|
||||
yield "<error>"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
public final class WhenIsKt {
|
||||
public static final fun foo(@org.jetbrains.annotations.NotNull bar: java.lang.Object) : java.lang.String {
|
||||
return switch (bar) {
|
||||
it is java.lang.String -> {
|
||||
bar
|
||||
break
|
||||
}
|
||||
|
||||
it !is java.lang.String -> {
|
||||
"<error>"
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -14,20 +14,20 @@ UFile (package = )
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "abc")
|
||||
UExpressionList (when_entry)
|
||||
ULiteralExpression (value = 1)
|
||||
UBreakExpression (label = null)
|
||||
UYieldExpression
|
||||
ULiteralExpression (value = 1)
|
||||
USwitchClauseExpressionWithBody
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "def")
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "ghi")
|
||||
UExpressionList (when_entry)
|
||||
ULiteralExpression (value = 2)
|
||||
UBreakExpression (label = null)
|
||||
UYieldExpression
|
||||
ULiteralExpression (value = 2)
|
||||
USwitchClauseExpressionWithBody
|
||||
UExpressionList (when_entry)
|
||||
ULiteralExpression (value = 3)
|
||||
UBreakExpression (label = null)
|
||||
UYieldExpression
|
||||
ULiteralExpression (value = 3)
|
||||
UMethod (name = getA)
|
||||
UMethod (name = getB)
|
||||
UMethod (name = <no name provided>)
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
UFile (package = )
|
||||
UClass (name = WhenStringLiteralKt)
|
||||
UField (name = a)
|
||||
UAnnotation (fqName = org.jetbrains.annotations.Nullable)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (readLine))
|
||||
USimpleNameReferenceExpression (identifier = readLine, resolvesTo = null)
|
||||
UField (name = b)
|
||||
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
|
||||
USwitchExpression
|
||||
USimpleNameReferenceExpression (identifier = a)
|
||||
UExpressionList (when)
|
||||
USwitchClauseExpressionWithBody
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "abc")
|
||||
UExpressionList (when_entry)
|
||||
ULiteralExpression (value = 1)
|
||||
UBreakExpression (label = null)
|
||||
USwitchClauseExpressionWithBody
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "def")
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "ghi")
|
||||
UExpressionList (when_entry)
|
||||
ULiteralExpression (value = 2)
|
||||
UBreakExpression (label = null)
|
||||
USwitchClauseExpressionWithBody
|
||||
UExpressionList (when_entry)
|
||||
ULiteralExpression (value = 3)
|
||||
UBreakExpression (label = null)
|
||||
UMethod (name = getA)
|
||||
UMethod (name = getB)
|
||||
UMethod (name = <no name provided>)
|
||||
UBlockExpression
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "abc1")
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "def1")
|
||||
@@ -2,18 +2,15 @@ public final class WhenStringLiteralKt {
|
||||
@org.jetbrains.annotations.Nullable private static final var a: java.lang.String = readLine()
|
||||
@org.jetbrains.annotations.NotNull private static final var b: int = switch (a) {
|
||||
"abc" -> {
|
||||
1
|
||||
break
|
||||
yield 1
|
||||
}
|
||||
|
||||
"def", "ghi" -> {
|
||||
2
|
||||
break
|
||||
yield 2
|
||||
}
|
||||
|
||||
-> {
|
||||
3
|
||||
break
|
||||
yield 3
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
public final class WhenStringLiteralKt {
|
||||
@org.jetbrains.annotations.Nullable private static final var a: java.lang.String = readLine()
|
||||
@org.jetbrains.annotations.NotNull private static final var b: int = switch (a) {
|
||||
"abc" -> {
|
||||
1
|
||||
break
|
||||
}
|
||||
|
||||
"def", "ghi" -> {
|
||||
2
|
||||
break
|
||||
}
|
||||
|
||||
-> {
|
||||
3
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final fun getA() : java.lang.String = UastEmptyExpression
|
||||
public static final fun getB() : int = UastEmptyExpression
|
||||
public static final fun <no name provided>() : void {
|
||||
"abc1"
|
||||
"def1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user