Add intention for converting an implicit 'it' parameter to an explicitly named parameter

Kotlin's function literals have a shortcut for one-argument literals:
the single argument doesn't need to be explicitly named, but can be
referred via the 'it' contextual keyword. Add an intention action for
converting an implicit 'it' parameter to an explicitly named one.

For example, 'array(1, 2, 3).filter { it % 2 == 0 }'
          -> 'array(1, 2, 3).filter { x -> x % 2 == 0 }'
This commit is contained in:
Tuomas Tynkkynen
2014-02-08 15:33:32 -08:00
committed by Nikolay Krasko
parent c6d6a32314
commit 8ce0d43118
17 changed files with 154 additions and 1 deletions
@@ -0,0 +1 @@
array(1, 2, 3).filter <spot>{ x -> x % 2 == 0 }</spot>
@@ -0,0 +1 @@
array(1, 2, 3).filter <spot>{ it % 2 == 0 }</spot>
@@ -0,0 +1,5 @@
<html>
<body>
This intention replaces the implicit 'it' parameter in a function literal with an explicitly named parameter.
</body>
</html>