Merge pull request #211 from ponomandr/KT3368
KT-3368 J2K: converted enums contain name() method
This commit is contained in:
@@ -42,12 +42,11 @@ public class Enum extends Class {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String toKotlin() {
|
public String toKotlin() {
|
||||||
|
String primaryConstructorBody = primaryConstructorBodyToKotlin();
|
||||||
return modifiersToKotlin() + "enum class" + SPACE + myName.toKotlin() + primaryConstructorSignatureToKotlin() +
|
return modifiersToKotlin() + "enum class" + SPACE + myName.toKotlin() + primaryConstructorSignatureToKotlin() +
|
||||||
typeParametersToKotlin() + implementTypesToKotlin() + SPACE + "{" + N +
|
typeParametersToKotlin() + implementTypesToKotlin() + SPACE + "{" + N +
|
||||||
AstUtil.joinNodes(membersExceptConstructors(), N) + N +
|
AstUtil.joinNodes(membersExceptConstructors(), N) + N +
|
||||||
primaryConstructorBodyToKotlin() + N +
|
(primaryConstructorBody.isEmpty() ? EMPTY : primaryConstructorBody + N) +
|
||||||
"public fun name() : String { return \"\" }" + N + // TODO : remove hack
|
|
||||||
"public fun order() : Int { return 0 }" + N +
|
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,4 @@ return color
|
|||||||
{
|
{
|
||||||
color = _color
|
color = _color
|
||||||
}
|
}
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,2 @@
|
|||||||
enum class A {
|
enum class A {
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,4 @@ FOO
|
|||||||
fun foo() : Unit {
|
fun foo() : Unit {
|
||||||
FOO.toString()
|
FOO.toString()
|
||||||
}
|
}
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,2 @@
|
|||||||
enum class A : I {
|
enum class A : I {
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,2 @@
|
|||||||
enum class A : I0, I1, I2 {
|
enum class A : I0, I1, I2 {
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
enum class E {
|
enum class E {
|
||||||
I
|
I
|
||||||
private var name : String? = null
|
private var name : String? = null
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,4 @@ return code
|
|||||||
{
|
{
|
||||||
code = c
|
code = c
|
||||||
}
|
}
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,2 @@
|
|||||||
enum class Test {
|
enum class Test {
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,4 @@ BLUE
|
|||||||
override fun toString() : String? {
|
override fun toString() : String? {
|
||||||
return "COLOR"
|
return "COLOR"
|
||||||
}
|
}
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,4 @@ return code
|
|||||||
{
|
{
|
||||||
code = c
|
code = c
|
||||||
}
|
}
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,2 @@
|
|||||||
private enum class Test {
|
private enum class Test {
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,2 @@
|
|||||||
protected enum class Test {
|
protected enum class Test {
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,2 @@
|
|||||||
public enum class Test {
|
public enum class Test {
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,4 @@ BLUE
|
|||||||
public override fun run() : Unit {
|
public override fun run() : Unit {
|
||||||
System.out?.println("name()=" + name() + ", toString()=" + toString())
|
System.out?.println("name()=" + name() + ", toString()=" + toString())
|
||||||
}
|
}
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,4 @@ PENNY
|
|||||||
NICKEL
|
NICKEL
|
||||||
DIME
|
DIME
|
||||||
QUARTER
|
QUARTER
|
||||||
public fun name() : String { return "" }
|
|
||||||
public fun order() : Int { return 0 }
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user