Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter wrapping logic for long parameter lists #281

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Egorand
Copy link
Collaborator

@Egorand Egorand commented Nov 14, 2017

Fixes #274

.addStatement("return %T", Unit::class)
.build()
assertThat(source.toString()).isEqualTo("""
|fun veryLongFunctionName(
Copy link
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
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
Copy link
Collaborator Author

Egorand commented Dec 1, 2017

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

@JakeWharton
Copy link
Member

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

@Egorand
Copy link
Collaborator Author

Egorand commented Dec 15, 2017

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
Member

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
Copy link
Collaborator Author

Egorand commented Dec 15, 2017

Can do

@Egorand
Copy link
Collaborator Author

Egorand commented Dec 23, 2017

Fixes #291

@gilgoldzweig
Copy link

Any updates on this request?

@Egorand
Copy link
Collaborator Author

Egorand commented Dec 5, 2018

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

@gilgoldzweig
Copy link

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

@Egorand
Copy link
Collaborator Author

Egorand commented Dec 5, 2018

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
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.

None yet

3 participants