New J2K: Add JKThrowStatement and JKContinueStatement to SwitchStatementConversion's falls fallsThrough()

This commit is contained in:
Ilya Kirillov
2018-11-14 14:33:23 +03:00
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())