Quick Fixes: Implement 'Move to constructor parameters' quick-fix

#KT-6604 In Progress
This commit is contained in:
Alexey Sedunov
2015-11-12 16:25:15 +03:00
parent f66af7bdd4
commit 138370ce5b
19 changed files with 319 additions and 9 deletions
@@ -0,0 +1,4 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$MoveToConstructorParameters" "false"
fun test() {
<caret>val n: Int
}
@@ -0,0 +1,9 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$MoveToConstructorParameters" "false"
// ACTION: Make 'n' abstract
// ACTION: Make internal
// ACTION: Make private
// ACTION: Make protected
// ERROR: Property must be initialized or be abstract
class A {
<caret>val Int.n: Int
}
@@ -0,0 +1,9 @@
// "Move to constructor parameters" "true"
// SHOULD_FAIL_WITH: Duplicating parameter 'n'
open class A(n: Int) {
<caret>val n: Int
}
fun test() {
val a = A(0)
}
@@ -0,0 +1,10 @@
// "Move to constructor parameters" "true"
open class A {
<caret>val n: Int
}
class B : A()
fun test() {
val a = A()
}
@@ -0,0 +1,9 @@
// "Move to constructor parameters" "true"
open class A(val n: Int) {
}
class B : A(0)
fun test() {
val a = A(0)
}
@@ -0,0 +1,14 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$MoveToConstructorParameters" "false"
// ACTION: Initialize property 'n'
// ACTION: Make 'n' abstract
// ACTION: Make internal
// ACTION: Make private
// ACTION: Make protected
// ERROR: Property must be initialized or be abstract
open class A(x: Int)
class B : A {
<caret>val n: Int
constructor(): super(1)
}
@@ -0,0 +1,14 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$MoveToConstructorParameters" "false"
// ACTION: Initialize property 'n'
// ACTION: Make 'n' abstract
// ACTION: Make internal
// ACTION: Make private
// ACTION: Make protected
// ERROR: Property must be initialized or be abstract
open class A
class B {
<caret>val n: Int
constructor()
}
@@ -0,0 +1,12 @@
// "Move to constructor parameters" "true"
open class A(s: String) {
<caret>val n: Int
constructor(a: Int): this("")
}
class B : A("")
fun test() {
val a = A("")
}
@@ -0,0 +1,11 @@
// "Move to constructor parameters" "true"
open class A(s: String, val n: Int) {
constructor(a: Int): this("", 0)
}
class B : A("", 0)
fun test() {
val a = A("", 0)
}
@@ -0,0 +1,7 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$MoveToConstructorParameters" "false"
// ACTION: Make internal
// ACTION: Make private
// ACTION: Make protected
interface A {
<caret>val n: Int
}
@@ -0,0 +1,9 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$MoveToConstructorParameters" "false"
// ACTION: Initialize property 'n'
// ACTION: Make 'n' abstract
// ACTION: Make internal
// ACTION: Make private
// ERROR: Property must be initialized or be abstract
object A {
<caret>val n: Int
}
@@ -0,0 +1,7 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$MoveToConstructorParameters" "false"
// ACTION: Make internal
// ACTION: Make private
// ACTION: Make protected
class A {
<caret>val n: Int by lazy { 0 }
}
@@ -0,0 +1,12 @@
// "Move to constructor parameters" "true"
annotation class foo
open class A(s: String) {
<caret>private @foo val /*1*/ n: /* 2 */ Int
}
class B : A("")
fun test() {
val a = A("")
}
@@ -0,0 +1,11 @@
// "Move to constructor parameters" "true"
annotation class foo
open class A(s: String, private @foo val /*1*/ n: /* 2 */ Int) {
}
class B : A("", 0)
fun test() {
val a = A("", 0)
}
@@ -0,0 +1,6 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$MoveToConstructorParameters" "false"
// ACTION: Initialize property 'n'
// ACTION: Make internal
// ACTION: Make private
// ERROR: Property must be initialized
<caret>val n: Int