Implement an intention converting several calls with same receiver to with/apply/run #KT-12183 Fixed

This commit is contained in:
shiraji
2017-02-04 09:03:39 +09:00
committed by Mikhail Glukhikh
parent c2e5fc5215
commit 0e5603f644
71 changed files with 1352 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.intentions.ConvertToWithIntention
+16
View File
@@ -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()
}
}
}
+13
View File
@@ -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>
}
}
+13
View File
@@ -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()
}
}
+15
View File
@@ -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()
}
}
}
+13
View File
@@ -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()
}
}
+15
View File
@@ -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()
}
}
}
+13
View File
@@ -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>
}
}
+15
View File
@@ -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()
}
}
}
+14
View File
@@ -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()
}
}
+14
View File
@@ -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
}
}