# RFC: Changing \`ExpandEditorPlaceholdersToLiteralClosures\` & \`CallToTrailingClosures\` to take a \`Syntax\` input

**URL:** <https://forums.swift.org/t/rfc-changing-expandeditorplaceholderstoliteralclosures-calltotrailingclosures-to-take-a-syntax-input/80288>\
**Category:** Swift Syntax\
**Created:** [June 4, 2025, 12:06pm UTC](https://forums.swift.org/t/rfc-changing-expandeditorplaceholderstoliteralclosures-calltotrailingclosures-to-take-a-syntax-input/80288 "2025-06-04T12:06:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hamishknight](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/hamishknight/32/14226_2.png) [@hamishknight](https://forums.swift.org/u/hamishknight)\
**Post date:** [June 4, 2025, 12:06pm UTC](https://forums.swift.org/t/rfc-changing-expandeditorplaceholderstoliteralclosures-calltotrailingclosures-to-take-a-syntax-input/80288/1 "2025-06-04T12:06:11Z")

</div>

- Summary: `ExpandEditorPlaceholdersToLiteralClosures` & `CallToTrailingClosures` now take a `Syntax` parameter and return `Syntax?` to satisfy the conformance to `SyntaxRefactoringProvider`. If a non-function-like syntax node is passed, `nil` is returned. The previous `FunctionCallExprSyntax` 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](https://github.com/swiftlang/swift-syntax/pull/3092)
- Swift Interface:

```diff
 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 to `SyntaxRefactoringProvider` 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.

---

<div class="post-metadata">

**Author:** ![ahoppen](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ahoppen/32/36046_2.png) [@ahoppen](https://forums.swift.org/u/ahoppen)\
**Post date:** [June 4, 2025, 6:25pm UTC](https://forums.swift.org/t/rfc-changing-expandeditorplaceholderstoliteralclosures-calltotrailingclosures-to-take-a-syntax-input/80288/2 "2025-06-04T18:25:50Z")

</div>

This change looks good to me. Thank you!

---

<div class="post-metadata">

**Author:** ![RandomHashTags](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/randomhashtags/32/24259_2.png) [@RandomHashTags](https://forums.swift.org/u/RandomHashTags)\
**Post date:** [June 5, 2025, 2:16am UTC](https://forums.swift.org/t/rfc-changing-expandeditorplaceholderstoliteralclosures-calltotrailingclosures-to-take-a-syntax-input/80288/3 "2025-06-05T02:16:53Z")

</div>

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.
