Open
Description
Describe the bug
When I use .callThisConstructor to have one constructor call another one, it looks formatting was forgotten.
To Reproduce
TypeSpec.classBuilder("HelloWorld")
.addFunction(
FunSpec.constructorBuilder()
.addParameter("x".repeat(30), String::class)
.addParameter("y".repeat(30), String::class)
.callThisConstructor(
CodeBlock.of("x".repeat(30)),
CodeBlock.of("y".repeat(30)),
CodeBlock.of("x".repeat(30)),
CodeBlock.of("y".repeat(30)),
buildCodeBlock {
beginControlFlow("thisIsAMethodThatUsesALambdaAndReturnsSomethingForTheConstructor")
addStatement("z".repeat(30) + "()")
endControlFlow()
}
)
.build()
)
.build()
)
.build()
.writeTo(System.out)
This prints:
package com.test
import kotlin.String
public class HelloWorld {
public constructor(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: String, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy: String)
: this(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
thisIsAMethodThatUsesALambdaAndReturnsSomethingForTheConstructor {
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz()
}
)
}
If this() is counted as the 1st line, then the 2nd and 3rd lines are aligned vertically with the colon but they should be more indented than that, because the this() call opened a new nesting level like it was a statement call. And what follows inside the method call in the 4th and 5th lines should be indented even more but it's actually going backwards.
Activity