New J2K: Render list separator as function
This commit is contained in:
committed by
Ilya Kirillov
parent
7af03c2859
commit
9a1e5582b6
@@ -177,12 +177,14 @@ class NewCodeBuilder {
|
||||
)
|
||||
}
|
||||
|
||||
private inline fun <T> renderList(list: List<T>, separator: String = ", ", renderElement: (T) -> Unit) =
|
||||
renderList(list, { printer.printWithNoIndent(separator) }, renderElement)
|
||||
|
||||
private inline fun <T> renderList(list: List<T>, separator: String = ", ", renderElement: (T) -> Unit) {
|
||||
private inline fun <T> renderList(list: List<T>, separator: () -> Unit, renderElement: (T) -> Unit) {
|
||||
val (head, tail) = list.headTail()
|
||||
head?.let(renderElement) ?: return
|
||||
tail?.forEach {
|
||||
builder.append(separator)
|
||||
separator()
|
||||
renderElement(it)
|
||||
}
|
||||
}
|
||||
@@ -343,7 +345,7 @@ class NewCodeBuilder {
|
||||
private fun renderStatementOrBlock(statement: JKStatement, multiline: Boolean = false) {
|
||||
if (statement is JKBlockStatement) {
|
||||
printer.block(multiline) {
|
||||
statement.block.statements.forEach { it.accept(this) }
|
||||
statement.block.accept(this)
|
||||
}
|
||||
} else {
|
||||
statement.accept(this)
|
||||
|
||||
Reference in New Issue
Block a user