extension function for converting a list of elements
This commit is contained in:
committed by
Pavel V. Talanov
parent
dd09affd9c
commit
d66b5e32f9
@@ -11,7 +11,7 @@ public open class Block(val statements: List<Statement>, val notEmpty: Boolean =
|
||||
|
||||
public override fun toKotlin(): String {
|
||||
if (!isEmpty()) {
|
||||
return "{\n" + AstUtil.joinNodes(statements, "\n") + "\n}"
|
||||
return "{\n" + statements.toKotlin("\n") + "\n}"
|
||||
}
|
||||
|
||||
return ""
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.jetbrains.jet.j2k.ast
|
||||
|
||||
import java.util.List
|
||||
|
||||
fun List<out Node>.toKotlin(separator: String): String {
|
||||
val result = StringBuilder()
|
||||
for(x in this) {
|
||||
if (result.length() > 0) result.append(separator)
|
||||
result.append(x.toKotlin())
|
||||
}
|
||||
return result.toString()!!
|
||||
}
|
||||
Reference in New Issue
Block a user