JetBrains/kotlin — pull request #393 by zgrannan (2014-02-28 05:50:04+00:00)
Title: safe access ↔ if-then and elvis ↔ if-then intentions

This pull requests adds four intention actions:

Elvis → If Then
If Then → Elvis
If Then → Safe Access
Safe Access → If Then

safe access ↔ if-then expression intention
------------------------------------------

Added an intention to convert an expression of the form

foo?.bar()

to the form

if (foo != null) foo.bar() else null

and vice versa.

If the expression of the left hand side of the safe-access operator is a
function call, the IDE will prompt the user create a temporary value to store
the result of the call. i.e an safe-access expression of the form:

foo()?.bar

could be converted to the form

val temp = foo()
if (temp != null) temp.bar() else null

elvis ↔ if-then intentions
---------------------------

Added an intention to convert an expression of the form

foo ?: bar

to the form

if (foo != null) foo else bar

and vice versa.

If the expression of the left hand side of the elvis expression is a function
call, the IDE will prompt the user to create a temporary value to store the
result of the call. i.e an elvis expression of the form:

foo() ?: bar

could be converted to the form

val temp = foo()
if (temp != null) temp else bar