IDEA plugin: fixed crashing ifExpressionToElvis intention when applying to if expression which is part of another expression.

#EA-57307 fixed
This commit is contained in:
Zalim Bashorov
2014-06-16 16:05:46 +04:00
parent 64175d3996
commit 247808e17b
5 changed files with 38 additions and 1 deletions
@@ -0,0 +1,9 @@
fun maybeFoo(): String? {
return "foo"
}
fun main(args: Array<String>) {
val foo = maybeFoo()
val bar = "bar"
val x = "baz" + if (foo == null<caret>) bar else foo
}
@@ -0,0 +1,8 @@
fun maybeFoo(): String? {
return "foo"
}
fun main(args: Array<String>) {
val bar = "bar"
val x = "baz" + (maybeFoo() ?: bar)
}
@@ -47,6 +47,14 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'.</problem_class>
<description>Replace 'if' expression with elvis expression</description>
</problem>
<problem>
<file>ifAsPartOfExpression.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/src/ifAsPartOfExpression.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'.</problem_class>
<description>Replace 'if' expression with elvis expression</description>
</problem>
<problem>
<file>ifAndElseNotInBlocks.kt</file>
<line>8</line>