Fix #KT-26353 'Make variable immutable' is a bad name for a quickfix that changes 'var' to 'val'
This commit is contained in:
committed by
Mikhail Glukhikh
parent
e85dcfc3e3
commit
e5841441c9
@@ -36,7 +36,7 @@ class ChangeVariableMutabilityFix(
|
|||||||
private val actionText: String? = null
|
private val actionText: String? = null
|
||||||
) : KotlinQuickFixAction<KtValVarKeywordOwner>(element) {
|
) : KotlinQuickFixAction<KtValVarKeywordOwner>(element) {
|
||||||
|
|
||||||
override fun getText() = actionText ?: if (makeVar) "Make variable mutable" else "Make variable immutable"
|
override fun getText() = actionText ?: if (makeVar) "Change to var" else "Change to val"
|
||||||
|
|
||||||
override fun getFamilyName(): String = text
|
override fun getFamilyName(): String = text
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// "class org.jetbrains.kotlin.idea.quickfix.LiftAssignmentOutOfTryFix" "false"
|
// "class org.jetbrains.kotlin.idea.quickfix.LiftAssignmentOutOfTryFix" "false"
|
||||||
// ACTION: Make variable mutable
|
// ACTION: Change to var
|
||||||
// ERROR: Val cannot be reassigned
|
// ERROR: Val cannot be reassigned
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// "class org.jetbrains.kotlin.idea.quickfix.LiftAssignmentOutOfTryFix" "false"
|
// "class org.jetbrains.kotlin.idea.quickfix.LiftAssignmentOutOfTryFix" "false"
|
||||||
// ACTION: Make variable mutable
|
// ACTION: Change to var
|
||||||
// ERROR: Val cannot be reassigned
|
// ERROR: Val cannot be reassigned
|
||||||
// ERROR: Val cannot be reassigned
|
// ERROR: Val cannot be reassigned
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
|
|
||||||
class A() {
|
class A() {
|
||||||
<caret>lateinit val foo: String
|
<caret>lateinit val foo: String
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
|
|
||||||
class A() {
|
class A() {
|
||||||
<caret>lateinit var foo: String
|
<caret>lateinit var foo: String
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable immutable" "true"
|
// "Change to val" "true"
|
||||||
object Test {
|
object Test {
|
||||||
<caret>const var foo = "123"
|
<caret>const var foo = "123"
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable immutable" "true"
|
// "Change to val" "true"
|
||||||
object Test {
|
object Test {
|
||||||
<caret>const val foo = "123"
|
<caret>const val foo = "123"
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable immutable" "true"
|
// "Change to val" "true"
|
||||||
fun foo(p: Int) {
|
fun foo(p: Int) {
|
||||||
<caret>var (v1, v2) = getPair()!!
|
<caret>var (v1, v2) = getPair()!!
|
||||||
v1
|
v1
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable immutable" "true"
|
// "Change to val" "true"
|
||||||
fun foo(p: Int) {
|
fun foo(p: Int) {
|
||||||
<caret>val (v1, v2) = getPair()!!
|
<caret>val (v1, v2) = getPair()!!
|
||||||
v1
|
v1
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable immutable" "true"
|
// "Change to val" "true"
|
||||||
fun foo(p: Int) {
|
fun foo(p: Int) {
|
||||||
<caret>var v: Int
|
<caret>var v: Int
|
||||||
if (p > 0) v = 1 else v = 2
|
if (p > 0) v = 1 else v = 2
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable immutable" "true"
|
// "Change to val" "true"
|
||||||
fun foo(p: Int) {
|
fun foo(p: Int) {
|
||||||
<caret>val v: Int
|
<caret>val v: Int
|
||||||
if (p > 0) v = 1 else v = 2
|
if (p > 0) v = 1 else v = 2
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
val a: String
|
val a: String
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
var a: String
|
var a: String
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
fun exec(f: () -> Unit) = f()
|
fun exec(f: () -> Unit) = f()
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
fun exec(f: () -> Unit) = f()
|
fun exec(f: () -> Unit) = f()
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "false"
|
// "Change to var" "false"
|
||||||
// ACTION: Remove redundant assignment
|
// ACTION: Remove redundant assignment
|
||||||
// ERROR: Val cannot be reassigned
|
// ERROR: Val cannot be reassigned
|
||||||
fun fun1(i: Int) {
|
fun fun1(i: Int) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
|
|
||||||
val String.prop: Int
|
val String.prop: Int
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
|
|
||||||
val String.prop: Int
|
val String.prop: Int
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
open class A {
|
open class A {
|
||||||
open var x = 42;
|
open var x = 42;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
open class A {
|
open class A {
|
||||||
open var x = 42;
|
open var x = 42;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
open class A {
|
open class A {
|
||||||
open var x = 42;
|
open var x = 42;
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
open class A {
|
open class A {
|
||||||
open var x = 42;
|
open var x = 42;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val a = 1
|
val a = 1
|
||||||
<caret>a = 3
|
<caret>a = 3
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
fun foo() {
|
fun foo() {
|
||||||
var a = 1
|
var a = 1
|
||||||
<caret>a = 3
|
<caret>a = 3
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
val a = 4
|
val a = 4
|
||||||
|
|
||||||
fun bar() {
|
fun bar() {
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
var a = 4
|
var a = 4
|
||||||
|
|
||||||
fun bar() {
|
fun bar() {
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
class A() {
|
class A() {
|
||||||
val a = 1
|
val a = 1
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
class A() {
|
class A() {
|
||||||
var a = 1
|
var a = 1
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
class A(val a: Int) {
|
class A(val a: Int) {
|
||||||
fun foo() {
|
fun foo() {
|
||||||
<caret>a = 5
|
<caret>a = 5
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
class A(var a: Int) {
|
class A(var a: Int) {
|
||||||
fun foo() {
|
fun foo() {
|
||||||
a = 5
|
a = 5
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
class A() {
|
class A() {
|
||||||
val a: Int = 0
|
val a: Int = 0
|
||||||
<caret>set(v: Int) {}
|
<caret>set(v: Int) {}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Make variable mutable" "true"
|
// "Change to var" "true"
|
||||||
class A() {
|
class A() {
|
||||||
var a: Int = 0
|
var a: Int = 0
|
||||||
set(v: Int) {}
|
set(v: Int) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user