J2K: use of new syntax for class intialization blocks

This commit is contained in:
Valentin Kipyatkov
2015-03-25 19:20:06 +03:00
parent 4bfdcae972
commit 108a1f872c
26 changed files with 27 additions and 25 deletions
+2
View File
@@ -3,7 +3,9 @@
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<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.stub.jvm" includeSubdirectories="true" />
</excludeFromCompile>
<resourceExtensions />
<wildcardResourcePatterns>
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.j2k.*
class Initializer(val body: DeferredElement<Block>, modifiers: Modifiers) : Member(Annotations.Empty, modifiers) {
override fun generateCode(builder: CodeBuilder) {
builder.append(body)
builder append "init" append body
}
override val isEmpty: Boolean
@@ -5,7 +5,7 @@ package test
public class Test(str: String) {
var myStr = "String2"
{
init {
myStr = str
}
@@ -4,7 +4,7 @@ package test
public class Test(str: String?) {
var myStr: String? = "String2"
{
init {
myStr = str
}
@@ -1,7 +1,7 @@
class Test {
var str: String
{
init {
str = "Ola"
}
}
@@ -2,7 +2,7 @@ class Test {
companion object {
var str: String
{
init {
str = "Ola"
}
}
@@ -2,7 +2,7 @@ class A// this is a primary constructor
(p: Int = 1) {
private val v: Int
{
init {
v = 1
} // end of primary constructor body
@@ -12,7 +12,7 @@ class C(val myArg1: Int) {
myArg3 = 0
}
{
init {
myArg2 = 0
myArg3 = 0
}
@@ -2,7 +2,7 @@ package org.test.customer
class Customer(public val firstName: String, public val lastName: String) {
{
init {
doSmthBefore()
doSmthAfter()
}
@@ -1,6 +1,6 @@
class C(private val field: Int) {
{
init {
System.out.println(field)
}
}
@@ -1,7 +1,7 @@
class C(p: Int) {
private val p: Int
{
init {
var p = p
this.p = p
System.out.println(p++)
@@ -1,7 +1,7 @@
class C(p: Int, c: C) {
public var p: Int = 0
{
init {
c.p = p
}
}
@@ -1,7 +1,7 @@
class C(p: Int) {
public var p: Int = 0
{
init {
this.p = 0
if (p > 0) {
this.p = p
@@ -1,7 +1,7 @@
class C(x: String) {
public var x: Any
{
init {
this.x = x
}
}
@@ -2,7 +2,7 @@
class C(x: Any, b: Boolean) {
public var x: Any
{
init {
if (b) {
this.x = x
}
@@ -2,7 +2,7 @@
class C(arg1: Int, arg2: Int = 0, arg3: Int = 0) {
private val field: Int
{
init {
var arg1 = arg1
var arg3 = arg3
arg1++
@@ -1,6 +1,6 @@
public class Test(public var id: String?, public val name: String, public val age: Int) {
{
init {
System.out.println(age)
}
}
@@ -2,7 +2,7 @@ public class Test(count: Int) {
public var count: Int = 0
private set
{
init {
this.count = count
}
@@ -2,7 +2,7 @@ public open class Base(x: Int) {
public var x: Int = 42
protected set
{
init {
this.x = x
}
}
@@ -12,7 +12,7 @@ class C(val arg1: Int) {
arg3 = 0
}
{
init {
arg2 = 0
arg3 = 0
}
+1 -1
View File
@@ -9,7 +9,7 @@ class A(private val field6: Int, private val field8: Int, a: A) {
private var field10: Int = 0
private var field11: Int = 0
{
init {
field7 = 10
this.field9 = 10
if (field6 > 0) {
+1 -1
View File
@@ -2,7 +2,7 @@
package demo
class C(a: Int) {
{
init {
abc = a * 2
}
@@ -3,7 +3,7 @@ import java.util.*
class A {
private val collection: MutableCollection<String>
{
init {
collection = createCollection()
}
@@ -1,6 +1,6 @@
class C(private val s: String?) {
{
init {
if (s == null) {
System.out.print("null")
}
@@ -15,7 +15,7 @@ open class Frame {
}
public class Client : Frame() {
{
init {
val a = object : WindowAdapter() {
override fun windowClosing() {
}
@@ -1,7 +1,7 @@
package demo
class Collection<E>(e: E) {
{
init {
System.out.println(e)
}
}