Uast: skip KtWhenConditionWithExpression in UAST (KT-38521)

when building parents, because they are anyway ignored in converter
This commit is contained in:
Nicolay Mitropolsky
2020-04-27 19:10:57 +03:00
parent 903f35ce0c
commit b7e715045a
6 changed files with 170 additions and 1 deletions
@@ -197,6 +197,7 @@ internal object KotlinConverter {
is KtSuperTypeList -> unwrapElements(element.parent)
is KtFinallySection -> unwrapElements(element.parent)
is KtAnnotatedExpression -> unwrapElements(element.parent)
is KtWhenConditionWithExpression -> unwrapElements(element.parent)
else -> element
}
+9 -1
View File
@@ -20,4 +20,12 @@ fun foo() {
val c = @Suppress a ?: b
}
}
fun annotatedSwitch(str: String) =
when {
@Suppress("DEPRECATION")
str.isBlank() -> null
str.isNotEmpty() != null -> null
else -> 1
}
@@ -38,3 +38,38 @@ UFile (package = )
ULiteralExpression (value = null)
USimpleNameReferenceExpression (identifier = varae507364)
USimpleNameReferenceExpression (identifier = b)
UMethod (name = annotatedSwitch)
UParameter (name = str)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
USwitchExpression
UExpressionList (when)
USwitchClauseExpressionWithBody
UQualifiedReferenceExpression
UAnnotation (fqName = kotlin.Suppress)
UNamedExpression (name = names)
UPolyadicExpression (operator = +)
ULiteralExpression (value = "DEPRECATION")
USimpleNameReferenceExpression (identifier = str)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (isBlank))
USimpleNameReferenceExpression (identifier = isBlank, resolvesTo = null)
UExpressionList (when_entry)
UYieldExpression
ULiteralExpression (value = null)
USwitchClauseExpressionWithBody
UBinaryExpression (operator = !=)
UQualifiedReferenceExpression
USimpleNameReferenceExpression (identifier = str)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (isNotEmpty))
USimpleNameReferenceExpression (identifier = isNotEmpty, resolvesTo = null)
ULiteralExpression (value = null)
UExpressionList (when_entry)
UYieldExpression
ULiteralExpression (value = null)
USwitchClauseExpressionWithBody
UExpressionList (when_entry)
UYieldExpression
ULiteralExpression (value = 1)
@@ -0,0 +1,75 @@
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)
UMethod (name = annotatedSwitch)
UParameter (name = str)
UAnnotation (fqName = org.jetbrains.annotations.NotNull)
UBlockExpression
UReturnExpression
USwitchExpression
UExpressionList (when)
USwitchClauseExpressionWithBody
UQualifiedReferenceExpression
UAnnotation (fqName = kotlin.Suppress)
UNamedExpression (name = names)
UPolyadicExpression (operator = +)
ULiteralExpression (value = "DEPRECATION")
USimpleNameReferenceExpression (identifier = str)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (isBlank))
USimpleNameReferenceExpression (identifier = isBlank, resolvesTo = null)
UExpressionList (when_entry)
ULiteralExpression (value = null)
UBreakExpression (label = null)
USwitchClauseExpressionWithBody
UBinaryExpression (operator = !=)
UQualifiedReferenceExpression
USimpleNameReferenceExpression (identifier = str)
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
UIdentifier (Identifier (isNotEmpty))
USimpleNameReferenceExpression (identifier = isNotEmpty, resolvesTo = null)
ULiteralExpression (value = null)
UExpressionList (when_entry)
ULiteralExpression (value = null)
UBreakExpression (label = null)
USwitchClauseExpressionWithBody
UExpressionList (when_entry)
ULiteralExpression (value = 1)
UBreakExpression (label = null)
@@ -10,4 +10,21 @@ public final class AnnotatedExpressionsKt {
if (varae507364 != null) varae507364 else b
}
}
public static final fun annotatedSwitch(@org.jetbrains.annotations.NotNull str: java.lang.String) : java.lang.Integer {
return switch {
str.isBlank() -> {
yield null
}
str.isNotEmpty() != null -> {
yield null
}
-> {
yield 1
}
}
}
}
@@ -0,0 +1,33 @@
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
}
}
public static final fun annotatedSwitch(@org.jetbrains.annotations.NotNull str: java.lang.String) : java.lang.Integer {
return switch {
str.isBlank() -> {
null
break
}
str.isNotEmpty() != null -> {
null
break
}
-> {
1
break
}
}
}
}