Skip to content

Smarter wrapping logic for long parameter lists - #281

Open
Egorand wants to merge 3 commits into
mainfrom
egorand/param-list-wrapping
Open

Smarter wrapping logic for long parameter lists#281
Egorand wants to merge 3 commits into
mainfrom
egorand/param-list-wrapping

Conversation

@Egorand

@Egorand Egorand commented Nov 14, 2017

Copy link
Copy Markdown
Collaborator

Fixes #274

.addStatement("return %T", Unit::class)
.build()
assertThat(source.toString()).isEqualTo("""
|fun veryLongFunctionName(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the style guide says about that, but having nested wrapping felt like an overkill. Hence, lambda types as function parameters are always single-line, even if they wrap.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior should also be consistent with the discussion on #256: we don't wrap the lambda parameters, but we do wrap the function parameters.

@Egorand

Egorand commented Dec 1, 2017

Copy link
Copy Markdown
Collaborator Author

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

@JakeWharton

Copy link
Copy Markdown
Collaborator

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

@Egorand

Egorand commented Dec 15, 2017

Copy link
Copy Markdown
Collaborator Author

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

@JakeWharton

Copy link
Copy Markdown
Collaborator

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.

@Egorand

Egorand commented Dec 15, 2017

Copy link
Copy Markdown
Collaborator Author

Can do

@Egorand
Egorand force-pushed the egorand/param-list-wrapping branch from e91ebae to a5e5eb0 Compare December 15, 2017 23:15
@Egorand
Egorand force-pushed the egorand/param-list-wrapping branch from a5e5eb0 to 09a1c92 Compare December 23, 2017 17:01
@Egorand

Egorand commented Dec 23, 2017

Copy link
Copy Markdown
Collaborator Author

Fixes #291

@gilgoldzweig

Copy link
Copy Markdown

Any updates on this request?

@Egorand

Egorand commented Dec 5, 2018

Copy link
Copy Markdown
Collaborator Author

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

@gilgoldzweig

Copy link
Copy Markdown

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

@Egorand

Egorand commented Dec 5, 2018

Copy link
Copy Markdown
Collaborator Author

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

@Egorand
Egorand changed the base branch from master to main July 5, 2023 09:21
@serranojoanna2025-commits

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve wrapping logic of parameter lists

4 participants