Skip to content

Commit e7c7f98

Browse files
committed
Deprecate add* methods on syntax nodes that have a collection as child
1 parent ea619f4 commit e7c7f98

File tree

7 files changed

+105
-0
lines changed

7 files changed

+105
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ func syntaxNode(emitKind: SyntaxNodeKind) -> SourceFileSyntax {
203203
/// `\(child.varOrCaseName)` collection.
204204
/// - returns: A copy of the receiver with the provided `\(raw: childElt)`
205205
/// appended to its `\(child.varOrCaseName)` collection.
206+
@available(*, deprecated, message: "Use node.\(child.varOrCaseName).append(newElement) instead")
206207
public func add\(raw: childElt)(_ element: \(raw: childEltType)) -> \(node.kind.syntaxType) {
207208
var collection: RawSyntax
208209
let arena = SyntaxArena()

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxDeclNodes.swift

Lines changed: 48 additions & 0 deletions
Large diffs are not rendered by default.

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxExprNodes.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public struct ArrayExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
127127
/// `elements` collection.
128128
/// - returns: A copy of the receiver with the provided `Element`
129129
/// appended to its `elements` collection.
130+
@available(*, deprecated, message: "Use node.elements.append(newElement) instead")
130131
public func addElement(_ element: ArrayElementSyntax) -> ArrayExprSyntax {
131132
var collection: RawSyntax
132133
let arena = SyntaxArena()
@@ -1507,6 +1508,7 @@ public struct ClosureExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
15071508
/// `statements` collection.
15081509
/// - returns: A copy of the receiver with the provided `Statement`
15091510
/// appended to its `statements` collection.
1511+
@available(*, deprecated, message: "Use node.statements.append(newElement) instead")
15101512
public func addStatement(_ element: CodeBlockItemSyntax) -> ClosureExprSyntax {
15111513
var collection: RawSyntax
15121514
let arena = SyntaxArena()
@@ -2658,6 +2660,7 @@ public struct FunctionCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
26582660
/// `arguments` collection.
26592661
/// - returns: A copy of the receiver with the provided `Argument`
26602662
/// appended to its `arguments` collection.
2663+
@available(*, deprecated, message: "Use node.arguments.append(newElement) instead")
26612664
public func addArgument(_ element: LabeledExprSyntax) -> FunctionCallExprSyntax {
26622665
var collection: RawSyntax
26632666
let arena = SyntaxArena()
@@ -2736,6 +2739,7 @@ public struct FunctionCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
27362739
/// `additionalTrailingClosures` collection.
27372740
/// - returns: A copy of the receiver with the provided `AdditionalTrailingClosure`
27382741
/// appended to its `additionalTrailingClosures` collection.
2742+
@available(*, deprecated, message: "Use node.additionalTrailingClosures.append(newElement) instead")
27392743
public func addAdditionalTrailingClosure(_ element: MultipleTrailingClosureElementSyntax) -> FunctionCallExprSyntax {
27402744
var collection: RawSyntax
27412745
let arena = SyntaxArena()
@@ -3079,6 +3083,7 @@ public struct IfExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
30793083
/// `conditions` collection.
30803084
/// - returns: A copy of the receiver with the provided `Condition`
30813085
/// appended to its `conditions` collection.
3086+
@available(*, deprecated, message: "Use node.conditions.append(newElement) instead")
30823087
public func addCondition(_ element: ConditionElementSyntax) -> IfExprSyntax {
30833088
var collection: RawSyntax
30843089
let arena = SyntaxArena()
@@ -3827,6 +3832,7 @@ public struct KeyPathExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
38273832
/// `components` collection.
38283833
/// - returns: A copy of the receiver with the provided `KeyPathComponent`
38293834
/// appended to its `components` collection.
3835+
@available(*, deprecated, message: "Use node.components.append(newElement) instead")
38303836
public func addKeyPathComponent(_ element: KeyPathComponentSyntax) -> KeyPathExprSyntax {
38313837
var collection: RawSyntax
38323838
let arena = SyntaxArena()
@@ -4073,6 +4079,7 @@ public struct MacroExpansionExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
40734079
/// `arguments` collection.
40744080
/// - returns: A copy of the receiver with the provided `Argument`
40754081
/// appended to its `arguments` collection.
4082+
@available(*, deprecated, message: "Use node.arguments.append(newElement) instead")
40764083
public func addArgument(_ element: LabeledExprSyntax) -> MacroExpansionExprSyntax {
40774084
var collection: RawSyntax
40784085
let arena = SyntaxArena()
@@ -4151,6 +4158,7 @@ public struct MacroExpansionExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
41514158
/// `additionalTrailingClosures` collection.
41524159
/// - returns: A copy of the receiver with the provided `AdditionalTrailingClosure`
41534160
/// appended to its `additionalTrailingClosures` collection.
4161+
@available(*, deprecated, message: "Use node.additionalTrailingClosures.append(newElement) instead")
41544162
public func addAdditionalTrailingClosure(_ element: MultipleTrailingClosureElementSyntax) -> MacroExpansionExprSyntax {
41554163
var collection: RawSyntax
41564164
let arena = SyntaxArena()
@@ -5615,6 +5623,7 @@ public struct SequenceExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
56155623
/// `elements` collection.
56165624
/// - returns: A copy of the receiver with the provided `Element`
56175625
/// appended to its `elements` collection.
5626+
@available(*, deprecated, message: "Use node.elements.append(newElement) instead")
56185627
public func addElement(_ element: ExprSyntax) -> SequenceExprSyntax {
56195628
var collection: RawSyntax
56205629
let arena = SyntaxArena()
@@ -5807,6 +5816,7 @@ public struct StringLiteralExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
58075816
/// `segments` collection.
58085817
/// - returns: A copy of the receiver with the provided `Segment`
58095818
/// appended to its `segments` collection.
5819+
@available(*, deprecated, message: "Use node.segments.append(newElement) instead")
58105820
public func addSegment(_ element: Syntax) -> StringLiteralExprSyntax {
58115821
var collection: RawSyntax
58125822
let arena = SyntaxArena()
@@ -6041,6 +6051,7 @@ public struct SubscriptCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
60416051
/// `arguments` collection.
60426052
/// - returns: A copy of the receiver with the provided `Argument`
60436053
/// appended to its `arguments` collection.
6054+
@available(*, deprecated, message: "Use node.arguments.append(newElement) instead")
60446055
public func addArgument(_ element: LabeledExprSyntax) -> SubscriptCallExprSyntax {
60456056
var collection: RawSyntax
60466057
let arena = SyntaxArena()
@@ -6119,6 +6130,7 @@ public struct SubscriptCallExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
61196130
/// `additionalTrailingClosures` collection.
61206131
/// - returns: A copy of the receiver with the provided `AdditionalTrailingClosure`
61216132
/// appended to its `additionalTrailingClosures` collection.
6133+
@available(*, deprecated, message: "Use node.additionalTrailingClosures.append(newElement) instead")
61226134
public func addAdditionalTrailingClosure(_ element: MultipleTrailingClosureElementSyntax) -> SubscriptCallExprSyntax {
61236135
var collection: RawSyntax
61246136
let arena = SyntaxArena()
@@ -6413,6 +6425,7 @@ public struct SwitchExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
64136425
/// `cases` collection.
64146426
/// - returns: A copy of the receiver with the provided `Case`
64156427
/// appended to its `cases` collection.
6428+
@available(*, deprecated, message: "Use node.cases.append(newElement) instead")
64166429
public func addCase(_ element: Syntax) -> SwitchExprSyntax {
64176430
var collection: RawSyntax
64186431
let arena = SyntaxArena()
@@ -6942,6 +6955,7 @@ public struct TupleExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
69426955
/// `elements` collection.
69436956
/// - returns: A copy of the receiver with the provided `Element`
69446957
/// appended to its `elements` collection.
6958+
@available(*, deprecated, message: "Use node.elements.append(newElement) instead")
69456959
public func addElement(_ element: LabeledExprSyntax) -> TupleExprSyntax {
69466960
var collection: RawSyntax
69476961
let arena = SyntaxArena()

0 commit comments

Comments
 (0)