Create from Usage: Generate secondary constructors by call expressions

This commit is contained in:
Alexey Sedunov
2015-03-25 13:16:56 +03:00
parent 15dddf362e
commit 9c0bcee9a3
20 changed files with 210 additions and 13 deletions
@@ -2,6 +2,7 @@
// ACTION: Create function 'Foo'
// ACTION: Add parameter to constructor 'Foo'
// ACTION: Split property declaration
// ACTION: Create secondary constructor
// ERROR: Too many arguments for public constructor Foo(a: kotlin.Int) defined in Foo
class Foo(a: Int)
@@ -2,6 +2,7 @@
// ACTION: Create function 'Foo'
// ACTION: Remove parameter 's'
// ACTION: Split property declaration
// ACTION: Create secondary constructor
// ERROR: No value passed for parameter s
class Foo(i: Int, s: String)
@@ -0,0 +1,13 @@
// "Create secondary constructor" "true"
trait T
class A: T {
constructor(i: Int) {
//To change body of created constructors use File | Settings | File Templates.
}
}
fun test() {
val t: T = A(1)
}
@@ -0,0 +1,12 @@
// "Create secondary constructor" "true"
class A {
constructor(i: Int) {
//To change body of created constructors use File | Settings | File Templates.
}
}
fun test() {
val a = A(1)
}
@@ -0,0 +1,11 @@
// "Create secondary constructor" "true"
class A {
constructor(i: Int) {
//To change body of created constructors use File | Settings | File Templates.
}
}
fun test() {
val a = A(1)
}
@@ -0,0 +1,9 @@
// "Create secondary constructor" "true"
trait T
class A: T
fun test() {
val t: T = A(<caret>1)
}
@@ -0,0 +1,12 @@
// "Create secondary constructor" "false"
// ACTION: Add parameter to constructor 'A'
// ACTION: Create function 'A'
// ACTION: Split property declaration
// ERROR: No type arguments expected
// ERROR: Too many arguments for public constructor A() defined in A
class A
fun test() {
val a = A<Int>(<caret>1)
}
@@ -0,0 +1,9 @@
// "Create secondary constructor" "true"
class A {
}
fun test() {
val a = A(<caret>1)
}
@@ -0,0 +1,7 @@
// "Create secondary constructor" "true"
class A
fun test() {
val a = A(<caret>1)
}
@@ -0,0 +1,15 @@
// "Create secondary constructor" "false"
// ACTION: Add parameter to constructor 'A'
// ACTION: Change 'b' type to 'A'
// ACTION: Create function 'A'
// ACTION: Split property declaration
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>B</td></tr><tr><td>Found:</td><td>A</td></tr></table></html>
// ERROR: Too many arguments for public constructor A() defined in A
class A
class B
fun test() {
val b: B = A(<caret>1)
}
@@ -0,0 +1,7 @@
// "Create secondary constructor" "false"
// ERROR: Too many arguments for public constructor G() defined in G
// ACTION: Add parameter to constructor 'G'
// ACTION: Convert to block body
// ACTION: Create function 'G'
fun test() = G(<caret>1)
@@ -0,0 +1,6 @@
class J {
public J(int i) {
}
}
@@ -0,0 +1,4 @@
// "Create secondary constructor" "true"
// ERROR: Too many arguments for public/*package*/ constructor J() defined in J
fun test() = J(1)
@@ -0,0 +1,4 @@
// "Create secondary constructor" "true"
// ERROR: Too many arguments for public/*package*/ constructor J() defined in J
fun test() = J(<caret>1)