Uast: don't fall on empty when entries (EA-231339)
This commit is contained in:
+18
-15
@@ -72,21 +72,24 @@ class KotlinUSwitchEntry(
|
||||
is KtBlockExpression -> exprPsi.statements.map { KotlinConverter.convertOrEmpty(it, this) }
|
||||
else -> listOf(KotlinConverter.convertOrEmpty(exprPsi, this))
|
||||
}
|
||||
expressions = userExpressions.subList(0, userExpressions.lastIndex) + object : UYieldExpression, JvmDeclarationUElementPlaceholder {
|
||||
override val javaPsi: PsiElement? = null
|
||||
override val sourcePsi: PsiElement? = null
|
||||
override val psi: PsiElement?
|
||||
get() = null
|
||||
override val label: String?
|
||||
get() = null
|
||||
override val uastParent: UElement?
|
||||
get() = this@KotlinUExpressionList
|
||||
override val annotations: List<UAnnotation>
|
||||
get() = emptyList()
|
||||
override val expression: UExpression?
|
||||
get() = userExpressions.lastOrNull()?.sourcePsi.safeAs<KtExpression>()
|
||||
?.let { KotlinConverter.convertExpression(it, this, DEFAULT_EXPRESSION_TYPES_LIST) }
|
||||
}
|
||||
expressions =
|
||||
if (userExpressions.isNotEmpty())
|
||||
userExpressions.subList(0, userExpressions.lastIndex) + object : UYieldExpression, JvmDeclarationUElementPlaceholder {
|
||||
override val javaPsi: PsiElement? = null
|
||||
override val sourcePsi: PsiElement? = null
|
||||
override val psi: PsiElement?
|
||||
get() = null
|
||||
override val label: String?
|
||||
get() = null
|
||||
override val uastParent: UElement?
|
||||
get() = this@KotlinUExpressionList
|
||||
override val annotations: List<UAnnotation>
|
||||
get() = emptyList()
|
||||
override val expression: UExpression?
|
||||
get() = userExpressions.lastOrNull()?.sourcePsi.safeAs<KtExpression>()
|
||||
?.let { KotlinConverter.convertExpression(it, this, DEFAULT_EXPRESSION_TYPES_LIST) }
|
||||
}
|
||||
else emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ fun getElementsAdditionalResolve(string: String): String {
|
||||
return "bindingContext"
|
||||
}
|
||||
|
||||
"empty-switch" -> {}
|
||||
|
||||
else -> {
|
||||
val (bindingContext, statementFilter) = arr
|
||||
return bindingContext
|
||||
|
||||
+7
-3
@@ -24,23 +24,27 @@ UFile (package = )
|
||||
UReturnExpression
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "bindingContext")
|
||||
USwitchClauseExpressionWithBody
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "empty-switch")
|
||||
UExpressionList (when_entry)
|
||||
USwitchClauseExpressionWithBody
|
||||
UExpressionList (when_entry)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = var837f1e82)
|
||||
ULocalVariable (name = var837f2350)
|
||||
UAnnotation (fqName = null)
|
||||
USimpleNameReferenceExpression (identifier = arr)
|
||||
ULocalVariable (name = bindingContext)
|
||||
UAnnotation (fqName = null)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = var837f1e82)
|
||||
USimpleNameReferenceExpression (identifier = var837f2350)
|
||||
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)
|
||||
USimpleNameReferenceExpression (identifier = var837f2350)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (component2))
|
||||
USimpleNameReferenceExpression (identifier = <anonymous class>, resolvesTo = null)
|
||||
|
||||
@@ -24,23 +24,28 @@ UFile (package = )
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "bindingContext")
|
||||
UBreakExpression (label = null)
|
||||
USwitchClauseExpressionWithBody
|
||||
UPolyadicExpression (operator = +)
|
||||
ULiteralExpression (value = "empty-switch")
|
||||
UExpressionList (when_entry)
|
||||
UBreakExpression (label = null)
|
||||
USwitchClauseExpressionWithBody
|
||||
UExpressionList (when_entry)
|
||||
UDeclarationsExpression
|
||||
ULocalVariable (name = var837f1e82)
|
||||
ULocalVariable (name = var837f2350)
|
||||
UAnnotation (fqName = null)
|
||||
USimpleNameReferenceExpression (identifier = arr)
|
||||
ULocalVariable (name = bindingContext)
|
||||
UAnnotation (fqName = null)
|
||||
UQualifiedReferenceExpression
|
||||
USimpleNameReferenceExpression (identifier = var837f1e82)
|
||||
USimpleNameReferenceExpression (identifier = var837f2350)
|
||||
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)
|
||||
USimpleNameReferenceExpression (identifier = var837f2350)
|
||||
UCallExpression (kind = UastCallKind(name='method_call'), argCount = 0))
|
||||
UIdentifier (Identifier (component2))
|
||||
USimpleNameReferenceExpression (identifier = <anonymous class>, resolvesTo = null)
|
||||
|
||||
@@ -6,10 +6,13 @@ public final class WhenAndDestructingKt {
|
||||
yield return "bindingContext"
|
||||
}
|
||||
|
||||
"empty-switch" -> {
|
||||
}
|
||||
|
||||
-> {
|
||||
@null var var837f1e82: <ErrorType> = arr
|
||||
@null var bindingContext: java.lang.String = var837f1e82.<anonymous class>()
|
||||
@null var statementFilter: java.lang.String = var837f1e82.<anonymous class>()
|
||||
@null var var837f2350: <ErrorType> = arr
|
||||
@null var bindingContext: java.lang.String = var837f2350.<anonymous class>()
|
||||
@null var statementFilter: java.lang.String = var837f2350.<anonymous class>()
|
||||
yield return bindingContext
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,14 @@ public final class WhenAndDestructingKt {
|
||||
break
|
||||
}
|
||||
|
||||
"empty-switch" -> {
|
||||
break
|
||||
}
|
||||
|
||||
-> {
|
||||
@null var var837f1e82: <ErrorType> = arr
|
||||
@null var bindingContext: java.lang.String = var837f1e82.<anonymous class>()
|
||||
@null var statementFilter: java.lang.String = var837f1e82.<anonymous class>()
|
||||
@null var var837f2350: <ErrorType> = arr
|
||||
@null var bindingContext: java.lang.String = var837f2350.<anonymous class>()
|
||||
@null var statementFilter: java.lang.String = var837f2350.<anonymous class>()
|
||||
return bindingContext
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user