kotlinpoet icon indicating copy to clipboard operation
kotlinpoet copied to clipboard

Smarter wrapping logic for long parameter lists

Open Egorand opened this issue 8 years ago • 10 comments

Fixes #274

Egorand avatar Nov 14 '17 10:11 Egorand

I think I'll update this PR to cover #291 as well. Any feedback here so far?

Egorand avatar Dec 01 '17 21:12 Egorand

I certainly like the results. When do you emit a parameter spec with wrapping=False?

JakeWharton avatar Dec 15 '17 22:12 JakeWharton

When you've got a parameterized LambdaTypeName as the type of the param:

fun veryLongFunctionName(
        veryLongParameterName: (java.io.Serializable, java.lang.Appendable, kotlin.Cloneable) -> kotlin.Unit,
        i: kotlin.Int
) = kotlin.Unit

Egorand avatar Dec 15 '17 22:12 Egorand

Ah, nice. I think I'd prefer if we flipped the boolean so that it wraps by default and we opt-out only in the lambda special case.

JakeWharton avatar Dec 15 '17 22:12 JakeWharton

Can do

Egorand avatar Dec 15 '17 22:12 Egorand

Fixes #291

Egorand avatar Dec 23 '17 17:12 Egorand

Any updates on this request?

gilgoldzweig avatar Dec 05 '18 18:12 gilgoldzweig

@gilgoldzweig we'll most likely go with a solution for #532, which should handle this use-case as well.

Egorand avatar Dec 05 '18 19:12 Egorand

Cool, is there any way to make it work now?

gilgoldzweig avatar Dec 05 '18 20:12 gilgoldzweig

There's no workaround unfortunately, but if your function/constructor has more than 2 parameters we'll auto-wrap it.

Egorand avatar Dec 05 '18 20:12 Egorand