Merge pull request #450 from wutalman/assert_to_if

KT-4576: (Bug fix) Intention to transform an if an AssertionError throw into an assert
This commit is contained in:
Zalim Bashorov
2014-04-22 17:30:22 +04:00
4 changed files with 22 additions and 1 deletions
@@ -28,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils
import kotlin.properties.Delegates
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
import org.jetbrains.jet.lang.psi.JetIfExpression
import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression
public class ConvertAssertToIfWithThrowIntention : JetSelfTargetingIntention<JetCallExpression>(
"convert.assert.to.if.with.throw", javaClass()) {
@@ -98,6 +99,11 @@ public class ConvertAssertToIfWithThrowIntention : JetSelfTargetingIntention<Jet
simplifier.applyTo(ifCondition, editor)
}
element.replace(ifExpression)
val parent = element.getParent()
if (parent is JetDotQualifiedExpression) {
parent.replace(ifExpression)
} else {
element.replace(ifExpression)
}
}
}