When to if now add braces for if branches inside #KT-12942 Fixed

(cherry picked from commit 29a7bfe)
This commit is contained in:
Mikhail Glukhikh
2016-07-11 19:09:12 +03:00
committed by Mikhail Glukhikh
parent b675b49daf
commit 3fe114fc24
4 changed files with 34 additions and 0 deletions
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.TextRange
import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.combineWhenConditions
import org.jetbrains.kotlin.idea.util.CommentSaver
import org.jetbrains.kotlin.psi.KtIfExpression
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.KtWhenExpression
import org.jetbrains.kotlin.psi.buildExpression
@@ -54,7 +55,13 @@ class WhenToIfIntention : SelfTargetingRangeIntention<KtWhenExpression>(KtWhenEx
appendFixedText("if (")
appendExpression(condition)
appendFixedText(")")
if (branch is KtIfExpression) {
appendFixedText("{ ")
}
appendExpression(branch)
if (branch is KtIfExpression) {
appendFixedText(" }")
}
}
if (i != entries.lastIndex) {
appendFixedText("\n")