-
Notifications
You must be signed in to change notification settings - Fork 440
Add convenience initializers for simple expr values #288
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 convenience initializers for simple expr values #288
Conversation
e7de2af
to
7b3a8a3
Compare
Sources/SwiftSyntaxBuilder/IntegerLiteralExprConvenienceInitializers.swift
Outdated
Show resolved
Hide resolved
3dc69f8
to
075708a
Compare
Sources/SwiftSyntaxBuilder/ExprConvenienceInitializers.swift.gyb
Outdated
Show resolved
Hide resolved
2fa8c38
to
d7d87aa
Compare
It’s not directly related to this PR, but I felt a bit uneasy about the
I think 1. should already be implemented in Regarding 2. and 3., I think it’s reasonable that we only provide an initializer that applies all optimizations and ignore use cases where a user might want to initialize a token by a string but not use the result builder. This is what we are doing already. And just so recap, we need to be careful not to create a convenience initializer if neither 2. nor 3. apply because then we’re redeclaring the initializer defined in Long story short, I think the following changes would make the implementation more streamlined and easier to understand:
Does this make sense to you @kimdv? |
I thinks it makes sense yes! |
68cd060
to
ba7c530
Compare
@ahoppen I think I made what you wrote. I can split change in The helper method is put in this PR: swiftlang/swift#37712 |
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.
This is looking very good overall. I’ve added a few remarks/questions inline.
Sources/SwiftSyntaxBuilder/BuildablesConvenienceInitializers.swift.gyb
Outdated
Show resolved
Hide resolved
Sources/SwiftSyntaxBuilder/BuildablesConvenienceInitializers.swift.gyb
Outdated
Show resolved
Hide resolved
Sources/SwiftSyntaxBuilder/BuildablesConvenienceInitializers.swift.gyb
Outdated
Show resolved
Hide resolved
ba7c530
to
72463ed
Compare
@ahoppen I have resolved your comment and pushed. |
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.
I’ve got a few suggestions on the wording for comments inline, otherwise looks good to me!
Sources/SwiftSyntaxBuilder/BuildablesConvenienceInitializers.swift.gyb
Outdated
Show resolved
Hide resolved
Sources/SwiftSyntaxBuilder/BuildablesConvenienceInitializers.swift.gyb
Outdated
Show resolved
Hide resolved
72463ed
to
58fa415
Compare
@ahoppen I have pushed the suggested changes. Also rebased swiftlang/swift#37712 with latest main Happy WWDC days! 🎉 |
Same to you! swiftlang/swift#37712 |
I have tried to make some initializers for the types I thought would be helpfull.
I could also try to generate all Expr that have a Keyword in the init parameter like NilLiteralExpr
Something like