Skip to content
New issue

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

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

Already on GitHub? # to your account

Lint and format context receiver #1693

Merged

Conversation

paul-dingemans
Copy link
Collaborator

Description

Change indent rule to accodomodate for the context receiver list. Add new rule content-receiver-wrapping to wrap a context receiver to a separate line regardless of the max line length setting, and, wrap context receiver and type projections to separate lines when max line length is exceeded.

Some example of code after auto correct:

    // ALways wrap regardless of whether max line length is set
    context(Foo)
    fun fooBar()

    // Wrap each context receiver to a separate line when the
    // entire context receiver list does not fit on a single line
    context(
        Fooooooooooooooooooo1,
        Foooooooooooooooooooooooooooooo2
    )
    fun fooBar()

    // Wrap each context receiver to a separate line when the
    // entire context receiver list does not fit on a single line.
    // Also, wrap each of it projection types in case a context
    // receiver does not fit on a single line after it has been
    // wrapped.
    context(
        Foooooooooooooooo<
            Foo,
            Bar
            >
    )
    fun fooBar()

Closes #1672

Checklist

  • PR description added
  • tests are added
  • KtLint has been applied on source code itself and violations are fixed
  • documentation is updated
  • CHANGELOG.md is updated

In case of adding a new rule:

@paul-dingemans paul-dingemans added this to the 0.48.0 milestone Nov 2, 2022
@paul-dingemans paul-dingemans merged commit cf1d7b5 into pinterest:master Nov 5, 2022
@paul-dingemans paul-dingemans deleted the 1672-context-receiver branch November 5, 2022 12:21
@chao2zhang
Copy link
Contributor

Thank you! I will test in my repositories and report back if there are any edge cases

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Styling for context receiver
2 participants