Skip to content

[Macros] Automatically format expanded macros #65450

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

Merged
merged 1 commit into from
Apr 28, 2023

Conversation

bnbarham
Copy link
Contributor

Rather than requiring macro implementations to add required whitespace and indentation, basic format all macro expansions. Right now this uses the default four space indentation, we can consider having that inferred later. Macros can opt-out of automatic formatting by implementing formatMode and setting it to .disabled.

Also moves the extra newlines before/after expansions to a new "Inline Macro" refactoring.

Resolves rdar://107731047.

@bnbarham bnbarham requested a review from DougGregor April 26, 2023 22:14
@bnbarham bnbarham force-pushed the format-macro-expansions branch from 980e45e to a3242ce Compare April 26, 2023 22:15
@bnbarham
Copy link
Contributor Author

swiftlang/swift-syntax#1591

@swift-ci please test

@bnbarham bnbarham force-pushed the format-macro-expansions branch from a3242ce to ee30220 Compare April 27, 2023 00:46
@ktoso
Copy link
Contributor

ktoso commented Apr 27, 2023

Random fly-by that I love this :-) ❤️

@bnbarham bnbarham force-pushed the format-macro-expansions branch from ee30220 to 07f7857 Compare April 27, 2023 01:39
@bnbarham
Copy link
Contributor Author

Random fly-by that I love this :-) ❤️

Heh, thanks :). Just to set expectations - this is in no way meant to be a complete format. It's mostly just to avoid having to manually add eg. required spaces. Basic indentation isn't too bad on top of that, so that's in there too.

@ktoso
Copy link
Contributor

ktoso commented Apr 27, 2023

Yeah that's already quite helpful :) Looks good!

@bnbarham
Copy link
Contributor Author

swiftlang/swift-syntax#1591

@swift-ci please test

@bnbarham bnbarham force-pushed the format-macro-expansions branch from 07f7857 to 8304410 Compare April 27, 2023 23:12
@bnbarham
Copy link
Contributor Author

swiftlang/swift-syntax#1591

@swift-ci please test

Rather than requiring macro implementations to add required whitespace
and indentation, basic format all macro expansions. Right now this uses
the default four space indentation, we can consider having that inferred
later. Macros can opt-out of automatic formatting by implementing
`formatMode` and setting it to `.disabled`.

Also moves the extra newlines before/after expansions to a new "Inline
Macro" refactoring.

Resolves rdar://107731047.
@bnbarham bnbarham force-pushed the format-macro-expansions branch from 8304410 to fe2104c Compare April 28, 2023 04:24
@bnbarham
Copy link
Contributor Author

swiftlang/swift-syntax#1591

@swift-ci please test

@bnbarham bnbarham merged commit 38f2e6c into swiftlang:main Apr 28, 2023
@bnbarham bnbarham deleted the format-macro-expansions branch April 28, 2023 23: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.

4 participants