Skip to content

Commit

Permalink
Update CodeBlock.kt
Browse files Browse the repository at this point in the history
Co-authored-by: Zongle Wang <wangzongler@gmail.com>
  • Loading branch information
egorikftp and Goooler committed Jul 25, 2024
1 parent 8bc7afc commit 5471c3a
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,17 @@ import com.squareup.kotlinpoet.CodeBlock
fun CodeBlock.Builder.argumentBlock(
argumentFlow: String,
vararg args: Any?,
isNested: Boolean = false,
block: CodeBlock.Builder.() -> Unit,
) {
add("$argumentFlow\n", *args)
indention(block)
newLine()
add(")")
}

fun CodeBlock.Builder.nestedArgumentBlock(
argumentFlow: String,
vararg args: Any?,
block: CodeBlock.Builder.() -> Unit,
) {
add("$argumentFlow\n", *args)
indention(block)
newLine()
add("),")
newLine()
if (isNested) {
add(",")
newLine()
}
}

fun CodeBlock.Builder.indention(block: CodeBlock.Builder.() -> Unit) {
Expand Down

0 comments on commit 5471c3a

Please sign in to comment.