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