From 73a756084e7b6b383c0840a6975d8acfbd6f7c16 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Sat, 28 Apr 2018 16:21:31 +0300 Subject: [PATCH] Reformat: if to when --- .../intentions/IfToWhenIntention.kt | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfToWhenIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfToWhenIntention.kt index aa7d41522de..6a1f120b180 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfToWhenIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfToWhenIntention.kt @@ -39,16 +39,16 @@ class IfToWhenIntention : SelfTargetingRangeIntention(KtIfExpres } private fun canPassThrough(expression: KtExpression?): Boolean = - when (expression) { - is KtReturnExpression, is KtThrowExpression -> - false - is KtBlockExpression -> - expression.statements.all { canPassThrough(it) } - is KtIfExpression -> - canPassThrough(expression.then) || canPassThrough(expression.`else`) - else -> - true - } + when (expression) { + is KtReturnExpression, is KtThrowExpression -> + false + is KtBlockExpression -> + expression.statements.all { canPassThrough(it) } + is KtIfExpression -> + canPassThrough(expression.then) || canPassThrough(expression.`else`) + else -> + true + } private fun buildNextBranch(ifExpression: KtIfExpression): KtExpression? { var nextSibling = ifExpression.getNextSiblingIgnoringWhitespaceAndComments() ?: return null @@ -125,16 +125,13 @@ class IfToWhenIntention : SelfTargetingRangeIntention(KtIfExpres baseIfExpressionForSyntheticBranch = syntheticElseBranch currentIfExpression = syntheticElseBranch toDelete.add(syntheticElseBranch) - } - else { + } else { appendElseBlock(syntheticElseBranch) break } - } - else if (currentElseBranch is KtIfExpression) { + } else if (currentElseBranch is KtIfExpression) { currentIfExpression = currentElseBranch - } - else { + } else { appendElseBlock(currentElseBranch) applyFullCommentSaver = false break