Fix #KT-26353 'Make variable immutable' is a bad name for a quickfix that changes 'var' to 'val'

This commit is contained in:
kenji tomita
2018-08-28 13:49:38 +09:00
committed by Mikhail Glukhikh
parent e85dcfc3e3
commit e5841441c9
32 changed files with 32 additions and 32 deletions
@@ -36,7 +36,7 @@ class ChangeVariableMutabilityFix(
private val actionText: String? = null
) : 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
+1 -1
View File
@@ -1,5 +1,5 @@
// "class org.jetbrains.kotlin.idea.quickfix.LiftAssignmentOutOfTryFix" "false"
// ACTION: Make variable mutable
// ACTION: Change to var
// ERROR: Val cannot be reassigned
// WITH_RUNTIME
+1 -1
View File
@@ -1,5 +1,5 @@
// "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
+1 -1
View File
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
class A() {
<caret>lateinit val foo: String
+1 -1
View File
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
class A() {
<caret>lateinit var foo: String
@@ -1,4 +1,4 @@
// "Make variable immutable" "true"
// "Change to val" "true"
object Test {
<caret>const var foo = "123"
}
@@ -1,4 +1,4 @@
// "Make variable immutable" "true"
// "Change to val" "true"
object Test {
<caret>const val foo = "123"
}
@@ -1,4 +1,4 @@
// "Make variable immutable" "true"
// "Change to val" "true"
fun foo(p: Int) {
<caret>var (v1, v2) = getPair()!!
v1
@@ -1,4 +1,4 @@
// "Make variable immutable" "true"
// "Change to val" "true"
fun foo(p: Int) {
<caret>val (v1, v2) = getPair()!!
v1
@@ -1,4 +1,4 @@
// "Make variable immutable" "true"
// "Change to val" "true"
fun foo(p: Int) {
<caret>var v: Int
if (p > 0) v = 1 else v = 2
@@ -1,4 +1,4 @@
// "Make variable immutable" "true"
// "Change to val" "true"
fun foo(p: Int) {
<caret>val v: Int
if (p > 0) v = 1 else v = 2
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
class Test {
val a: String
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
class Test {
var a: String
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
fun exec(f: () -> Unit) = f()
fun foo() {
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
fun exec(f: () -> Unit) = f()
fun foo() {
@@ -1,4 +1,4 @@
// "Make variable mutable" "false"
// "Change to var" "false"
// ACTION: Remove redundant assignment
// ERROR: Val cannot be reassigned
fun fun1(i: Int) {
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
val String.prop: Int
get() {
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
val String.prop: Int
get() {
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
open class A {
open var x = 42;
}
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
open class A {
open var x = 42;
}
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
open class A {
open var x = 42;
}
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
open class A {
open var x = 42;
}
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
fun foo() {
val a = 1
<caret>a = 3
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
fun foo() {
var a = 1
<caret>a = 3
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
val a = 4
fun bar() {
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
var a = 4
fun bar() {
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
class A() {
val a = 1
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
class A() {
var a = 1
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
class A(val a: Int) {
fun foo() {
<caret>a = 5
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
class A(var a: Int) {
fun foo() {
a = 5
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
class A() {
val a: Int = 0
<caret>set(v: Int) {}
@@ -1,4 +1,4 @@
// "Make variable mutable" "true"
// "Change to var" "true"
class A() {
var a: Int = 0
set(v: Int) {}