Augmented list assignment inspection: add "replace with ordinary" fix

Relates to KT-20626
This commit is contained in:
Mikhail Glukhikh
2018-12-04 13:18:21 +03:00
parent ed8305995e
commit aa9e48b9b6
26 changed files with 80 additions and 35 deletions
@@ -1,4 +1,4 @@
// "Replace with assignment" "false"
// "Replace with assignment (original is empty)" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Change type to mutable
// ACTION: Replace overloaded operator with function call
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherList: List<Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherList: List<Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherList: List<Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherList: List<Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherMap: Map<Int, Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherMap: Map<Int, Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherMap: Map<Int, Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherMap: Map<Int, Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherList: Set<Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherList: Set<Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherList: Set<Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "true"
// "Replace with assignment (original is empty)" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// WITH_RUNTIME
fun test(otherList: Set<Int>) {
@@ -1,4 +1,4 @@
// "Replace with assignment" "false"
// "Replace with assignment (original is empty)" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Change type to mutable
// ACTION: Replace overloaded operator with function call
@@ -1,4 +1,4 @@
// "Replace with assignment" "false"
// "Replace with assignment (original is empty)" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Change type to mutable
// ACTION: Replace overloaded operator with function call
@@ -1,4 +1,4 @@
// "Replace with assignment" "false"
// "Replace with assignment (original is empty)" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Change type to mutable
// ACTION: Replace overloaded operator with function call
@@ -1,4 +1,4 @@
// "Replace with assignment" "false"
// "Replace with assignment (original is empty)" "false"
// ACTION: Replace overloaded operator with function call
// ACTION: Replace with ordinary assignment
// WITH_RUNTIME
@@ -1,4 +1,4 @@
// "Replace with assignment" "false"
// "Replace with assignment (original is empty)" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Change type to mutable
// ACTION: Replace overloaded operator with function call
@@ -1,4 +1,4 @@
// "Replace with assignment" "false"
// "Replace with assignment (original is empty)" "false"
// ACTION: Replace overloaded operator with function call
// ACTION: Replace with ordinary assignment
// WITH_RUNTIME
@@ -1,4 +1,4 @@
// "Replace with assignment" "false"
// "Replace with assignment (original is empty)" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Change type to mutable
// ACTION: Replace overloaded operator with function call
@@ -1,4 +1,4 @@
// "Replace with assignment" "false"
// "Replace with assignment (original is empty)" "false"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Change type to mutable
// ACTION: Replace overloaded operator with function call
@@ -0,0 +1,10 @@
// "Replace with ordinary assignment" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Replace overloaded operator with function call
// WITH_RUNTIME
fun test(otherList: List<Int>, flag: Boolean) {
var list = otherList
if (flag) {
list <caret>+= 4
}
}
@@ -0,0 +1,10 @@
// "Replace with ordinary assignment" "true"
// TOOL: org.jetbrains.kotlin.idea.inspections.SuspiciousCollectionReassignmentInspection
// ACTION: Replace overloaded operator with function call
// WITH_RUNTIME
fun test(otherList: List<Int>, flag: Boolean) {
var list = otherList
if (flag) {
list = list + 4
}
}