https://kotlinlang.org logo
Title
j

jw

01/16/2023, 6:41 PM
if you use non-breaking spaces (https://square.github.io/kotlinpoet/#spaces-wrap-by-default) everywhere on your first line it should/might wrap after the equals sign
l

Lamberto Basti

01/16/2023, 6:43 PM
Oh wow thanks! Also, the indentation afterwards is kinda weird:
context(Transaction)
public fun TestTable.updateTestTableById(parameter: Int, dto: TestTableDTO): Int =
    update({ id eq parameter }) { statement ->
  statement[id] = requireNotNull(dto.id) { "TestTableDTO.$id is null" }
  statement[name] = requireNotNull(dto.name) { "TestTableDTO.$name is null" }
  statement[surname] = dto.surname
  statement[aLong] = requireNotNull(dto.aLong) { "TestTableDTO.$aLong is null" }
}
is there a way to reindent correctly?
j

jw

01/16/2023, 6:43 PM
Unfortunately, no
l

Lamberto Basti

01/16/2023, 6:43 PM
Alright, thanks anyway 🙂
j

jw

01/16/2023, 6:44 PM
If you care deeply about the generated code's format we recommend post-processing with a formatter like IntelliJ or ktlint
l

Lamberto Basti

01/16/2023, 6:44 PM
Indeed that is what I am going to do! I will postprocess the generated code with klint i believe
j

jessewilson

01/16/2023, 9:31 PM
I recommend rewriting your generated code to be less dense, and to skip ktlint. That way your builds will be faster and your line wrapping won’t be that bad.
Adding ktlint to run at the end of KotlinPoet is often the source of slow builds; or at least that was the case for Dagger
(their problem was JavaPoet + Google Java Format, but the performance problem had the same structure. Formatting generated code while the user is waiting on a build isn’t great)