Add inspection + intention to replace .let { it.foo() } with .foo() #KT-13551 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
cdf4309e04
commit
e4c873dc6a
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.intentions.ReplaceSingleLineLetIntention
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
it.length<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.length
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
it.length<caret>
|
||||
it.length
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String = ""
|
||||
foo.let {
|
||||
it.length<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String = ""
|
||||
foo.length
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
text ->
|
||||
"".to("")<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
"".to("")<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
it.to(it)<caret>
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
it.to(it).to("").to("")<caret>
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
it.to("").to(it).to("")<caret>
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
it.to("").to("").to(it)<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
text ->
|
||||
text.to(text)<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
it.to("")<caret>
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.to("")
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
it.to("").to("")<caret>
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.to("").to("")
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.let {
|
||||
text ->
|
||||
text.length<caret>
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.length
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.toString()?.let {
|
||||
it.to("")<caret>
|
||||
}?.let {
|
||||
it.to("")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun foo() {
|
||||
val foo: String? = null
|
||||
foo?.toString()?.to("")?.let {
|
||||
it.to("")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun Int.foo(): Int {
|
||||
return <caret>let { it.hashCode().hashCode() }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun Int.foo(): Int {
|
||||
return hashCode().hashCode()
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun Int.foo(): Int {
|
||||
return <caret>let { it.hashCode() }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: true
|
||||
|
||||
fun Int.foo(): Int {
|
||||
return hashCode()
|
||||
}
|
||||
Reference in New Issue
Block a user