Quick Fixes: Implement 'Initialize with constructor parameter' quick-fix

#KT-6604 Fixed
This commit is contained in:
Alexey Sedunov
2015-11-12 17:19:05 +03:00
parent 138370ce5b
commit ac8532ffce
26 changed files with 428 additions and 11 deletions
@@ -0,0 +1,4 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$InitializeWithConstructorParameter" "false"
fun test() {
<caret>val n: Int
}
@@ -0,0 +1,11 @@
// "Initialize with constructor parameter" "true"
open class A(n: Int) {
<caret>var n: Int
get() = 1
}
class B : A(0)
fun test() {
val a = A(0)
}
@@ -0,0 +1,11 @@
// "Initialize with constructor parameter" "true"
open class A(n: Int, n1: Int) {
var n: Int = n1
get() = 1
}
class B : A(0, 0)
fun test() {
val a = A(0, 0)
}
@@ -0,0 +1,12 @@
// "Initialize with constructor parameter" "true"
open class A {
<caret>val n: Int
constructor(n: Int)
}
class B : A(1)
fun test() {
val a = A(1)
}
@@ -0,0 +1,14 @@
// "Initialize with constructor parameter" "true"
open class A {
val n: Int
constructor(n: Int, n1: Int) {
this.n = n1
}
}
class B : A(1, 0)
fun test() {
val a = A(1, 0)
}
@@ -0,0 +1,11 @@
// "Initialize with constructor parameter" "true"
open class A {
<caret>var n: Int
get() = 1
}
class B : A()
fun test() {
val a = A()
}
@@ -0,0 +1,11 @@
// "Initialize with constructor parameter" "true"
open class A(n: Int) {
var n: Int = n
get() = 1
}
class B : A(0)
fun test() {
val a = A(0)
}
@@ -0,0 +1,14 @@
// "Initialize with constructor parameter" "true"
open class A(s: String) {
<caret>var n: Int
get() = 1
constructor(): this("")
constructor(a: Int): this("" + a)
}
class B : A("")
fun test() {
val a = A("")
}
@@ -0,0 +1,14 @@
// "Initialize with constructor parameter" "true"
open class A(s: String, n: Int) {
var n: Int = n
get() = 1
constructor(): this("", 0)
constructor(a: Int): this("" + a, 0)
}
class B : A("", 0)
fun test() {
val a = A("", 0)
}
@@ -0,0 +1,11 @@
// "Initialize with constructor parameter" "true"
open class A(s: String) {
<caret>var n: Int
get() = 1
}
class B : A("")
fun test() {
val a = A("")
}
@@ -0,0 +1,11 @@
// "Initialize with constructor parameter" "true"
open class A(s: String, n: Int) {
var n: Int = n
get() = 1
}
class B : A("", 0)
fun test() {
val a = A("", 0)
}
@@ -0,0 +1,19 @@
// "Initialize with constructor parameter" "true"
open class A {
<caret>val n: Int
constructor(s: String)
constructor(a: Int) {
val t = 1
}
}
class B : A("")
class C : A(1)
fun test() {
val a = A("")
val aa = A(1)
}
@@ -0,0 +1,22 @@
// "Initialize with constructor parameter" "true"
open class A {
val n: Int
constructor(s: String, n: Int) {
this.n = n
}
constructor(a: Int, n: Int) {
val t = 1
this.n = n
}
}
class B : A("", 0)
class C : A(1, 0)
fun test() {
val a = A("", 0)
val aa = A(1, 0)
}
@@ -0,0 +1,7 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$InitializeWithConstructorParameter" "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$InitializeWithConstructorParameter" "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,11 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$InitializeWithConstructorParameter" "false"
// ERROR: Property must be initialized or be abstract
open class A {
<caret>val n: Int
}
class B : A()
fun test() {
val a = A()
}
@@ -0,0 +1,14 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$InitializeWithConstructorParameter" "false"
// ERROR: Property must be initialized or be abstract
open class A(s: String) {
<caret>val n: Int
constructor(): this("")
constructor(a: Int): this("" + a)
}
class B : A("")
fun test() {
val a = A("")
}
@@ -0,0 +1,11 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$InitializeWithConstructorParameter" "false"
// ERROR: Property must be initialized or be abstract
open class A(s: String) {
<caret>val n: Int
}
class B : A("")
fun test() {
val a = A("")
}
@@ -0,0 +1,7 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$InitializeWithConstructorParameter" "false"
// ACTION: Make internal
// ACTION: Make private
// ACTION: Make protected
class A {
<caret>val n: Int by lazy { 0 }
}
@@ -0,0 +1,6 @@
// "class org.jetbrains.kotlin.idea.quickfix.InitializePropertyQuickFixFactory$InitializeWithConstructorParameter" "false"
// ACTION: Initialize property 'n'
// ACTION: Make internal
// ACTION: Make private
// ERROR: Property must be initialized
<caret>val n: Int