- Summary:
ExpandEditorPlaceholdersToLiteralClosures
&CallToTrailingClosures
now take aSyntax
parameter and returnSyntax?
to satisfy the conformance toSyntaxRefactoringProvider
. If a non-function-like syntax node is passed,nil
is returned. The previousFunctionCallExprSyntax
overloads are deprecated. This allows the refactorings to correctly handle macro expansion expressions and declarations. - Link to PR: Handle macro expansion args in placeholder expansion by hamishknight · Pull Request #3092 · swiftlang/swift-syntax · GitHub
- Swift Interface:
extension CallToTrailingClosures { + @available(*, deprecated, message: "Pass a Syntax argument instead of FunctionCallExprSyntax") public static func refactor(syntax: FunctionCallExprSyntax, in context: Context = Context()) -> FunctionCallExprSyntax? + /// Apply the refactoring to a given syntax node. If either a + /// non-function-like syntax node is passed, or the refactoring fails, + /// `nil` is returned. + public static func refactor(syntax: Syntax, in context: Context = Context()) -> Syntax? } extension ExpandEditorPlaceholdersToLiteralClosures { + @available(*, deprecated, message: "Pass a Syntax argument instead of FunctionCallExprSyntax") public static func refactor(syntax: FunctionCallExprSyntax, in context: Context = Context()) -> FunctionCallExprSyntax? + /// Apply the refactoring to a given syntax node. If either a + /// non-function-like syntax node is passed, or the refactoring fails, + /// `nil` is returned. + public static func refactor(syntax: Syntax, in context: Context = Context()) -> Syntax? }
- Impact: The deprecation will mitigate the impact for clients that directly call
refactor
. Clients relying on the conformance toSyntaxRefactoringProvider
will be impacted by this change, but I don't expect there to be many clients. - Migration: Clients should pass a
Syntax
argument as cast the result if needed.
This change looks good to me. Thank you!
Welcomed change in my book. I don't know if using a SyntaxProtocol
would be better long-term (as an existential and generic parameter) but its use looks discouraged, so I guess Syntax
is appropriate.