Intention to replace add/addAll on a mutable collection with += (#1143)

This commit is contained in:
nd
2017-07-07 16:34:20 +02:00
committed by Dmitry Jemerov
parent fae8efdc7f
commit 58e5c497d0
16 changed files with 188 additions and 0 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.intentions.ReplaceAddWithPlusAssignIntention
@@ -0,0 +1,6 @@
// WITH_RUNTIME
// INTENTION_TEXT: Replace 'add()' with '+='
fun foo() {
val a = arrayListOf<Int>(1, 2, 3)
a.<caret>add(4)
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
// INTENTION_TEXT: Replace 'add()' with '+='
fun foo() {
val a = arrayListOf<Int>(1, 2, 3)
a += 4
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
// INTENTION_TEXT: Replace 'addAll()' with '+='
fun foo() {
val a = arrayListOf<Int>(1, 2, 3)
a.<caret>addAll(arrayOf(4, 5, 6))
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
// INTENTION_TEXT: Replace 'addAll()' with '+='
fun foo() {
val a = arrayListOf<Int>(1, 2, 3)
a += arrayOf(4, 5, 6)
}
@@ -0,0 +1,7 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
fun foo() {
val a = arrayListOf<Int>(1, 2, 3)
a.<caret>addAll(1, arrayListOf(4))
}
@@ -0,0 +1,7 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
fun foo() {
var a = arrayListOf<Int>(1, 2, 3)
a.<caret>addAll(arrayListOf(4))
}
@@ -0,0 +1,7 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
fun foo() {
val a = arrayListOf<Int>(1, 2, 3)
a.<caret>add(1, 4)
}
@@ -0,0 +1,7 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
fun foo() {
var a = arrayListOf<Int>(1, 2, 3)
a.<caret>add(4)
}
@@ -0,0 +1,10 @@
// IS_APPLICABLE: false
class A {
fun add(x: Int) {
}
}
fun foo() {
A().<caret>add(1)
}