-
Notifications
You must be signed in to change notification settings - Fork 439
Remove unnecessary casts in SyntaxRewriter #2119
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
Remove unnecessary casts in SyntaxRewriter #2119
Conversation
@@ -23,11 +23,11 @@ | |||
|
|||
open class SyntaxRewriter { | |||
public let viewMode: SyntaxTreeViewMode | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, a lot of these is just swift-format
508.0.1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swift-format
doesn't format generated code, so I think something went awry during the code generation process. Would you mind re-running the code generation to try to fix it?
Thank you, @natikgadzhi, for working on this! ❤️ |
I ran swift-format format Sources/SwiftSyntax/generated/SyntaxRewriter.swift —in-place manually.
Happy to generate without formatting through — my bad, I should have just ran format.py
|
359d684
to
6bfac1e
Compare
There! Much cleaner now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Thank you. So much cleaner. 🤩
We don’t manually format the generated files because the formatting will disappear the next time that you re-run CodeGeneration, which makes it hard to spot the modifications made by CodeGeneration. |
@swift-ci Please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @natikgadzhi 🙌
@swift-ci Please test |
This pull request removes unnecessary casts in
SyntaxRewriter
, i.e. funcs that look like this:become this:
It's more readable, and
visitChildren(node)
is guaranteed to return the same type asnode
anyway, so the cast is unnecessary. Thank you, @Matejkob, for filing the issue with pointers on how to get started!Closes #2102.
Disclaimer: I'm here to learn, and just making my first steps. Please feel free to "well, actually" me.
TODOs
SyntaxVisitor.visit
and pretty deep. But, they also crash for me on main. 👀