Skip to content

Remove XXXRawSyntax.withYYY() methods #1048

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
Nov 3, 2022

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Nov 3, 2022

This should save some code size.

This should save some code size.
@rintaro rintaro requested a review from ahoppen as a code owner November 3, 2022 00:19
@rintaro
Copy link
Member Author

rintaro commented Nov 3, 2022

@swift-ci Please test

@rintaro rintaro requested a review from CodaFi November 3, 2022 00:20
@@ -167,7 +167,13 @@ extension Parser {
arena: parser.arena)
} addSemicolonIfNeeded: { lastElement, newItemAtStartOfLine, parser in
if lastElement.semicolon == nil && !newItemAtStartOfLine {
return lastElement.withSemicolon(parser.missingToken(.semicolon, text: nil), arena: parser.arena)
Copy link
Contributor

@bnbarham bnbarham Nov 3, 2022

Choose a reason for hiding this comment

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

Totally fine with this change for now. But one thing I was thinking of... What if we instead had just a single .with that takes the previous node + optional params + leading/trailing trivia? For both the red + green tree. Then this would be eg.

return RawMemberDeclListItemSyntax(lastElement, semicolon: parser.missingToken(.semicolon, text: nil)))

EDIT: Actually, thinking about this more - it's probably not worth it for the green tree. We really shouldn't be modifying them very much (ideally not at all but... 🤷). So for the green tree we'd just have the initializers (no with's) and for the red tree each would have a single .with(...).

@rintaro rintaro merged commit 41da025 into swiftlang:main Nov 3, 2022
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.

3 participants