Converter:

Functions are final by default in plugin mode
This commit is contained in:
Pavel V. Talanov
2013-11-19 16:52:57 +04:00
parent bf4e27b152
commit d98d8cfa7f
88 changed files with 168 additions and 162 deletions
+6 -6
View File
@@ -207,7 +207,7 @@ public class Converter(val project: Project, val settings: ConverterSettings) {
} }
} }
} }
members.add(Constructor(Identifier.EMPTY_IDENTIFIER, arrayListOf(), Collections.emptySet<Modifier>(), members.add(Constructor(this, Identifier.EMPTY_IDENTIFIER, arrayListOf(), Collections.emptySet<Modifier>(),
ClassType(name, Collections.emptyList<Element>(), false, this), ClassType(name, Collections.emptyList<Element>(), false, this),
Collections.emptyList<Element>(), Collections.emptyList<Element>(),
ParameterList(createParametersFromFields(finalOrWithEmptyInitializer)), ParameterList(createParametersFromFields(finalOrWithEmptyInitializer)),
@@ -295,12 +295,11 @@ public class Converter(val project: Project, val settings: ConverterSettings) {
} }
if (method.isConstructor()) { if (method.isConstructor()) {
val isPrimary: Boolean = isConstructorPrimary(method) return Constructor(this, identifier, docComments, modifiers, returnType, typeParameters, params,
return Constructor(identifier, docComments, modifiers, returnType, typeParameters, params, Block(removeEmpty(body.statements), false), isConstructorPrimary(method))
Block(removeEmpty(body.statements), false), isPrimary)
} }
return Function(identifier, docComments, modifiers, returnType, typeParameters, params, body) return Function(this, identifier, docComments, modifiers, returnType, typeParameters, params, body)
} }
private fun createFunctionParameters(method: PsiMethod): ParameterList { private fun createFunctionParameters(method: PsiMethod): ParameterList {
@@ -342,6 +341,7 @@ public class Converter(val project: Project, val settings: ConverterSettings) {
return false return false
} }
public fun blockToBlock(block: PsiCodeBlock?, notEmpty: Boolean): Block { public fun blockToBlock(block: PsiCodeBlock?, notEmpty: Boolean): Block {
if (block == null) if (block == null)
return Block.EMPTY_BLOCK return Block.EMPTY_BLOCK
@@ -611,7 +611,7 @@ public class Converter(val project: Project, val settings: ConverterSettings) {
private fun isNotOpenMethod(method: PsiMethod): Boolean { private fun isNotOpenMethod(method: PsiMethod): Boolean {
val parent = method.getParent() val parent = method.getParent()
if (parent is PsiClass) { if (parent is PsiClass) {
val parentModifierList: PsiModifierList? = parent.getModifierList() val parentModifierList = parent.getModifierList()
if ((parentModifierList != null && parentModifierList.hasExplicitModifier(PsiModifier.FINAL)) || parent.isEnum()) { if ((parentModifierList != null && parentModifierList.hasExplicitModifier(PsiModifier.FINAL)) || parent.isEnum()) {
return true return true
} }
+1 -1
View File
@@ -80,7 +80,7 @@ public open class Class(val converter: Converter,
val constructorTypeParameters = ArrayList<Element>() val constructorTypeParameters = ArrayList<Element>()
constructorTypeParameters.addAll(typeParameters) constructorTypeParameters.addAll(typeParameters)
constructorTypeParameters.addAll(f.typeParameters) constructorTypeParameters.addAll(f.typeParameters)
return Function(Identifier("init"), arrayList(), modifiers, return Function(converter, Identifier("init"), arrayList(), modifiers,
ClassType(name, constructorTypeParameters, false, converter), ClassType(name, constructorTypeParameters, false, converter),
constructorTypeParameters, f.params, block) constructorTypeParameters, f.params, block)
} }
@@ -17,21 +17,24 @@
package org.jetbrains.jet.j2k.ast package org.jetbrains.jet.j2k.ast
import org.jetbrains.jet.j2k.ast.types.Type import org.jetbrains.jet.j2k.ast.types.Type
import org.jetbrains.jet.j2k.Converter
public open class Constructor(identifier: Identifier, public class Constructor(converter: Converter,
identifier: Identifier,
docComments: List<Node>, docComments: List<Node>,
modifiers: Set<Modifier>, modifiers: Set<Modifier>,
`type`: Type, `type`: Type,
typeParameters: List<Element>, typeParameters: List<Element>,
params: Element, params: Element,
block: Block, block: Block,
val isPrimary: Boolean) : Function(identifier, docComments, modifiers, `type`, typeParameters, params, block) { val isPrimary: Boolean) : Function(converter, identifier, docComments, modifiers,
`type`, typeParameters, params, block) {
public open fun primarySignatureToKotlin(): String { public fun primarySignatureToKotlin(): String {
return "(" + params.toKotlin() + ")" return "(" + params.toKotlin() + ")"
} }
public open fun primaryBodyToKotlin(): String { public fun primaryBodyToKotlin(): String {
return block!!.toKotlin() return block!!.toKotlin()
} }
} }
@@ -19,8 +19,10 @@ package org.jetbrains.jet.j2k.ast
import org.jetbrains.jet.j2k.ast.types.Type import org.jetbrains.jet.j2k.ast.types.Type
import java.util.ArrayList import java.util.ArrayList
import org.jetbrains.jet.j2k.ast.types.isUnit import org.jetbrains.jet.j2k.ast.types.isUnit
import org.jetbrains.jet.j2k.Converter
public open class Function(val name: Identifier, public open class Function(val converter: Converter,
val name: Identifier,
val docComments: List<Node>, val docComments: List<Node>,
modifiers: Set<Modifier>, modifiers: Set<Modifier>,
val `type`: Type, val `type`: Type,
@@ -61,10 +63,11 @@ public open class Function(val name: Identifier,
modifierList.add(Modifier.OVERRIDE) modifierList.add(Modifier.OVERRIDE)
} }
if (!modifiers.contains(Modifier.ABSTRACT) && if (converter.settings.openByDefault &&
!modifiers.contains(Modifier.OVERRIDE) && !modifiers.contains(Modifier.ABSTRACT) &&
!modifiers.contains(Modifier.FINAL) && !modifiers.contains(Modifier.OVERRIDE) &&
!modifiers.contains(Modifier.PRIVATE)) { !modifiers.contains(Modifier.FINAL) &&
!modifiers.contains(Modifier.PRIVATE)) {
modifierList.add(Modifier.OPEN) modifierList.add(Modifier.OPEN)
} }
@@ -1,13 +1,13 @@
package test package test
public class Test(str : String) { public class Test(str : String) {
var myStr : String = "String2" var myStr : String = "String2"
public open fun sout(str : String) { public fun sout(str : String) {
System.out.println(str) System.out.println(str)
} }
public open fun dummy(str : String) : String { public fun dummy(str : String) : String {
return str return str
} }
public open fun test() { public fun test() {
sout("String") sout("String")
val test = "String2" val test = "String2"
sout(test) sout(test)
@@ -1,6 +1,6 @@
package test package test
class Foo() { class Foo() {
open fun execute() { fun execute() {
} }
} }
class Bar() { class Bar() {
@@ -8,7 +8,7 @@ var fooNotNull : Foo = Foo()
var fooNullable : Foo = null var fooNullable : Foo = null
} }
class Test() { class Test() {
public open fun test(barNotNull : Bar, barNullable : Bar) { public fun test(barNotNull : Bar, barNullable : Bar) {
barNotNull.fooNotNull.execute() barNotNull.fooNotNull.execute()
barNotNull.fooNullable.execute() barNotNull.fooNullable.execute()
barNullable.fooNotNull.execute() barNullable.fooNotNull.execute()
@@ -1,6 +1,6 @@
import java.util.BitSet import java.util.BitSet
class Foo() { class Foo() {
open fun foo(o : BitSet) { fun foo(o : BitSet) {
val o2 = o val o2 = o
val foo = 0 val foo = 0
foo = o2.size() foo = o2.size()
@@ -1,6 +1,6 @@
import java.util.ArrayList import java.util.ArrayList
class Boxing() { class Boxing() {
open fun test() { fun test() {
val i = 0 val i = 0
val n = 0.0.toFloat() val n = 0.0.toFloat()
i = 1 i = 1
@@ -1,6 +1,6 @@
package demo package demo
class Test() { class Test() {
open fun test() { fun test() {
val i = Integer.valueOf(100) val i = Integer.valueOf(100)
val s = 3 val s = 3
val ss = java.lang.Short.valueOf(s) val ss = java.lang.Short.valueOf(s)
@@ -4,7 +4,7 @@ val ourOut : java.io.PrintStream = 0
} }
} }
class User() { class User() {
open fun main() { fun main() {
Library.ourOut.print() Library.ourOut.print()
} }
} }
@@ -1,14 +1,14 @@
class Library() { class Library() {
class object { class object {
open fun call() { fun call() {
} }
open fun getString() : String { fun getString() : String {
return "" return ""
} }
} }
} }
class User() { class User() {
open fun main() { fun main() {
Library.call() Library.call()
Library.getString().isEmpty() Library.getString().isEmpty()
} }
@@ -1,12 +1,12 @@
class Library() { class Library() {
open fun call() { fun call() {
} }
open fun getString() : String { fun getString() : String {
return "" return ""
} }
} }
class User() { class User() {
open fun main() { fun main() {
val lib = Library() val lib = Library()
lib.call() lib.call()
lib.getString().isEmpty() lib.getString().isEmpty()
@@ -2,7 +2,7 @@ class Library() {
public val myString : String = 0 public val myString : String = 0
} }
class User() { class User() {
open fun main() { fun main() {
Library.myString.isEmpty() Library.myString.isEmpty()
} }
} }
@@ -1,14 +1,14 @@
package test package test
public class Short() { public class Short() {
class object { class object {
public open fun valueOf(value : String) : Short { public fun valueOf(value : String) : Short {
return Short() return Short()
} }
} }
} }
class Test() { class Test() {
class object { class object {
public open fun test() { public fun test() {
test.Short.valueOf("1") test.Short.valueOf("1")
test.Short.valueOf("1") test.Short.valueOf("1")
java.lang.Short.valueOf("1") java.lang.Short.valueOf("1")
@@ -1,6 +1,6 @@
abstract class A() { abstract class A() {
abstract fun callme() abstract fun callme()
open fun callmetoo() { fun callmetoo() {
print("This is a concrete method.") print("This is a concrete method.")
} }
} }
@@ -1,9 +1,9 @@
abstract class Shape() { abstract class Shape() {
public var color : String = 0 public var color : String = 0
public open fun setColor(c : String) { public fun setColor(c : String) {
color = c color = c
} }
public open fun getColor() : String { public fun getColor() : String {
return color return color
} }
public abstract fun area() : Double public abstract fun area() : Double
+3 -3
View File
@@ -2,18 +2,18 @@ package demo
import java.util.HashMap import java.util.HashMap
class Test() { class Test() {
class object { class object {
open fun init() : Test { fun init() : Test {
val __ = Test() val __ = Test()
return __ return __
} }
open fun init(s : String) : Test { fun init(s : String) : Test {
val __ = Test() val __ = Test()
return __ return __
} }
} }
} }
class User() { class User() {
open fun main() { fun main() {
val m = HashMap(1) val m = HashMap(1)
val m2 = HashMap(10) val m2 = HashMap(10)
val t1 = Test.init() val t1 = Test.init()
@@ -1,10 +1,10 @@
class C(arg1 : Int, arg2 : Int, arg3 : Int) { class C(arg1 : Int, arg2 : Int, arg3 : Int) {
class object { class object {
open fun init(arg1 : Int, arg2 : Int) : C { fun init(arg1 : Int, arg2 : Int) : C {
val __ = C(arg1, arg2, 0) val __ = C(arg1, arg2, 0)
return __ return __
} }
open fun init(arg1 : Int) : C { fun init(arg1 : Int) : C {
val __ = C(arg1, 0, 0) val __ = C(arg1, 0, 0)
return __ return __
} }
@@ -12,7 +12,7 @@ return __
} }
public class User() { public class User() {
class object { class object {
public open fun main() { public fun main() {
val c1 = C(100, 100, 100) val c1 = C(100, 100, 100)
val c2 = C.init(100, 100) val c2 = C.init(100, 100)
val c3 = C.init(100) val c3 = C.init(100)
@@ -8,13 +8,13 @@ myArg2 = 0
myArg3 = 0 myArg3 = 0
} }
class object { class object {
open fun init(arg1 : Int, arg2 : Int, arg3 : Int) : C { fun init(arg1 : Int, arg2 : Int, arg3 : Int) : C {
val __ = C(arg1) val __ = C(arg1)
__.myArg2 = arg2 __.myArg2 = arg2
__.myArg3 = arg3 __.myArg3 = arg3
return __ return __
} }
open fun init(arg1 : Int, arg2 : Int) : C { fun init(arg1 : Int, arg2 : Int) : C {
val __ = C(arg1) val __ = C(arg1)
__.myArg2 = arg2 __.myArg2 = arg2
__.myArg3 = 0 __.myArg3 = 0
@@ -24,7 +24,7 @@ return __
} }
public class User() { public class User() {
class object { class object {
public open fun main() { public fun main() {
val c1 = C.init(100, 100, 100) val c1 = C.init(100, 100, 100)
val c2 = C.init(100, 100) val c2 = C.init(100, 100)
val c3 = C(100) val c3 = C(100)
@@ -2,10 +2,10 @@ package org.test.customer
class Customer(first : String, last : String) { class Customer(first : String, last : String) {
public val _firstName : String public val _firstName : String
public val _lastName : String public val _lastName : String
public open fun getFirstName() : String { public fun getFirstName() : String {
return _firstName return _firstName
} }
public open fun getLastName() : String { public fun getLastName() : String {
return _lastName return _lastName
} }
private fun doSmthBefore() { private fun doSmthBefore() {
@@ -22,21 +22,21 @@ doSmthAfter()
class CustomerBuilder() { class CustomerBuilder() {
public var _firstName : String = "Homer" public var _firstName : String = "Homer"
public var _lastName : String = "Simpson" public var _lastName : String = "Simpson"
public open fun WithFirstName(firstName : String) : CustomerBuilder { public fun WithFirstName(firstName : String) : CustomerBuilder {
_firstName = firstName _firstName = firstName
return this return this
} }
public open fun WithLastName(lastName : String) : CustomerBuilder { public fun WithLastName(lastName : String) : CustomerBuilder {
_lastName = lastName _lastName = lastName
return this return this
} }
public open fun Build() : Customer { public fun Build() : Customer {
return Customer(_firstName, _lastName) return Customer(_firstName, _lastName)
} }
} }
public class User() { public class User() {
class object { class object {
public open fun main() { public fun main() {
val customer = CustomerBuilder().WithFirstName("Homer").WithLastName("Simpson").Build() val customer = CustomerBuilder().WithFirstName("Homer").WithLastName("Simpson").Build()
System.out.println(customer.getFirstName()) System.out.println(customer.getFirstName())
System.out.println(customer.getLastName()) System.out.println(customer.getLastName())
@@ -2,7 +2,7 @@ public class Identifier<T>(_myName : T, _myHasDollar : Boolean) {
private val myName : T private val myName : T
private var myHasDollar : Boolean = false private var myHasDollar : Boolean = false
private var myNullable : Boolean = true private var myNullable : Boolean = true
public open fun getName() : T { public fun getName() : T {
return myName return myName
} }
{ {
@@ -10,16 +10,16 @@ myName = _myName
myHasDollar = _myHasDollar myHasDollar = _myHasDollar
} }
class object { class object {
public open fun init<T>(name : T) : Identifier<T> { public fun init<T>(name : T) : Identifier<T> {
val __ = Identifier(name, false) val __ = Identifier(name, false)
return __ return __
} }
public open fun init<T>(name : T, isNullable : Boolean) : Identifier<T> { public fun init<T>(name : T, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, false) val __ = Identifier(name, false)
__.myNullable = isNullable __.myNullable = isNullable
return __ return __
} }
public open fun init<T>(name : T, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> { public fun init<T>(name : T, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, hasDollar) val __ = Identifier(name, hasDollar)
__.myNullable = isNullable __.myNullable = isNullable
return __ return __
@@ -28,7 +28,7 @@ return __
} }
public class User() { public class User() {
class object { class object {
public open fun main() { public fun main() {
val i1 = Identifier.init<String>("name", false, true) val i1 = Identifier.init<String>("name", false, true)
val i2 = Identifier.init<String>("name", false) val i2 = Identifier.init<String>("name", false)
val i3 = Identifier.init<String>("name") val i3 = Identifier.init<String>("name")
@@ -2,7 +2,7 @@ public class Identifier(_myName : String, _myHasDollar : Boolean) {
private val myName : String private val myName : String
private var myHasDollar : Boolean = false private var myHasDollar : Boolean = false
private var myNullable : Boolean = true private var myNullable : Boolean = true
public open fun getName() : String { public fun getName() : String {
return myName return myName
} }
{ {
@@ -10,16 +10,16 @@ myName = _myName
myHasDollar = _myHasDollar myHasDollar = _myHasDollar
} }
class object { class object {
public open fun init(name : String) : Identifier { public fun init(name : String) : Identifier {
val __ = Identifier(name, false) val __ = Identifier(name, false)
return __ return __
} }
public open fun init(name : String, isNullable : Boolean) : Identifier { public fun init(name : String, isNullable : Boolean) : Identifier {
val __ = Identifier(name, false) val __ = Identifier(name, false)
__.myNullable = isNullable __.myNullable = isNullable
return __ return __
} }
public open fun init(name : String, hasDollar : Boolean, isNullable : Boolean) : Identifier { public fun init(name : String, hasDollar : Boolean, isNullable : Boolean) : Identifier {
val __ = Identifier(name, hasDollar) val __ = Identifier(name, hasDollar)
__.myNullable = isNullable __.myNullable = isNullable
return __ return __
@@ -28,7 +28,7 @@ return __
} }
public class User() { public class User() {
class object { class object {
public open fun main() { public fun main() {
val i1 = Identifier.init("name", false, true) val i1 = Identifier.init("name", false, true)
val i2 = Identifier.init("name", false) val i2 = Identifier.init("name", false)
val i3 = Identifier.init("name") val i3 = Identifier.init("name")
@@ -18,22 +18,22 @@ f = _f
g = _g g = _g
} }
class object { class object {
public open fun init() : Test { public fun init() : Test {
val __ = Test(0, false, 0.toDouble(), 0.toFloat(), 0, 0, 0, ' ') val __ = Test(0, false, 0.toDouble(), 0.toFloat(), 0, 0, 0, ' ')
return __ return __
} }
public open fun init(name : String) : Test { public fun init(name : String) : Test {
val __ = Test(foo(name), false, 0.toDouble(), 0.toFloat(), 0, 0, 0, ' ') val __ = Test(foo(name), false, 0.toDouble(), 0.toFloat(), 0, 0, 0, ' ')
return __ return __
} }
open fun foo(n : String) : String { fun foo(n : String) : String {
return "" return ""
} }
} }
} }
public class User() { public class User() {
class object { class object {
public open fun main() { public fun main() {
val t = Test.init("name") val t = Test.init("name")
} }
} }
@@ -17,19 +17,19 @@ super.finalize()
} }
} }
class Base() { class Base() {
public open fun hashCode() : Int { public fun hashCode() : Int {
return System.identityHashCode(this) return System.identityHashCode(this)
} }
public open fun equals(o : Any) : Boolean { public fun equals(o : Any) : Boolean {
return this.identityEquals(o) return this.identityEquals(o)
} }
protected open fun clone() : Any { protected fun clone() : Any {
return super.clone() return super.clone()
} }
public open fun toString() : String { public fun toString() : String {
return getJavaClass<Base>.getName() + '@' + Integer.toHexString(hashCode()) return getJavaClass<Base>.getName() + '@' + Integer.toHexString(hashCode())
} }
protected open fun finalize() { protected fun finalize() {
super.finalize() super.finalize()
} }
} }
@@ -1,5 +1,5 @@
class A() { class A() {
open fun a() { fun a() {
} }
} }
class B() : A() { class B() : A() {
@@ -1,5 +1,5 @@
class A() { class A() {
open fun foo() { fun foo() {
} }
} }
class B() : A() { class B() : A() {
@@ -1,18 +1,18 @@
package test package test
class Test() { class Test() {
public open fun hashCode() : Int { public fun hashCode() : Int {
return System.identityHashCode(this) return System.identityHashCode(this)
} }
public open fun equals(o : Any) : Boolean { public fun equals(o : Any) : Boolean {
return this.identityEquals(o) return this.identityEquals(o)
} }
protected open fun clone() : Any { protected fun clone() : Any {
return super.clone() return super.clone()
} }
public open fun toString() : String { public fun toString() : String {
return getJavaClass<Test>.getName() + '@' + Integer.toHexString(hashCode()) return getJavaClass<Test>.getName() + '@' + Integer.toHexString(hashCode())
} }
protected open fun finalize() { protected fun finalize() {
super.finalize() super.finalize()
} }
} }
@@ -1,6 +1,6 @@
package demo package demo
class Test() { class Test() {
open fun test(vararg var args : Any) { fun test(vararg var args : Any) {
args = array<Int>(1, 2, 3) args = array<Int>(1, 2, 3)
} }
} }
@@ -1,6 +1,6 @@
package demo package demo
class Test() { class Test() {
open fun test(var i : Int) : Int { fun test(var i : Int) : Int {
i = 10 i = 10
return i + 20 return i + 20
} }
@@ -4,7 +4,7 @@ class `$`() {
} }
class `$$`(`$$$$` : `$$$$$`) : `$`() { class `$$`(`$$$$` : `$$$$$`) : `$`() {
val `$$$` : `$$$$$` val `$$$` : `$$$$$`
public open fun `$$$$$$`() : `$$$$$` { public fun `$$$$$$`() : `$$$$$` {
return `$$$` return `$$$`
} }
{ {
@@ -1,6 +1,6 @@
class Test() { class Test() {
class object { class object {
public open fun foo(args : Array<String>) : Int { public fun foo(args : Array<String>) : Int {
return args.size return args.size
} }
} }
@@ -11,7 +11,7 @@ private var i : Int = 0
/** /**
* This is a function doc comment. * This is a function doc comment.
*/ */
public open fun foo() { public fun foo() {
/* This is a function comment */ /* This is a function comment */
} }
} }
+2 -2
View File
@@ -2,11 +2,11 @@ import java.util.HashMap
class G<T : String>(t : T) { class G<T : String>(t : T) {
} }
public class Java() { public class Java() {
open fun test() { fun test() {
val m = HashMap() val m = HashMap()
m.put(1, 1) m.put(1, 1)
} }
open fun test2() { fun test2() {
val m = HashMap() val m = HashMap()
val g = G("") val g = G("")
val g2 = G<String>("") val g2 = G<String>("")
+1 -1
View File
@@ -1,7 +1,7 @@
package demo package demo
class Test() { class Test() {
class object { class object {
open fun subListRangeCheck(fromIndex : Int, toIndex : Int, size : Int) { fun subListRangeCheck(fromIndex : Int, toIndex : Int, size : Int) {
if (fromIndex < 0) if (fromIndex < 0)
throw IndexOutOfBoundsException("fromIndex = " + fromIndex) throw IndexOutOfBoundsException("fromIndex = " + fromIndex)
if (toIndex > size) if (toIndex > size)
@@ -1,8 +1,8 @@
package demo package demo
class Test() { class Test() {
open fun putInt(i : Int) { fun putInt(i : Int) {
} }
open fun test() { fun test() {
val b = 10 val b = 10
putInt(b.toInt()) putInt(b.toInt())
val b2 = 10 val b2 = 10
@@ -1,8 +1,8 @@
package demo package demo
class Test() { class Test() {
open fun putInt(i : Int) { fun putInt(i : Int) {
} }
open fun test() { fun test() {
val i = 10 val i = 10
putInt(i) putInt(i)
} }
+2 -2
View File
@@ -1,8 +1,8 @@
package demo package demo
class Test() { class Test() {
open fun putInt(i : Int) { fun putInt(i : Int) {
} }
open fun test() { fun test() {
val b = 10 val b = 10
putInt(b.toInt()) putInt(b.toInt())
} }
+5 -5
View File
@@ -2,7 +2,7 @@ public class Identifier<T>(_myName : T, _myHasDollar : Boolean) {
private val myName : T private val myName : T
private var myHasDollar : Boolean = false private var myHasDollar : Boolean = false
private var myNullable : Boolean = true private var myNullable : Boolean = true
public open fun getName() : T { public fun getName() : T {
return myName return myName
} }
{ {
@@ -10,16 +10,16 @@ myName = _myName
myHasDollar = _myHasDollar myHasDollar = _myHasDollar
} }
class object { class object {
public open fun init<T>(name : T) : Identifier<T> { public fun init<T>(name : T) : Identifier<T> {
val __ = Identifier(name, false) val __ = Identifier(name, false)
return __ return __
} }
public open fun init<T>(name : T, isNullable : Boolean) : Identifier<T> { public fun init<T>(name : T, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, false) val __ = Identifier(name, false)
__.myNullable = isNullable __.myNullable = isNullable
return __ return __
} }
public open fun init<T>(name : T, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> { public fun init<T>(name : T, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, hasDollar) val __ = Identifier(name, hasDollar)
__.myNullable = isNullable __.myNullable = isNullable
return __ return __
@@ -28,7 +28,7 @@ return __
} }
public class User() { public class User() {
class object { class object {
public open fun main(args : Array<String>) { public fun main(args : Array<String>) {
val i1 = Identifier.init<String>("name", false, true) val i1 = Identifier.init<String>("name", false, true)
val i2 = Identifier.init<String>("name", false) val i2 = Identifier.init<String>("name", false)
val i3 = Identifier.init<String>("name") val i3 = Identifier.init<String>("name")
+3 -3
View File
@@ -1,12 +1,12 @@
package test package test
class Base() { class Base() {
public open fun hashCode() : Int { public fun hashCode() : Int {
return System.identityHashCode(this) return System.identityHashCode(this)
} }
public open fun equals(o : Any) : Boolean { public fun equals(o : Any) : Boolean {
return this.identityEquals(o) return this.identityEquals(o)
} }
public open fun toString() : String { public fun toString() : String {
return getJavaClass<Base>.getName() + '@' + Integer.toHexString(hashCode()) return getJavaClass<Base>.getName() + '@' + Integer.toHexString(hashCode())
} }
} }
@@ -1,6 +1,6 @@
package demo package demo
class Test(i : Int) { class Test(i : Int) {
open fun test() { fun test() {
val i = 10 val i = 10
Test(i) Test(i)
} }
+1 -1
View File
@@ -1,6 +1,6 @@
package demo package demo
class Test(i : Int) { class Test(i : Int) {
open fun test() { fun test() {
val b = 10 val b = 10
Test(b.toInt()) Test(b.toInt())
} }
@@ -1,9 +1,9 @@
package demo package demo
class Test() { class Test() {
open fun getInteger(i : Int) : Int { fun getInteger(i : Int) : Int {
return i return i
} }
open fun test() { fun test() {
val i = getInteger(10)!! val i = getInteger(10)!!
} }
} }
+1 -1
View File
@@ -1,5 +1,5 @@
class Test() { class Test() {
open fun getInt() : Int { fun getInt() : Int {
val b = 10 val b = 10
return b.toInt() return b.toInt()
} }
@@ -10,9 +10,9 @@ var myContainer : Container = Container()
class StringContainer(s : String) { class StringContainer(s : String) {
} }
class Test() { class Test() {
open fun putString(s : String) { fun putString(s : String) {
} }
open fun test() { fun test() {
putString(One.myContainer.myString) putString(One.myContainer.myString)
StringContainer(One.myContainer.myString) StringContainer(One.myContainer.myString)
} }
+2 -2
View File
@@ -10,9 +10,9 @@ var myContainer : Container = Container()
class IntContainer(i : Int) { class IntContainer(i : Int) {
} }
class Test() { class Test() {
open fun putInt(i : Int) { fun putInt(i : Int) {
} }
open fun test() { fun test() {
putInt(One.myContainer.myInt) putInt(One.myContainer.myInt)
IntContainer(One.myContainer.myInt) IntContainer(One.myContainer.myInt)
} }
@@ -1,6 +1,6 @@
class Test() { class Test() {
class object { class object {
public open fun toFileSystemSafeName(name : String) : String { public fun toFileSystemSafeName(name : String) : String {
val size = name.length() val size = name.length()
return name return name
} }
+1 -1
View File
@@ -8,7 +8,7 @@ var myContainer : Container = Container()
} }
} }
class Test() { class Test() {
open fun test() { fun test() {
val b = One.myContainer.myInt.toByte() val b = One.myContainer.myInt.toByte()
} }
} }
@@ -5,7 +5,7 @@ import java.io.File
*/ */
public class Test() { public class Test() {
class object { class object {
public open fun isDir(parent : File) : Boolean { public fun isDir(parent : File) : Boolean {
if (parent == null || !parent.exists()) if (parent == null || !parent.exists())
{ {
return false return false
+1 -1
View File
@@ -8,7 +8,7 @@ var myContainer : Container = Container()
} }
} }
class Test() { class Test() {
open fun test() { fun test() {
if (One.myContainer.myBoolean) if (One.myContainer.myBoolean)
System.out.println("Ok") System.out.println("Ok")
val s = (if (One.myContainer.myBoolean) val s = (if (One.myContainer.myBoolean)
+1 -1
View File
@@ -1,5 +1,5 @@
class Test() { class Test() {
open fun test() { fun test() {
val res = true val res = true
res = res and false res = res and false
res = res or false res = res or false
+2 -2
View File
@@ -10,9 +10,9 @@ this.code = code
} }
} }
class Base() { class Base() {
open fun test() { fun test() {
} }
open fun toString() : String { fun toString() : String {
return "BASE" return "BASE"
} }
} }
+1 -1
View File
@@ -2,7 +2,7 @@ package com.voltvoodoo.saplo4j.model
import java.io.Serializable import java.io.Serializable
public class Language(code : String) : Serializable { public class Language(code : String) : Serializable {
protected var code : String = 0 protected var code : String = 0
public open fun equals(other : Language) : Boolean { public fun equals(other : Language) : Boolean {
return other.toString().equals(this.toString()) return other.toString().equals(this.toString())
} }
{ {
+1 -1
View File
@@ -1,6 +1,6 @@
package demo package demo
class Test() { class Test() {
open fun test() : String { fun test() : String {
val s1 = "" val s1 = ""
val s2 = "" val s2 = ""
val s3 = "" val s3 = ""
+1 -1
View File
@@ -1,7 +1,7 @@
package demo package demo
class Program() { class Program() {
class object { class object {
public open fun main(args : Array<String>) { public fun main(args : Array<String>) {
System.out.println("Halo!") System.out.println("Halo!")
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
class Test() { class Test() {
class object { class object {
public open fun getInt(i : Int) : Int { public fun getInt(i : Int) : Int {
when (i) { when (i) {
0 -> { 0 -> {
return 0 return 0
+1 -1
View File
@@ -1,6 +1,6 @@
package demo package demo
class Test() { class Test() {
open fun test() { fun test() {
for (i in 0..10 - 1) { for (i in 0..10 - 1) {
System.out.println(i) System.out.println(i)
} }
@@ -1,6 +1,6 @@
import java.util.Calendar import java.util.Calendar
abstract class MyCalendar() : Calendar() { abstract class MyCalendar() : Calendar() {
public open fun foo() { public fun foo() {
val i = Calendar.ALL_STYLES val i = Calendar.ALL_STYLES
} }
} }
@@ -3,7 +3,7 @@ class Test() : java.lang.Iterable<String> {
public override fun iterator() : java.util.Iterator<String> { public override fun iterator() : java.util.Iterator<String> {
return null return null
} }
public open fun push(i : java.util.Iterator<String>) : java.util.Iterator<String> { public fun push(i : java.util.Iterator<String>) : java.util.Iterator<String> {
val j = i val j = i
return j return j
} }
@@ -12,7 +12,7 @@ class FullTest() : java.lang.Iterable<String> {
public override fun iterator() : java.util.Iterator<String> { public override fun iterator() : java.util.Iterator<String> {
return null return null
} }
public open fun push(i : java.util.Iterator<String>) : java.util.Iterator<String> { public fun push(i : java.util.Iterator<String>) : java.util.Iterator<String> {
val j = i val j = i
return j return j
} }
+1 -1
View File
@@ -1,6 +1,6 @@
import java.util.* import java.util.*
public class ForEach() { public class ForEach() {
public open fun test() { public fun test() {
val xs = ArrayList<Any>() val xs = ArrayList<Any>()
val ys = LinkedList<Any>() val ys = LinkedList<Any>()
for (x in xs) for (x in xs)
+1 -1
View File
@@ -1,6 +1,6 @@
import java.util.* import java.util.*
public class Lists() { public class Lists() {
public open fun test() { public fun test() {
val xs = ArrayList<Any>() val xs = ArrayList<Any>()
val ys = LinkedList<Any>() val ys = LinkedList<Any>()
val zs = ArrayList<Any>() val zs = ArrayList<Any>()
@@ -1,5 +1,5 @@
class Test() { class Test() {
open fun test() { fun test() {
val c1 = 'c' val c1 = 'c'
val c2 = 'C' val c2 = 'C'
} }
@@ -1,6 +1,6 @@
package demo package demo
class Test() { class Test() {
open fun test() { fun test() {
val name = "$$$$" val name = "$$$$"
name = name.replaceAll("\\$[0-9]+", "\\$") name = name.replaceAll("\\$[0-9]+", "\\$")
val c = '$' val c = '$'
@@ -1,5 +1,5 @@
class Test() { class Test() {
open fun test() { fun test() {
val l1 = 10 val l1 = 10
val d1 = 10.0 val d1 = 10.0
val f1 = 10.0.toFloat() val f1 = 10.0.toFloat()
@@ -7,7 +7,7 @@ val l2 = 10
val d2 = 10.0 val d2 = 10.0
val f2 = 10.0.toFloat() val f2 = 10.0.toFloat()
} }
open fun testBoxed() { fun testBoxed() {
val l1 = 10 val l1 = 10
val d1 = 10.0 val d1 = 10.0
val f1 = 10.0.toFloat() val f1 = 10.0.toFloat()
@@ -1,5 +1,5 @@
class Test() { class Test() {
open fun test() { fun test() {
val i1 = 33 val i1 = 33
val i2 = 51 val i2 = 51
} }
@@ -1,5 +1,5 @@
class Test() { class Test() {
open fun test() { fun test() {
val i1 = 37 val i1 = 37
val i2 = 26 val i2 = 26
} }
@@ -1,5 +1,5 @@
class Test() { class Test() {
open fun test() { fun test() {
val t1 = true val t1 = true
val t2 = true val t2 = true
val f1 = false val f1 = false
@@ -1,10 +1,10 @@
package demo package demo
class Map() { class Map() {
open fun put<K, V>(k : K, v : V) { fun put<K, V>(k : K, v : V) {
} }
} }
class U() { class U() {
open fun test() { fun test() {
val m = Map() val m = Map()
m.put<String, Int>("10", 10) m.put<String, Int>("10", 10)
} }
@@ -1,6 +1,6 @@
package test package test
class User() { class User() {
open fun main() { fun main() {
val list = java.util.LinkedList() val list = java.util.LinkedList()
} }
} }
@@ -1,6 +1,6 @@
package test package test
class User() { class User() {
open fun main() { fun main() {
val list = java.util.LinkedList() val list = java.util.LinkedList()
} }
} }
@@ -1,6 +1,6 @@
import java.util.LinkedList import java.util.LinkedList
class User() { class User() {
open fun main() { fun main() {
val list = LinkedList<String>() val list = LinkedList<String>()
} }
} }
@@ -2,7 +2,7 @@ package org.test
class Library() { class Library() {
} }
class User() { class User() {
open fun main() { fun main() {
val lib = Library() val lib = Library()
} }
} }
@@ -4,7 +4,7 @@ class InnerClass() {
} }
} }
class User() { class User() {
open fun main() { fun main() {
val outerObject = OuterClass() val outerObject = OuterClass()
val innerObject = outerObject.InnerClass() val innerObject = outerObject.InnerClass()
} }
@@ -3,7 +3,7 @@ import java.util.LinkedList
class Member() { class Member() {
} }
class User() { class User() {
open fun main() { fun main() {
val members = LinkedList<Member>() val members = LinkedList<Member>()
members.add(Member()) members.add(Member())
} }
@@ -6,7 +6,7 @@ class Bar() {
} }
} }
class User() { class User() {
open fun main() { fun main() {
val boo = Foo.Bar() val boo = Foo.Bar()
} }
} }
@@ -1,6 +1,6 @@
package demo package demo
class WindowAdapter() { class WindowAdapter() {
public open fun windowClosing() { public fun windowClosing() {
} }
} }
public class Client() : Frame() { public class Client() : Frame() {
@@ -1,7 +1,7 @@
package demo package demo
import java.util.HashMap import java.util.HashMap
class Test() { class Test() {
open fun main() { fun main() {
val commonMap = HashMap<String, Int>() val commonMap = HashMap<String, Int>()
val rawMap = HashMap<String, Int>() val rawMap = HashMap<String, Int>()
val superRawMap = HashMap() val superRawMap = HashMap()
@@ -5,7 +5,7 @@ System.out.println(e)
} }
} }
class Test() { class Test() {
open fun main() { fun main() {
val raw1 = Collection(1) val raw1 = Collection(1)
val raw2 = Collection<Int>(1) val raw2 = Collection<Int>(1)
val raw3 = Collection<String>("1") val raw3 = Collection<String>("1")
@@ -1,7 +1,7 @@
package demo package demo
import java.util.LinkedList import java.util.LinkedList
class Test() { class Test() {
open fun main() { fun main() {
val common = LinkedList<String>() val common = LinkedList<String>()
val raw = LinkedList<String>() val raw = LinkedList<String>()
val superRaw = LinkedList() val superRaw = LinkedList()
@@ -1,10 +1,10 @@
package demo package demo
class TestT() { class TestT() {
open fun getT<T>() { fun getT<T>() {
} }
} }
class U() { class U() {
open fun main() { fun main() {
val t = TestT() val t = TestT()
t.getT<String>() t.getT<String>()
t.getT<Int>() t.getT<Int>()
@@ -1,9 +1,9 @@
class Base() { class Base() {
open fun foo() fun foo()
} }
class A() : Base() { class A() : Base() {
class C() { class C() {
open fun test() { fun test() {
super@A.foo() super@A.foo()
} }
} }
@@ -1,5 +1,5 @@
class B(i : Int) { class B(i : Int) {
open fun call() : Int { fun call() : Int {
return 1 return 1
} }
} }
@@ -1,10 +1,10 @@
package demo package demo
public class SwitchDemo() { public class SwitchDemo() {
class object { class object {
public open fun print(o : Any) { public fun print(o : Any) {
System.out.println(o) System.out.println(o)
} }
public open fun test(i : Int) { public fun test(i : Int) {
val monthString = "<empty>" val monthString = "<empty>"
when (i) { when (i) {
1 -> { 1 -> {
@@ -80,7 +80,7 @@ monthString = "Invalid month"
} }
System.out.println(monthString) System.out.println(monthString)
} }
public open fun main(args : Array<String>) { public fun main(args : Array<String>) {
for (i in 1..12) test(i) for (i in 1..12) test(i)
} }
} }
@@ -1,6 +1,6 @@
public class NonDefault() { public class NonDefault() {
class object { class object {
public open fun main(args : Array<String>) { public fun main(args : Array<String>) {
val value = 3 val value = 3
val valueString = "" val valueString = ""
when (value) { when (value) {
@@ -1,7 +1,7 @@
package switch_demo package switch_demo
public class SwitchDemo() { public class SwitchDemo() {
class object { class object {
public open fun main(args : Array<String>) { public fun main(args : Array<String>) {
val month = 8 val month = 8
val monthString : String val monthString : String
when (month) { when (month) {
+1 -1
View File
@@ -1,7 +1,7 @@
package switch_demo package switch_demo
public class SwitchDemo() { public class SwitchDemo() {
class object { class object {
public open fun main(args : Array<String>) { public fun main(args : Array<String>) {
val month = 8 val month = 8
val monthString : String val monthString : String
when (month) { when (month) {
@@ -1,6 +1,6 @@
public class NonDefault() { public class NonDefault() {
class object { class object {
public open fun main(args : Array<String>) { public fun main(args : Array<String>) {
val value = 3 val value = 3
val valueString = "" val valueString = ""
when (value) { when (value) {
@@ -1,10 +1,10 @@
class Base() { class Base() {
open fun foo() { fun foo() {
} }
} }
class A() : Base() { class A() : Base() {
class C() { class C() {
open fun test() { fun test() {
this@A.foo() this@A.foo()
} }
} }
@@ -1,4 +1,4 @@
trait INode { trait INode {
open fun getTag() : Tag fun getTag() : Tag
open fun toKotlin() : String fun toKotlin() : String
} }