Merge pull request #2033 from t-kameyama/KT-28699
KT-28699 Add "Convert to also" intention
This commit is contained in:
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ConvertToAlsoIntention
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2(a: MyClass) = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(it: MyClass) {
|
||||
val a = MyClass()
|
||||
a.foo1()
|
||||
a.foo2(it)<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(it: MyClass) {
|
||||
val a = MyClass()
|
||||
a.foo1()
|
||||
a.foo2(it)
|
||||
a.foo3()<caret>
|
||||
}
|
||||
}
|
||||
@@ -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().also {
|
||||
it.foo1().foo2().foo3()
|
||||
it.foo2()
|
||||
it.foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
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,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1(a: MyClass): MyClass = this
|
||||
fun foo2(): MyClass = this
|
||||
fun foo3(): MyClass = this
|
||||
|
||||
fun foo4() {
|
||||
val a = MyClass().also {
|
||||
it.foo1(this).foo2().foo3()
|
||||
it.foo2()
|
||||
it.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().also {
|
||||
it.foo1()
|
||||
it.foo2()
|
||||
it.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().also {
|
||||
it.foo1()
|
||||
it.foo2()
|
||||
it.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().also {
|
||||
it.foo1()
|
||||
it.foo2()
|
||||
it.foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2(a: MyClass) = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(it: MyClass) {
|
||||
val a = MyClass()
|
||||
a.foo1()
|
||||
a.foo3()<caret>
|
||||
a.foo2(it)
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
class MyClass {
|
||||
fun foo1() = Unit
|
||||
fun foo2(a: MyClass) = Unit
|
||||
fun foo3() = Unit
|
||||
|
||||
fun foo4(it: MyClass) {
|
||||
val a = MyClass().also {
|
||||
it.foo1()
|
||||
it.foo3()
|
||||
}
|
||||
a.foo2(it)
|
||||
a.foo3()
|
||||
}
|
||||
}
|
||||
+14
@@ -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().also {
|
||||
it.foo1()
|
||||
it.foo2()
|
||||
it.foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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().also {
|
||||
// here is comment
|
||||
it.foo1()
|
||||
// comment
|
||||
|
||||
// bbb
|
||||
it.foo2()
|
||||
it.foo3()
|
||||
}
|
||||
// last comment won't be in
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1(a: MyClass): MyClass = this
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-7
@@ -1,16 +1,13 @@
|
||||
// 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()
|
||||
}
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1(a: MyClass): MyClass = this
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-7
@@ -1,16 +1,13 @@
|
||||
// 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()
|
||||
}
|
||||
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) {
|
||||
with(it) {
|
||||
foo1()
|
||||
foo2()
|
||||
foo3()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
class MyClass {
|
||||
fun foo1(a: MyClass): MyClass = this
|
||||
|
||||
@@ -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 {
|
||||
with(a) {
|
||||
foo1(it).foo2().foo3()
|
||||
foo2()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user