Suggest "Remove braces" in nested if correctly #KT-14270 Fixed

This commit is contained in:
Toshiaki Kameyama
2018-03-07 04:51:02 +03:00
committed by Mikhail Glukhikh
parent 8082a5daf7
commit e328d2d1ca
11 changed files with 119 additions and 1 deletions
@@ -38,7 +38,10 @@ class RemoveBracesIntention : SelfTargetingIntention<KtElement>(KtElement::class
val container = block.parent
when (container) {
is KtContainerNode -> {
if (singleStatement is KtIfExpression && container.parent is KtIfExpression) return false
if (singleStatement is KtIfExpression) {
val elseExpression = (container.parent as? KtIfExpression)?.`else`
if (elseExpression != null && elseExpression != block) return false
}
val description = container.description() ?: return false
text = "Remove braces from '$description' statement"