Skip to content

Add default leading and trailing trivia to tokens from Format #651

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
Aug 31, 2022

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Aug 29, 2022

This frees TokenSyntax from any implicit formatting and sinks all formatting logic into the Format type for a clearer separation of concerns.

@ahoppen ahoppen requested a review from fwcd August 29, 2022 15:02
@ahoppen
Copy link
Member Author

ahoppen commented Aug 29, 2022

@swift-ci Please test

Copy link
Member

@fwcd fwcd left a comment

Choose a reason for hiding this comment

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

Looks good, a minor stylistic note below.

The only thing that I am a bit concerned about is that this regresses generation time slightly (9 s on main vs 12 s on this branch, with a debug build on my machine), probably due to the additional withXTrivia calls. Since token generation is usually on the hot path and happens pretty often, even small changes can have an impact there.

In any case that is probably for another PR.

}
}

func createWithLeadingWithTrailingTriviaCall(token: TokenSpec) -> CodeBlockItem {
Copy link
Member

@fwcd fwcd Aug 29, 2022

Choose a reason for hiding this comment

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

Can we make this private?

Suggested change
func createWithLeadingWithTrailingTriviaCall(token: TokenSpec) -> CodeBlockItem {
private func createWithLeadingWithTrailingTriviaCall(token: TokenSpec) -> CodeBlockItem {

This frees `TokenSyntax` from any implicit formatting and sinks all formatting logic into the `Format` type for a clearer separation of concerns.
@ahoppen ahoppen force-pushed the ahoppen/token-format branch from 3b2e747 to f5e146e Compare August 30, 2022 07:03
@ahoppen
Copy link
Member Author

ahoppen commented Aug 30, 2022

@swift-ci Please test

1 similar comment
@ahoppen
Copy link
Member Author

ahoppen commented Aug 31, 2022

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Aug 31, 2022

@swift-ci Please test macOS

@ahoppen ahoppen merged commit 6f30831 into swiftlang:main Aug 31, 2022
@ahoppen ahoppen deleted the ahoppen/token-format branch August 31, 2022 21:01
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.

2 participants