Intention to convert anonymous function to lambda

This commit is contained in:
Natalia Ukhorskaya
2015-12-15 10:22:53 +03:00
parent c79ffbac5c
commit 693e158759
27 changed files with 451 additions and 57 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.intentions.AnonymousFunctionToLambdaIntention
@@ -0,0 +1,10 @@
fun foo(f: () -> Unit) {
f()
}
fun main(args: String) {
foo(<caret>fun() {
val p1 = 1
val p2 = 1
})
}
@@ -0,0 +1,10 @@
fun foo(f: () -> Unit) {
f()
}
fun main(args: String) {
foo {
val p1 = 1
val p2 = 1
}
}
@@ -0,0 +1,7 @@
class Foo(f: () -> Unit)
fun main(args: String) {
Foo(fun<caret>() {
val p = 1
})
}
@@ -0,0 +1,5 @@
class Foo(f: () -> Unit)
fun main(args: String) {
Foo { val p = 1 }
}
@@ -0,0 +1,7 @@
fun foo3(f: () -> Int) {
f()
}
fun main(args: String) {
foo3(<caret>fun () = 1)
}
@@ -0,0 +1,7 @@
fun foo3(f: () -> Int) {
f()
}
fun main(args: String) {
foo3 { 1 }
}
@@ -0,0 +1,9 @@
fun foo2(f: (Int) -> Unit) {
f(1)
}
fun main(args: String) {
foo2(<caret>fun(i: Int) {
val p = i
})
}
@@ -0,0 +1,7 @@
fun foo2(f: (Int) -> Unit) {
f(1)
}
fun main(args: String) {
foo2 { i -> val p = i }
}
@@ -0,0 +1,9 @@
fun foo(f: () -> Unit, i: Int) {
f()
}
fun main(args: String) {
foo(<caret>fun() {
val p = 1
}, 1)
}
@@ -0,0 +1,7 @@
fun foo(f: () -> Unit, i: Int) {
f()
}
fun main(args: String) {
foo({ val p = 1 }, 1)
}
@@ -0,0 +1,9 @@
fun foo2(f: (Int) -> Unit) {
f(1)
}
fun main(args: String) {
foo2(<caret>fun(i) {
val p = i
})
}
@@ -0,0 +1,7 @@
fun foo2(f: (Int) -> Unit) {
f(1)
}
fun main(args: String) {
foo2 { i -> val p = i }
}
@@ -0,0 +1,9 @@
fun foo(f: () -> Int) {
f()
}
fun main(args: String) {
foo(<caret>fun(): Int {
return 1
})
}
@@ -0,0 +1,7 @@
fun foo(f: () -> Int) {
f()
}
fun main(args: String) {
foo { 1 }
}
@@ -0,0 +1,13 @@
fun foo(f: () -> Int) {
f()
}
fun main(args: String) {
foo(<caret>fun(): Int {
val a = 1
if (a > 1) {
return 1
}
return 2
})
}
@@ -0,0 +1,13 @@
fun foo(f: () -> Int) {
f()
}
fun main(args: String) {
foo {
val a = 1
if (a > 1) {
return@foo 1
}
2
}
}
@@ -0,0 +1,9 @@
fun foo(f: () -> Unit) {
f()
}
fun main(args: String) {
foo(fun<caret>() {
val p = 1
})
}
@@ -0,0 +1,7 @@
fun foo(f: () -> Unit) {
f()
}
fun main(args: String) {
foo { val p = 1 }
}