New J2K: Add JKThrowStatement and JKContinueStatement to SwitchStatementConversion's falls fallsThrough()
This commit is contained in:
committed by
Ilya Kirillov
parent
42dc96d9a8
commit
5236858c20
@@ -89,16 +89,22 @@ class SwitchStatementConversion(private val context: ConversionContext) : Recurs
|
|||||||
all { it.fallsThrough() }
|
all { it.fallsThrough() }
|
||||||
|
|
||||||
private fun JKStatement.fallsThrough(): Boolean =
|
private fun JKStatement.fallsThrough(): Boolean =
|
||||||
when (this) {
|
when {
|
||||||
//TODO add support of this when will be added
|
this.isThrowStatement() ||
|
||||||
// is JKThrowStatement || is JKContinueStatement -> false
|
this is JKBreakStatement ||
|
||||||
is JKBreakStatement, is JKReturnStatement -> false
|
this is JKReturnStatement ||
|
||||||
is JKBlockStatement -> block.statements.fallsThrough()
|
this is JKContinueStatement -> false
|
||||||
is JKIfStatement, is JKJavaSwitchStatement, is JKKtWhenStatement ->
|
this is JKBlockStatement -> block.statements.fallsThrough()
|
||||||
|
this is JKIfStatement ||
|
||||||
|
this is JKJavaSwitchStatement ||
|
||||||
|
this is JKKtWhenStatement ->
|
||||||
this.psi!!.canCompleteNormally()
|
this.psi!!.canCompleteNormally()
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun JKStatement.isThrowStatement(): Boolean =
|
||||||
|
(this as? JKExpressionStatement)?.expression is JKKtThrowExpression
|
||||||
|
|
||||||
private fun PsiElement.canCompleteNormally(): Boolean {
|
private fun PsiElement.canCompleteNormally(): Boolean {
|
||||||
val controlFlow =
|
val controlFlow =
|
||||||
ControlFlowFactory.getInstance(project).getControlFlow(this, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance())
|
ControlFlowFactory.getInstance(project).getControlFlow(this, LocalsOrMyInstanceFieldsControlFlowPolicy.getInstance())
|
||||||
|
|||||||
Reference in New Issue
Block a user