@@ -14,6 +14,7 @@ import com.squareup.kotlinpoet.PropertySpec
1414import com.squareup.kotlinpoet.TypeSpec
1515import com.squareup.kotlinpoet.asClassName
1616import com.squareup.kotlinpoet.asTypeName
17+ import com.squareup.kotlinpoet.buildCodeBlock
1718import io.github.typesafegithub.workflows.actionbindinggenerator.domain.ActionCoords
1819import io.github.typesafegithub.workflows.actionbindinggenerator.domain.MetadataRevision
1920import io.github.typesafegithub.workflows.actionbindinggenerator.domain.TypingActualSource
@@ -471,15 +472,16 @@ private fun Metadata.buildCommonConstructorParameters(
471472 .flatMap { (key, input) ->
472473 val typedInput = inputTypings.containsKey(key)
473474 val description = input.description.escapedForComments.removeTrailingWhitespacesForEachLine()
474- val kdocBuilder = CodeBlock .builder()
475- if (typedInput && ! untypedClass && input.shouldBeRequiredInBinding()) {
476- kdocBuilder.add(" %L" , " <required>" .escapedForComments)
477- if (description.isNotEmpty()) {
478- kdocBuilder.add(" " )
475+ val kdoc =
476+ buildCodeBlock {
477+ if (typedInput && ! untypedClass && input.shouldBeRequiredInBinding()) {
478+ add(" %L" , " <required>" .escapedForComments)
479+ if (description.isNotEmpty()) {
480+ add(" " )
481+ }
482+ }
483+ add(" %L" , description)
479484 }
480- }
481- kdocBuilder.add(" %L" , description)
482- val kdoc = kdocBuilder.build()
483485
484486 listOfNotNull(
485487 untypedClass.takeIf { ! it && typedInput }?.let {
@@ -545,19 +547,18 @@ private fun TypeSpec.Builder.addInitializerBlockIfNecessary(
545547 return this
546548}
547549
548- private fun Metadata.initializerBlock (inputTypings : Map <String , Typing >): CodeBlock {
549- val codeBlockBuilder = CodeBlock .builder()
550- var first = true
551- inputs
552- .filter { inputTypings.containsKey(it.key) }
553- .forEach { (key, input) ->
554- if (! first) {
555- codeBlockBuilder.add(" \n " )
556- }
557- first = false
558- val propertyName = key.toCamelCase()
559- codeBlockBuilder
560- .add(
550+ private fun Metadata.initializerBlock (inputTypings : Map <String , Typing >) =
551+ buildCodeBlock {
552+ var first = true
553+ inputs
554+ .filter { inputTypings.containsKey(it.key) }
555+ .forEach { (key, input) ->
556+ if (! first) {
557+ add(" \n " )
558+ }
559+ first = false
560+ val propertyName = key.toCamelCase()
561+ add(
561562 """
562563 require(!((%1N != null) && (%1L_Untyped != null))) {
563564 %2S
@@ -567,9 +568,8 @@ private fun Metadata.initializerBlock(inputTypings: Map<String, Typing>): CodeBl
567568 propertyName,
568569 " Only $propertyName or ${propertyName} _Untyped must be set, but not both" ,
569570 )
570- if (input.shouldBeRequiredInBinding()) {
571- codeBlockBuilder
572- .add(
571+ if (input.shouldBeRequiredInBinding()) {
572+ add(
573573 """
574574 require((%1N != null) || (%1L_Untyped != null)) {
575575 %2S
@@ -579,10 +579,9 @@ private fun Metadata.initializerBlock(inputTypings: Map<String, Typing>): CodeBl
579579 propertyName,
580580 " Either $propertyName or ${propertyName} _Untyped must be set, one of them is required" ,
581581 )
582+ }
582583 }
583- }
584- return codeBlockBuilder.build()
585- }
584+ }
586585
587586private fun actionKdoc (
588587 metadata : Metadata ,
0 commit comments