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.ConvertToApplyIntention
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1(): MyClass = this
|
||||
fun foo2(): MyClass = this
|
||||
fun foo3(): MyClass = this
|
||||
|
||||
fun foo4() {
|
||||
val 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() {
|
||||
val a = MyClass().apply {
|
||||
foo1().foo2().foo3()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
+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() {
|
||||
listOf<MyClass>().forEach {
|
||||
val a = MyClass()
|
||||
a.foo1(it).foo2().foo3()
|
||||
a.foo2()<caret>
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1(a: MyClass): MyClass = this
|
||||
fun foo2(): MyClass = this
|
||||
fun foo3(): MyClass = this
|
||||
|
||||
fun foo4() {
|
||||
listOf<MyClass>().forEach {
|
||||
val a = MyClass().apply {
|
||||
foo1(it).foo2().foo3()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1(a: MyClass): MyClass = this
|
||||
fun foo2(): MyClass = this
|
||||
fun foo3(): MyClass = this
|
||||
|
||||
fun foo4() {
|
||||
val a = MyClass()
|
||||
a.foo1(this).foo2().foo3()
|
||||
a.foo2()<caret>
|
||||
a.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,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4() {
|
||||
val a = MyClass().apply {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
val 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) {
|
||||
val a = MyClass().apply {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
val 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) {
|
||||
val a = MyClass().apply {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
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,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4() {
|
||||
val a = MyClass().apply {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2(a: MyClass) = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
val a = MyClass()
|
||||
a.foo1()
|
||||
a.foo2(this)<caret>
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2(a: MyClass) = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
val a = MyClass()
|
||||
a.foo1()
|
||||
a.foo2(this)
|
||||
a.foo3()<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2(a: MyClass) = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
val 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) {
|
||||
val a = MyClass().apply {
|
||||
foo1()
|
||||
foo3()
|
||||
}
|
||||
a.foo2(this)
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4() {
|
||||
var 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() {
|
||||
var a = MyClass().apply {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
// top comment
|
||||
val a = MyClass()
|
||||
// here is comment
|
||||
a.foo1()<caret>
|
||||
// comment
|
||||
|
||||
// bbb
|
||||
a.foo2()
|
||||
a.foo3()
|
||||
// last comment won't be in
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
// top comment
|
||||
val a = MyClass().apply {
|
||||
// here is comment
|
||||
foo1()
|
||||
// comment
|
||||
|
||||
// bbb
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
// last comment won't be in
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user