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

Add option to add a newline between 2 adjacent attributes #784

Merged
merged 2 commits into from
Aug 1, 2024

Conversation

dduan
Copy link
Contributor

@dduan dduan commented Jul 28, 2024

Add an option that inserts hard line breaks between adjacent attributes.

Closes #773

@dduan dduan marked this pull request as draft July 29, 2024 17:29
@dduan dduan marked this pull request as ready for review July 29, 2024 17:31
@dduan dduan force-pushed the dd/newline-between-attrs branch 2 times, most recently from 33ebf17 to b855621 Compare July 29, 2024 17:34
@allevato
Copy link
Member

I think we would only want this behavior for declaration attributes, because it would be heavy-handed on type attributes. For example, how does your current implementation handle this case?

func f(body: @MainActor @Sendable () -> Void) {}

We should definitely keep those horizontally flowing, IMO.

Can you add some tests for that case, and also some tests that use attributes in conditional #if ... blocks, just to make sure we don't break anything there?

@dduan
Copy link
Contributor Author

dduan commented Jul 30, 2024

makes sense. I'll give it a go!

@dduan dduan marked this pull request as draft July 30, 2024 19:06
@dduan dduan marked this pull request as ready for review July 31, 2024 00:31
@dduan
Copy link
Contributor Author

dduan commented Jul 31, 2024

@allevato I took your suggestion and expanded the unit test to cover a lot more node types.

@dduan dduan requested a review from allevato July 31, 2024 16:04
Add an option that inserts hard line breaks between adjacent attributes.

Closes swiftlang#773
@dduan
Copy link
Contributor Author

dduan commented Jul 31, 2024

@allevato thanks for the feedbacks! I've addressed them.

@allevato
Copy link
Member

allevato commented Aug 1, 2024

Thanks!

@allevato allevato merged commit 992d2c6 into swiftlang:main Aug 1, 2024
@dduan dduan deleted the dd/newline-between-attrs branch August 3, 2024 18:29
thunderseethe pushed a commit to thunderseethe/swift-format that referenced this pull request Aug 13, 2024
)

Add an option that inserts hard line breaks between adjacent attributes.
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.

Rule for putting annotations into separate lines
2 participants