Skip to content

Commit 9e82800

Browse files
committed
Add a renamed label for the renamed syntax node initializers
This makes migration of the initializers a lot easier because Xcode can apply a Fix-It to replace the argument labels.
1 parent ea619f4 commit 9e82800

File tree

2 files changed

+126
-115
lines changed

2 files changed

+126
-115
lines changed

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RenamedChildrenCompatibilityFile.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,20 @@ let renamedChildrenCompatibilityFile = try! SourceFileSyntax(leadingTrivia: copy
6060
.map { $0.varOrCaseName.description }
6161
.joined(separator: ", ")
6262

63+
let renamedArguments =
64+
layoutNode.children.map { child in
65+
if child.isUnexpectedNodes {
66+
return "_:"
67+
} else {
68+
return "\(child.varOrCaseName):"
69+
}
70+
}.joined(separator: "")
71+
72+
let renamedName = "\(layoutNode.type.syntaxBaseName)(leadingTrivia:\(renamedArguments)trailingTrivia:)"
73+
6374
try! InitializerDeclSyntax(
6475
"""
65-
@available(*, deprecated, message: "Use an initializer with \(raw: deprecatedNames) argument(s).")
76+
@available(*, deprecated, renamed: \(literal: renamedName))
6677
@_disfavoredOverload
6778
\(layoutNode.generateInitializerDeclHeader(useDeprecatedChildName: true))
6879
"""

0 commit comments

Comments
 (0)