J2K: use of new syntax for class intialization blocks
This commit is contained in:
Generated
+2
@@ -3,7 +3,9 @@
|
|||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||||
<excludeFromCompile>
|
<excludeFromCompile>
|
||||||
|
<directory url="file://$PROJECT_DIR$/core/reflection" includeSubdirectories="true" />
|
||||||
<directory url="file://$PROJECT_DIR$/core/reflection.jvm" includeSubdirectories="true" />
|
<directory url="file://$PROJECT_DIR$/core/reflection.jvm" includeSubdirectories="true" />
|
||||||
|
<directory url="file://$PROJECT_DIR$/core/reflection.stub.jvm" includeSubdirectories="true" />
|
||||||
</excludeFromCompile>
|
</excludeFromCompile>
|
||||||
<resourceExtensions />
|
<resourceExtensions />
|
||||||
<wildcardResourcePatterns>
|
<wildcardResourcePatterns>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.j2k.*
|
|||||||
|
|
||||||
class Initializer(val body: DeferredElement<Block>, modifiers: Modifiers) : Member(Annotations.Empty, modifiers) {
|
class Initializer(val body: DeferredElement<Block>, modifiers: Modifiers) : Member(Annotations.Empty, modifiers) {
|
||||||
override fun generateCode(builder: CodeBuilder) {
|
override fun generateCode(builder: CodeBuilder) {
|
||||||
builder.append(body)
|
builder append "init" append body
|
||||||
}
|
}
|
||||||
|
|
||||||
override val isEmpty: Boolean
|
override val isEmpty: Boolean
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ package test
|
|||||||
public class Test(str: String) {
|
public class Test(str: String) {
|
||||||
var myStr = "String2"
|
var myStr = "String2"
|
||||||
|
|
||||||
{
|
init {
|
||||||
myStr = str
|
myStr = str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package test
|
|||||||
public class Test(str: String?) {
|
public class Test(str: String?) {
|
||||||
var myStr: String? = "String2"
|
var myStr: String? = "String2"
|
||||||
|
|
||||||
{
|
init {
|
||||||
myStr = str
|
myStr = str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class Test {
|
class Test {
|
||||||
var str: String
|
var str: String
|
||||||
|
|
||||||
{
|
init {
|
||||||
str = "Ola"
|
str = "Ola"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ class Test {
|
|||||||
companion object {
|
companion object {
|
||||||
var str: String
|
var str: String
|
||||||
|
|
||||||
{
|
init {
|
||||||
str = "Ola"
|
str = "Ola"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class A// this is a primary constructor
|
|||||||
(p: Int = 1) {
|
(p: Int = 1) {
|
||||||
private val v: Int
|
private val v: Int
|
||||||
|
|
||||||
{
|
init {
|
||||||
v = 1
|
v = 1
|
||||||
} // end of primary constructor body
|
} // end of primary constructor body
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class C(val myArg1: Int) {
|
|||||||
myArg3 = 0
|
myArg3 = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
init {
|
||||||
myArg2 = 0
|
myArg2 = 0
|
||||||
myArg3 = 0
|
myArg3 = 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package org.test.customer
|
|||||||
|
|
||||||
class Customer(public val firstName: String, public val lastName: String) {
|
class Customer(public val firstName: String, public val lastName: String) {
|
||||||
|
|
||||||
{
|
init {
|
||||||
doSmthBefore()
|
doSmthBefore()
|
||||||
doSmthAfter()
|
doSmthAfter()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class C(private val field: Int) {
|
class C(private val field: Int) {
|
||||||
|
|
||||||
{
|
init {
|
||||||
System.out.println(field)
|
System.out.println(field)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
class C(p: Int) {
|
class C(p: Int) {
|
||||||
private val p: Int
|
private val p: Int
|
||||||
|
|
||||||
{
|
init {
|
||||||
var p = p
|
var p = p
|
||||||
this.p = p
|
this.p = p
|
||||||
System.out.println(p++)
|
System.out.println(p++)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class C(p: Int, c: C) {
|
class C(p: Int, c: C) {
|
||||||
public var p: Int = 0
|
public var p: Int = 0
|
||||||
|
|
||||||
{
|
init {
|
||||||
c.p = p
|
c.p = p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
class C(p: Int) {
|
class C(p: Int) {
|
||||||
public var p: Int = 0
|
public var p: Int = 0
|
||||||
|
|
||||||
{
|
init {
|
||||||
this.p = 0
|
this.p = 0
|
||||||
if (p > 0) {
|
if (p > 0) {
|
||||||
this.p = p
|
this.p = p
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class C(x: String) {
|
class C(x: String) {
|
||||||
public var x: Any
|
public var x: Any
|
||||||
|
|
||||||
{
|
init {
|
||||||
this.x = x
|
this.x = x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
class C(x: Any, b: Boolean) {
|
class C(x: Any, b: Boolean) {
|
||||||
public var x: Any
|
public var x: Any
|
||||||
|
|
||||||
{
|
init {
|
||||||
if (b) {
|
if (b) {
|
||||||
this.x = x
|
this.x = x
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
class C(arg1: Int, arg2: Int = 0, arg3: Int = 0) {
|
class C(arg1: Int, arg2: Int = 0, arg3: Int = 0) {
|
||||||
private val field: Int
|
private val field: Int
|
||||||
|
|
||||||
{
|
init {
|
||||||
var arg1 = arg1
|
var arg1 = arg1
|
||||||
var arg3 = arg3
|
var arg3 = arg3
|
||||||
arg1++
|
arg1++
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
public class Test(public var id: String?, public val name: String, public val age: Int) {
|
public class Test(public var id: String?, public val name: String, public val age: Int) {
|
||||||
|
|
||||||
{
|
init {
|
||||||
System.out.println(age)
|
System.out.println(age)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ public class Test(count: Int) {
|
|||||||
public var count: Int = 0
|
public var count: Int = 0
|
||||||
private set
|
private set
|
||||||
|
|
||||||
{
|
init {
|
||||||
this.count = count
|
this.count = count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ public open class Base(x: Int) {
|
|||||||
public var x: Int = 42
|
public var x: Int = 42
|
||||||
protected set
|
protected set
|
||||||
|
|
||||||
{
|
init {
|
||||||
this.x = x
|
this.x = x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class C(val arg1: Int) {
|
|||||||
arg3 = 0
|
arg3 = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
init {
|
||||||
arg2 = 0
|
arg2 = 0
|
||||||
arg3 = 0
|
arg3 = 0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class A(private val field6: Int, private val field8: Int, a: A) {
|
|||||||
private var field10: Int = 0
|
private var field10: Int = 0
|
||||||
private var field11: Int = 0
|
private var field11: Int = 0
|
||||||
|
|
||||||
{
|
init {
|
||||||
field7 = 10
|
field7 = 10
|
||||||
this.field9 = 10
|
this.field9 = 10
|
||||||
if (field6 > 0) {
|
if (field6 > 0) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
package demo
|
package demo
|
||||||
|
|
||||||
class C(a: Int) {
|
class C(a: Int) {
|
||||||
{
|
init {
|
||||||
abc = a * 2
|
abc = a * 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import java.util.*
|
|||||||
class A {
|
class A {
|
||||||
private val collection: MutableCollection<String>
|
private val collection: MutableCollection<String>
|
||||||
|
|
||||||
{
|
init {
|
||||||
collection = createCollection()
|
collection = createCollection()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class C(private val s: String?) {
|
class C(private val s: String?) {
|
||||||
|
|
||||||
{
|
init {
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
System.out.print("null")
|
System.out.print("null")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ open class Frame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class Client : Frame() {
|
public class Client : Frame() {
|
||||||
{
|
init {
|
||||||
val a = object : WindowAdapter() {
|
val a = object : WindowAdapter() {
|
||||||
override fun windowClosing() {
|
override fun windowClosing() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package demo
|
package demo
|
||||||
|
|
||||||
class Collection<E>(e: E) {
|
class Collection<E>(e: E) {
|
||||||
{
|
init {
|
||||||
System.out.println(e)
|
System.out.println(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user