Code Insight: "Generate secondary constructor" action

#KT-6970 Fixed
This commit is contained in:
Alexey Sedunov
2015-10-09 17:54:14 +03:00
parent 78829b9e8f
commit 30d697109c
37 changed files with 1025 additions and 246 deletions
@@ -0,0 +1,20 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
// WITH_RUNTIME
class Foo {<caret>
val x = 1
val y: Int
val z: Int get() = 3
val u: Int by lazy { 4 }
init {
y = 2
}
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,22 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
// WITH_RUNTIME
class Foo {
val x = 1
val y: Int
val z: Int get() = 3
val u: Int by lazy { 4 }
<caret>constructor()
init {
y = 2
}
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,24 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
// WITH_RUNTIME
class Foo {<caret>
constructor() {
}
val x = 1
val y: Int
val z: Int get() = 3
val u: Int by lazy { 4 }
init {
y = 2
}
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1 @@
Constructor already exists
@@ -0,0 +1,9 @@
public class Base<X, Y> {
public Base(X x) {
}
public Base(X x, Y y) {
}
}
@@ -0,0 +1,12 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
class Foo<U> : Base<U, Int> {<caret>
val x = 1
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,16 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
class Foo<U> : Base<U, Int> {
val x = 1
<caret>constructor(x: U) : super(x)
constructor(x: U, y: Int?) : super(x, y)
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,16 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
class Foo {<caret>
val n: Int
val x = 1
val m: Int
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,21 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
class Foo {
val n: Int
val x = 1
val m: Int
<caret>constructor(n: Int, m: Int) {
this.n = n
this.m = m
}
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,18 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base(n: Int) {
constructor(a: Int, b: Int): this(a + b)
}
class Foo : Base {<caret>
val n: Int
val x = 1
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,26 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base(n: Int) {
constructor(a: Int, b: Int): this(a + b)
}
class Foo : Base {
val n: Int
val x = 1
<caret>constructor(a: Int, b: Int, n: Int) : super(a, b) {
this.n = n
}
constructor(n: Int, n1: Int) : super(n) {
this.n = n1
}
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,16 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base(n: Int) {
constructor(a: Int, b: Int): this(a + b)
}
class Foo : Base {<caret>
val x = 1
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,20 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base(n: Int) {
constructor(a: Int, b: Int): this(a + b)
}
class Foo : Base {
val x = 1
<caret>constructor(a: Int, b: Int) : super(a, b)
constructor(n: Int) : super(n)
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,20 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base(n: Int) {
constructor(a: Int, b: Int): this(a + b)
}
class Foo : Base {<caret>
val x = 1
constructor(t: Int, u: Int) : super(u, t)
constructor(x: Int) : super(x)
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1 @@
Constructor already exists
@@ -0,0 +1,16 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base(n: Int) {
constructor(a: Int, b: Int): this(a + b)
}
class Foo(x: Int) : Base(x) {<caret>
val x = 1
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,18 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base(n: Int) {
constructor(a: Int, b: Int): this(a + b)
}
class Foo(x: Int) : Base(x) {
val x = 1
<caret>constructor(a: Int, b: Int) : super(a, b)
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,18 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base(n: Int) {
constructor(a: Int, b: Int): this(a + b)
}
class Foo : Base {<caret>
val x = 1
constructor(x: Int) : super(x)
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,20 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base(n: Int) {
constructor(a: Int, b: Int): this(a + b)
}
class Foo : Base {
val x = 1
constructor(x: Int) : super(x)
<caret>constructor(a: Int, b: Int) : super(a, b)
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,16 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base<X, Y>(n: X) {
constructor(x: X, y: Y): this(x)
}
class Foo<U> : Base<U, Int> {<caret>
val x = 1
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,20 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base<X, Y>(n: X) {
constructor(x: X, y: Y): this(x)
}
class Foo<U> : Base<U, Int> {
val x = 1
<caret>constructor(x: U, y: Int) : super(x, y)
constructor(n: U) : super(n)
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,16 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base {
constructor(a: Int, vararg b: Int)
}
class Foo : Base {<caret>
val x = 1
fun foo() {
}
fun bar() {
}
}
@@ -0,0 +1,18 @@
// ACTION_CLASS: org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateSecondaryConstructorAction
open class Base {
constructor(a: Int, vararg b: Int)
}
class Foo : Base {
val x = 1
<caret>constructor(a: Int, vararg b: Int) : super(a, *b)
fun foo() {
}
fun bar() {
}
}