-
Notifications
You must be signed in to change notification settings - Fork 440
Replace expression in ClosureCaptureSyntax
with initializer clause
#2763
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
ahoppen
merged 7 commits into
swiftlang:main
from
MAJKFL:closure-capture-syntax-node-update
Aug 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
22347b8
Adjust closure capture syntax node.
MAJKFL d5bbac9
Bring back the convenience initializer and deprecate it. Add entries …
MAJKFL abc705f
Add deprecated signatures to `SwiftSyntaxCompatibility.swift`. Adjust…
MAJKFL 2984ad8
Format.
MAJKFL 612109f
Add `self` keyword as a possible name kind in ClosureCaptureSyntax.
MAJKFL 98f40b1
Merge branch 'main' into closure-capture-syntax-node-update
MAJKFL e3f6436
Fix failing inconsistent initializer naming test.
MAJKFL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1167,73 +1167,6 @@ extension ClassDeclSyntax { | |
} | ||
} | ||
|
||
extension ClosureCaptureSyntax { | ||
@available(*, deprecated, renamed: "unexpectedBetweenNameAndEqual") | ||
public var unexpectedBetweenNameAndAssignToken: UnexpectedNodesSyntax? { | ||
get { | ||
return unexpectedBetweenNameAndEqual | ||
} | ||
set { | ||
unexpectedBetweenNameAndEqual = newValue | ||
} | ||
} | ||
|
||
@available(*, deprecated, renamed: "equal") | ||
public var assignToken: TokenSyntax? { | ||
get { | ||
return equal | ||
} | ||
set { | ||
equal = newValue | ||
} | ||
} | ||
|
||
@available(*, deprecated, renamed: "unexpectedBetweenEqualAndExpression") | ||
public var unexpectedBetweenAssignTokenAndExpression: UnexpectedNodesSyntax? { | ||
get { | ||
return unexpectedBetweenEqualAndExpression | ||
} | ||
set { | ||
unexpectedBetweenEqualAndExpression = newValue | ||
} | ||
} | ||
|
||
@available(*, deprecated, renamed: "ClosureCaptureSyntax(leadingTrivia:_:specifier:_:name:_:equal:_:expression:_:trailingComma:_:trailingTrivia:)") | ||
@_disfavoredOverload | ||
public init( | ||
leadingTrivia: Trivia? = nil, | ||
_ unexpectedBeforeSpecifier: UnexpectedNodesSyntax? = nil, | ||
specifier: ClosureCaptureSpecifierSyntax? = nil, | ||
_ unexpectedBetweenSpecifierAndName: UnexpectedNodesSyntax? = nil, | ||
name: TokenSyntax? = nil, | ||
_ unexpectedBetweenNameAndAssignToken: UnexpectedNodesSyntax? = nil, | ||
assignToken: TokenSyntax? = nil, | ||
_ unexpectedBetweenAssignTokenAndExpression: UnexpectedNodesSyntax? = nil, | ||
expression: some ExprSyntaxProtocol, | ||
_ unexpectedBetweenExpressionAndTrailingComma: UnexpectedNodesSyntax? = nil, | ||
trailingComma: TokenSyntax? = nil, | ||
_ unexpectedAfterTrailingComma: UnexpectedNodesSyntax? = nil, | ||
trailingTrivia: Trivia? = nil | ||
|
||
) { | ||
self.init( | ||
leadingTrivia: leadingTrivia, | ||
unexpectedBeforeSpecifier, | ||
specifier: specifier, | ||
unexpectedBetweenSpecifierAndName, | ||
name: name, | ||
unexpectedBetweenNameAndAssignToken, | ||
equal: assignToken, | ||
unexpectedBetweenAssignTokenAndExpression, | ||
expression: expression, | ||
unexpectedBetweenExpressionAndTrailingComma, | ||
trailingComma: trailingComma, | ||
unexpectedAfterTrailingComma, | ||
trailingTrivia: trailingTrivia | ||
) | ||
} | ||
} | ||
|
||
Comment on lines
-1170
to
-1236
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. People might still be relying on these compatibility overloads, so we shouldn’t remove them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added those to |
||
extension ClosureParameterClauseSyntax { | ||
@available(*, deprecated, renamed: "unexpectedBetweenLeftParenAndParameters") | ||
public var unexpectedBetweenLeftParenAndParameterList: UnexpectedNodesSyntax? { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You should be able to hoist the parsing of
name
out of theif
statement and then useself.at(.equal)
instead ofself.peek(isAt: .equal)
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 for the suggestion. I moved name parsing to before the
if
statement.As an interesting artifact,
self
token will not be remapped toidentifier
when parsing capture of[self = 123]
form. Out of curiosity, was there a particular reason for this remapping? As far as I checked, e.g. inlet self = 123
self
is classified as a keyword.