Convert to scope function: refactor
This commit is contained in:
committed by
Mikhail Glukhikh
parent
0501a108c0
commit
f15c8f78fa
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ConvertToRunIntention
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(it: MyClass) {
|
||||
it.foo1()<caret>
|
||||
it.foo2()
|
||||
it.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(it: MyClass) {
|
||||
it.run {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public class JavaClass {
|
||||
void bar1() {}
|
||||
void bar2() {}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public class JavaClass {
|
||||
void bar1() {}
|
||||
void bar2() {}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(c: JavaClass) {
|
||||
<caret>c.bar1()
|
||||
c.bar2()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(c: JavaClass) {
|
||||
c.run {
|
||||
bar1()
|
||||
bar2()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public class JavaClass {
|
||||
public static void foo1() {}
|
||||
public static void foo2() {}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun test() {
|
||||
<caret>JavaClass.foo1()
|
||||
JavaClass.foo2()
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1(): MyClass = this
|
||||
fun foo2(): MyClass = this
|
||||
fun foo3(): MyClass = this
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.foo1().foo2().foo3()
|
||||
a.foo2()<caret>
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1(): MyClass = this
|
||||
fun foo2(): MyClass = this
|
||||
fun foo3(): MyClass = this
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.run {
|
||||
foo1().foo2().foo3()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1(a: MyClass): MyClass = this
|
||||
fun foo2(): MyClass = this
|
||||
fun foo3(): MyClass = this
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
listOf<MyClass>().forEach {
|
||||
a.foo1(it).foo2().foo3()
|
||||
a.foo2()<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1(a: MyClass): MyClass = this
|
||||
fun foo2(): MyClass = this
|
||||
fun foo3(): MyClass = this
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
listOf<MyClass>().forEach {
|
||||
a.run {
|
||||
foo1(it).foo2().foo3()
|
||||
foo2()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1(a: MyClass): MyClass = this
|
||||
fun foo2(): MyClass = this
|
||||
fun foo3(): MyClass = this
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.foo1(this).foo2().foo3()
|
||||
a.foo2()<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.foo1()<caret>
|
||||
a.foo2()
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.run {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.foo1()
|
||||
a.foo2()<caret>
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.run {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.foo1()
|
||||
a.foo2()
|
||||
a.foo3()<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.run {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4() {
|
||||
val a = MyClass()
|
||||
a.foo1()<caret>
|
||||
a.foo2()
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4() {
|
||||
val a = MyClass()
|
||||
a.run {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4() {
|
||||
<caret>val a = MyClass()
|
||||
a.foo1()
|
||||
a.foo2()
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2(a: MyClass) = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.foo1()
|
||||
a.foo2(this)<caret>
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
this.foo1()<caret>
|
||||
this.foo2()
|
||||
this.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2(a: MyClass) = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.foo1()
|
||||
a.foo3()<caret>
|
||||
a.foo2(this)
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2(a: MyClass) = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.run {
|
||||
foo1()
|
||||
foo3()
|
||||
}
|
||||
a.foo2(this)
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
// top comment
|
||||
a.foo1()<caret>
|
||||
// comment
|
||||
|
||||
// bbb
|
||||
a.foo2()
|
||||
a.foo3()
|
||||
// last comment
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
// top comment
|
||||
a.run {
|
||||
foo1()
|
||||
// comment
|
||||
|
||||
// bbb
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
// last comment
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user