Add a convenience init to ClosureCaptureSyntax#2127
Conversation
ahoppen
left a comment
There was a problem hiding this comment.
Could you add an entry for this PR and #2112 to the new release notes file https://github.com/apple/swift-syntax/blob/main/Release%20Notes/510.md?
Provides release notes entries for: - `ClosureCaptureSyntax.init` swiftlang#2127 - `EnumCaseParameterSyntax.init` swiftlang#2112
|
@swift-ci please test |
Matejkob
left a comment
There was a problem hiding this comment.
Thanks for the updates—great work! My internal nitpick radar 📡 kicked in, so I've left a few comments. Not sure how helpful they are, but there you go! 🙈
Release Notes/510.md
Outdated
| - `ClosureCaptureSyntax.init(leadingTrivia: Trivia? = nil, specifier: ClosureCaptureSpecifierSyntax? = nil, name: TokenSyntax, equal: TokenSyntax = TokenSyntax.equalToken(), expression: some ExprSyntaxProtocol, trailingComma: TokenSyntax? = nil, trailingTrivia: Trivia? = nil)` | ||
| - Description: Provides a convenience initializer for `ClosureCaptureSyntax` that takes a concrete `name` argument and automatically adds `equal = TokenSyntax.equalToken()` to it. | ||
| - Pull Request: https://github.com/apple/swift-syntax/pull/2127 | ||
| - `EnumCaseParameterSyntax.init(leadingTrivia: Trivia? = nil, modifiers: DeclModifierListSyntax = [], firstName: TokenSyntax, secondName: TokenSyntax? = nil, colon: TokenSyntax = TokenSyntax.colonToken(), type: some TypeSyntaxProtocol, defaultValue: InitializerClauseSyntax? = nil, trailingComma: TokenSyntax? = nil, trailingTrivia: Trivia? = nil)` | ||
| - Description: Provides a convenience initializer for `EnumCaseParameterSyntax` that takes a concrete `firstName` value and adds `colon = TokenSyntax.colonToken()` automatically to it. | ||
| - Pull Request: https://github.com/apple/swift-syntax/pull/2112 |
There was a problem hiding this comment.
The issue related to these changes contains important information about the new APIs. I would consider adding a link to it, as stated in the template below. What do you think about it?
| - `ClosureCaptureSyntax.init(leadingTrivia: Trivia? = nil, specifier: ClosureCaptureSpecifierSyntax? = nil, name: TokenSyntax, equal: TokenSyntax = TokenSyntax.equalToken(), expression: some ExprSyntaxProtocol, trailingComma: TokenSyntax? = nil, trailingTrivia: Trivia? = nil)` | |
| - Description: Provides a convenience initializer for `ClosureCaptureSyntax` that takes a concrete `name` argument and automatically adds `equal = TokenSyntax.equalToken()` to it. | |
| - Pull Request: https://github.com/apple/swift-syntax/pull/2127 | |
| - `EnumCaseParameterSyntax.init(leadingTrivia: Trivia? = nil, modifiers: DeclModifierListSyntax = [], firstName: TokenSyntax, secondName: TokenSyntax? = nil, colon: TokenSyntax = TokenSyntax.colonToken(), type: some TypeSyntaxProtocol, defaultValue: InitializerClauseSyntax? = nil, trailingComma: TokenSyntax? = nil, trailingTrivia: Trivia? = nil)` | |
| - Description: Provides a convenience initializer for `EnumCaseParameterSyntax` that takes a concrete `firstName` value and adds `colon = TokenSyntax.colonToken()` automatically to it. | |
| - Pull Request: https://github.com/apple/swift-syntax/pull/2112 | |
| - `ClosureCaptureSyntax.init(leadingTrivia: Trivia? = nil, specifier: ClosureCaptureSpecifierSyntax? = nil, name: TokenSyntax, equal: TokenSyntax = TokenSyntax.equalToken(), expression: some ExprSyntaxProtocol, trailingComma: TokenSyntax? = nil, trailingTrivia: Trivia? = nil)` | |
| - Description: Provides a convenience initializer for `ClosureCaptureSyntax` that takes a concrete `name` argument and automatically adds `equal = TokenSyntax.equalToken()` to it. | |
| - Issue: https://github.com/apple/swift-syntax/issues/1984 | |
| - Pull Request: https://github.com/apple/swift-syntax/pull/2127 | |
| - `EnumCaseParameterSyntax.init(leadingTrivia: Trivia? = nil, modifiers: DeclModifierListSyntax = [], firstName: TokenSyntax, secondName: TokenSyntax? = nil, colon: TokenSyntax = TokenSyntax.colonToken(), type: some TypeSyntaxProtocol, defaultValue: InitializerClauseSyntax? = nil, trailingComma: TokenSyntax? = nil, trailingTrivia: Trivia? = nil)` | |
| - Description: Provides a convenience initializer for `EnumCaseParameterSyntax` that takes a concrete `firstName` value and adds `colon = TokenSyntax.colonToken()` automatically to it. | |
| - Issue: https://github.com/apple/swift-syntax/issues/1984 | |
| - Pull Request: https://github.com/apple/swift-syntax/pull/2112 |
There was a problem hiding this comment.
Yes, I think linking the issue would be valuable.
Also, I think the full API signature isn’t that enlightening. What I would do instead is name the items
ClosureCaptureSyntax.initwith a requirednameEnumCaseParameterSyntax.initwith a requiredfirstName
There was a problem hiding this comment.
How about incorporating release notes into the DocC documentation for SwiftSyntax package? With this approach, it would be really easy to add direct links to specific methods right in the code.
There was a problem hiding this comment.
The problem is that we would need to decide which module to put the release notes in. If we put it in the SwiftSyntax module, you can’t link to any API in e.g. SwiftParser. Since the release notes are for the entire package and not one specific module, I think having them at a top-level makes sense for now.
There was a problem hiding this comment.
I wasn't aware of this restriction that you can't link to any API from a different target. That's unfortunate. :/
There was a problem hiding this comment.
FWIW swiftlang/swift-docc#208 is tracking this restriction.
There was a problem hiding this comment.
Thank you both for the review! I'll clean up the changelog for now. Hopefully, I can get a generator-based version quickly enough and clean them up altogether in a few days.
**Summary** This adds a convenience init to ClosureCaptureSyntax that adds equal token if the provided `name` is not nil. It's supposed to be used by developers, so it omits the unexpected tokens. Related: swiftlang#1984
Provides release notes entries for: - `ClosureCaptureSyntax.init` swiftlang#2127 - `EnumCaseParameterSyntax.init` swiftlang#2112 Co-authored-by: Mateusz Bąk <bakmatthew@icloud.com>
4d6c9b0 to
440b6da
Compare
Provides release notes entries for: - `ClosureCaptureSyntax.init` swiftlang#2127 - `EnumCaseParameterSyntax.init` swiftlang#2112 Co-authored-by: Mateusz Bąk <bakmatthew@icloud.com>
440b6da to
a9acb00
Compare
|
Alright! Should be good to go for this PR. |
|
@swift-ci Please test |
|
@swift-ci Please test Windows |
|
@swift-ci Please test macOS |
|
@swift-ci Please test Windows |
Summary
This adds a convenience
inittoClosureCaptureSyntaxthat adds anequaltoken if the providednameis not nil.It's supposed to be used by developers, so it omits the unexpected tokens.
Related: #1984