ReplaceWith: suggest for "invoke" extension

#KT-8597 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-10-29 20:07:02 +09:00
committed by Yan Zhulanow
parent bb7d4c224f
commit be194c3460
13 changed files with 184 additions and 4 deletions
@@ -0,0 +1,14 @@
// "Replace with 'execute(action)'" "true"
class Executor {
@Deprecated("Use Executor.execute(Runnable) instead.", ReplaceWith("execute(action)"))
operator fun invoke(action: () -> Unit) {}
fun execute(action: () -> Unit) {}
}
fun usage(executor: Executor) {
<caret>executor {
// do something
}
}
@@ -0,0 +1,14 @@
// "Replace with 'execute(action)'" "true"
class Executor {
@Deprecated("Use Executor.execute(Runnable) instead.", ReplaceWith("execute(action)"))
operator fun invoke(action: () -> Unit) {}
fun execute(action: () -> Unit) {}
}
fun usage(executor: Executor) {
executor.execute {
// do something
}
}
@@ -0,0 +1,18 @@
// "Replace with 'Foo.execute(action)'" "true"
class Executor {
@Deprecated("Use Executor.execute(Runnable) instead.", ReplaceWith("Foo.execute(action)"))
operator fun invoke(action: () -> Unit) {}
fun execute(action: () -> Unit) {}
}
object Foo {
fun execute(action: () -> Unit) {}
}
fun usage(executor: Executor) {
<caret>executor {
// do something
}
}
@@ -0,0 +1,18 @@
// "Replace with 'Foo.execute(action)'" "true"
class Executor {
@Deprecated("Use Executor.execute(Runnable) instead.", ReplaceWith("Foo.execute(action)"))
operator fun invoke(action: () -> Unit) {}
fun execute(action: () -> Unit) {}
}
object Foo {
fun execute(action: () -> Unit) {}
}
fun usage(executor: Executor) {
Foo.execute {
// do something
}
}
@@ -0,0 +1,14 @@
// "Replace with 'execute(action)'" "true"
class Executor {
@Deprecated("Use Executor.execute(Runnable) instead.", ReplaceWith("execute(action)"))
operator fun invoke(action: () -> Unit) {}
fun execute(action: () -> Unit) {}
fun usage(executor: Executor) {
<caret>invoke {
// do something
}
}
}
@@ -0,0 +1,14 @@
// "Replace with 'execute(action)'" "true"
class Executor {
@Deprecated("Use Executor.execute(Runnable) instead.", ReplaceWith("execute(action)"))
operator fun invoke(action: () -> Unit) {}
fun execute(action: () -> Unit) {}
fun usage(executor: Executor) {
execute {
// do something
}
}
}
@@ -0,0 +1,17 @@
// "Replace with 'execute(action)'" "true"
class Executor {
val self: Executor
get() = this
@Deprecated("Use Executor.execute(Runnable) instead.", ReplaceWith("execute(action)"))
operator fun invoke(action: () -> Unit) {}
fun execute(action: () -> Unit) {}
}
fun usage(executor: Executor) {
executor.<caret>self {
// do something
}
}
@@ -0,0 +1,17 @@
// "Replace with 'execute(action)'" "true"
class Executor {
val self: Executor
get() = this
@Deprecated("Use Executor.execute(Runnable) instead.", ReplaceWith("execute(action)"))
operator fun invoke(action: () -> Unit) {}
fun execute(action: () -> Unit) {}
}
fun usage(executor: Executor) {
executor.self.execute {
// do something
}
}