diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/EliminateWhenSubjectIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/EliminateWhenSubjectIntention.kt index 3dedeca07fc..1bef17160c7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/EliminateWhenSubjectIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/EliminateWhenSubjectIntention.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.toExpression import org.jetbrains.kotlin.psi.JetPsiFactory import org.jetbrains.kotlin.psi.JetSimpleNameExpression import org.jetbrains.kotlin.psi.JetWhenExpression +import org.jetbrains.kotlin.psi.buildExpression public class EliminateWhenSubjectIntention : JetSelfTargetingIntention(javaClass(), "Eliminate argument of 'when'") { override fun isApplicableTo(element: JetWhenExpression, caretOffset: Int): Boolean { @@ -33,21 +34,32 @@ public class EliminateWhenSubjectIntention : JetSelfTargetingIntention 0) appendFixedText(",") + appendNonFormattedText(condition.toExpressionText(subject)) + } + } + appendFixedText("->") + + if (branchExpression != null) { + appendExpression(branchExpression) + } + appendFixedText("\n") } - builder.branchExpression(branchExpression) + appendFixedText("}") } - element.replace(builder.toExpression()) + element.replace(whenExpression) } }