Implement an intention converting several calls with same receiver to with/apply/run #KT-12183 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
c2e5fc5215
commit
0e5603f644
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ConvertToWithIntention
|
||||
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
a.let {
|
||||
it.foo1()<caret>
|
||||
it.foo2()
|
||||
it.foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
with(a) {
|
||||
foo1().foo2().foo3()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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(a: MyClass) {
|
||||
listOf<MyClass>().forEach {
|
||||
a.foo1(it).foo2().foo3()
|
||||
a.foo2()<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
with(a) {
|
||||
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) {
|
||||
with(a) {
|
||||
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) {
|
||||
with(a) {
|
||||
foo1()
|
||||
foo2()
|
||||
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()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2(a: MyClass) = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
with(a) {
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2() = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(a: MyClass) {
|
||||
// top comment
|
||||
with(a) {
|
||||
foo1()
|
||||
// comment
|
||||
|
||||
// bbb
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
// last comment
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user