https://kotlinlang.org logo
p

Philip Dukhov

04/14/2021, 8:26 AM
Hello 👋 I’m using KotlinPoet, and can’t find one feature. In the IDE I can “Reformat file”, which will use all my code styles from settings, like indents, braces, ets. Is there a way to do the same with
FileSpec
?
j

jessewilson

04/14/2021, 8:37 AM
Nope. KotlinPoet emits files formatted well enough to be human readable, but we've decided it's not worth the code complexity or the runtime cost to do more
👌 1
Dagger 2 used to spend like 50% of it's time formatting the generated code and it was a bad tradeoff when a developer is waiting
👍 3
😮 1
p

Philip Dukhov

04/14/2021, 8:49 AM
thank you for such a detailed answer!
m

mbonnin

04/14/2021, 12:49 PM
I was thinking of the same thing and considering using ktlint or maybe Psi directly to reformat source after it's been generated by KotlinPoet. No idea how easy/hard that is but it feels theoretically doable.