Add inspection + intention to replace .let { it.foo() } with .foo() #KT-13551 Fixed

This commit is contained in:
shiraji
2016-09-05 23:59:41 +03:00
committed by Mikhail Glukhikh
parent cdf4309e04
commit e4c873dc6a
32 changed files with 452 additions and 0 deletions
@@ -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
}
@@ -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>
}
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
fun foo() {
val foo: String? = null
foo?.let {
it.to(it).to("").to("")<caret>
}
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
fun foo() {
val foo: String? = null
foo?.let {
it.to("").to(it).to("")<caret>
}
}
@@ -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>
}
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// IS_APPLICABLE: true
fun foo() {
val foo: String? = null
foo?.to("")
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// IS_APPLICABLE: true
fun foo() {
val foo: String? = null
foo?.let {
it.to("").to("")<caret>
}
}
@@ -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>
}
}
@@ -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()
}