@@ -117,9 +117,9 @@ public struct ${node.name}: SyntaxCollection, SyntaxHashable {
117
117
self . _syntaxNode = Syntax ( data)
118
118
}
119
119
120
- public init( _ children: [ Element] ) {
120
+ public init( _ children: [ Element] , arena : SyntaxArena = SyntaxArena ( ) ) {
121
121
let raw = RawSyntax . makeLayout ( kind: SyntaxKind . ${ node. swift_syntax_kind} ,
122
- from: children. map { $0. raw } , arena: . default )
122
+ from: children. map { $0. raw } , arena: arena )
123
123
let data = SyntaxData . forRoot ( raw)
124
124
self . init ( data)
125
125
}
@@ -134,9 +134,10 @@ public struct ${node.name}: SyntaxCollection, SyntaxHashable {
134
134
/// collection.
135
135
/// - Returns: A new `${node.name}` with the new layout underlying it.
136
136
internal func replacingLayout(
137
- _ layout: [ RawSyntax? ] ) - > ${ node. name} {
138
- let newRaw = layoutView. replacingLayout ( with: layout, arena: . default)
139
- let newData = data. replacingSelf ( newRaw)
137
+ _ layout: [ RawSyntax? ] ,
138
+ arena: SyntaxArena) - > ${ node. name} {
139
+ let newRaw = layoutView. replacingLayout ( with: layout, arena: arena)
140
+ let newData = data. replacingSelf ( newRaw, arena: arena)
140
141
return ${ node. name} ( newData)
141
142
}
142
143
@@ -145,10 +146,10 @@ public struct ${node.name}: SyntaxCollection, SyntaxHashable {
145
146
///
146
147
/// - Parameter syntax: The element to append.
147
148
/// - Returns: A new `${node.name}` with that element appended to the end.
148
- public func appending( _ syntax: Element) - > ${ node. name} {
149
+ public func appending( _ syntax: Element, arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
149
150
var newLayout = layoutView. formLayoutArray ( )
150
151
newLayout. append ( syntax. raw)
151
- return replacingLayout ( newLayout)
152
+ return replacingLayout ( newLayout, arena : arena )
152
153
}
153
154
154
155
/// Creates a new `${node.name}` by prepending the provided syntax element
@@ -157,8 +158,8 @@ public struct ${node.name}: SyntaxCollection, SyntaxHashable {
157
158
/// - Parameter syntax: The element to prepend.
158
159
/// - Returns: A new `${node.name}` with that element prepended to the
159
160
/// beginning.
160
- public func prepending( _ syntax: Element) - > ${ node. name} {
161
- return inserting ( syntax, at: 0 )
161
+ public func prepending( _ syntax: Element, arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
162
+ return inserting ( syntax, at: 0 , arena : arena )
162
163
}
163
164
164
165
/// Creates a new `${node.name}` by inserting the provided syntax element
@@ -169,13 +170,13 @@ public struct ${node.name}: SyntaxCollection, SyntaxHashable {
169
170
/// - index: The index at which to insert the element in the collection.
170
171
///
171
172
/// - Returns: A new `${node.name}` with that element appended to the end.
172
- public func inserting( _ syntax: Element, at index: Int) - > ${ node. name} {
173
+ public func inserting( _ syntax: Element, at index: Int, arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
173
174
var newLayout = layoutView. formLayoutArray ( )
174
175
/// Make sure the index is a valid insertion index (0 to 1 past the end)
175
176
precondition ( ( newLayout. startIndex... newLayout. endIndex) . contains ( index) ,
176
177
" inserting node at invalid index \( index) " )
177
178
newLayout. insert ( syntax. raw, at: index)
178
- return replacingLayout ( newLayout)
179
+ return replacingLayout ( newLayout, arena : arena )
179
180
}
180
181
181
182
/// Creates a new `${node.name}` by replacing the syntax element
@@ -186,13 +187,13 @@ public struct ${node.name}: SyntaxCollection, SyntaxHashable {
186
187
/// - syntax: The element to replace with.
187
188
///
188
189
/// - Returns: A new `${node.name}` with the new element at the provided index.
189
- public func replacing( childAt index: Int, with syntax: Element) - > ${ node. name} {
190
+ public func replacing( childAt index: Int, with syntax: Element, arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
190
191
var newLayout = layoutView. formLayoutArray ( )
191
192
/// Make sure the index is a valid index for replacing
192
193
precondition ( ( newLayout. startIndex..< newLayout. endIndex) . contains ( index) ,
193
194
" replacing node at invalid index \( index) " )
194
195
newLayout [ index] = syntax. raw
195
- return replacingLayout ( newLayout)
196
+ return replacingLayout ( newLayout, arena : arena )
196
197
}
197
198
198
199
/// Creates a new `${node.name}` by removing the syntax element at the
@@ -201,55 +202,55 @@ public struct ${node.name}: SyntaxCollection, SyntaxHashable {
201
202
/// - Parameter index: The index of the element to remove from the collection.
202
203
/// - Returns: A new `${node.name}` with the element at the provided index
203
204
/// removed.
204
- public func removing( childAt index: Int) - > ${ node. name} {
205
+ public func removing( childAt index: Int, arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
205
206
var newLayout = layoutView. formLayoutArray ( )
206
207
newLayout. remove ( at: index)
207
- return replacingLayout ( newLayout)
208
+ return replacingLayout ( newLayout, arena : arena )
208
209
}
209
210
210
211
/// Creates a new `${node.name}` by removing the first element.
211
212
///
212
213
/// - Returns: A new `${node.name}` with the first element removed.
213
- public func removingFirst( ) - > ${ node. name} {
214
+ public func removingFirst( arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
214
215
var newLayout = layoutView. formLayoutArray ( )
215
216
newLayout. removeFirst ( )
216
- return replacingLayout ( newLayout)
217
+ return replacingLayout ( newLayout, arena : arena )
217
218
}
218
219
219
220
/// Creates a new `${node.name}` by removing the last element.
220
221
///
221
222
/// - Returns: A new `${node.name}` with the last element removed.
222
- public func removingLast( ) - > ${ node. name} {
223
+ public func removingLast( arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
223
224
var newLayout = layoutView. formLayoutArray ( )
224
225
newLayout. removeLast ( )
225
- return replacingLayout ( newLayout)
226
+ return replacingLayout ( newLayout, arena : arena )
226
227
}
227
228
228
229
/// Returns a new `${node.name}` with its leading trivia replaced
229
230
/// by the provided trivia.
230
- public func withLeadingTrivia( _ leadingTrivia: Trivia) - > ${ node. name} {
231
- return ${ node. name} ( data. withLeadingTrivia ( leadingTrivia) )
231
+ public func withLeadingTrivia( _ leadingTrivia: Trivia, arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
232
+ return ${ node. name} ( data. withLeadingTrivia ( leadingTrivia, arena : arena ) )
232
233
}
233
234
234
235
/// Returns a new `${node.name}` with its trailing trivia replaced
235
236
/// by the provided trivia.
236
- public func withTrailingTrivia( _ trailingTrivia: Trivia) - > ${ node. name} {
237
- return ${ node. name} ( data. withTrailingTrivia ( trailingTrivia) )
237
+ public func withTrailingTrivia( _ trailingTrivia: Trivia, arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
238
+ return ${ node. name} ( data. withTrailingTrivia ( trailingTrivia, arena : arena ) )
238
239
}
239
240
240
241
/// Returns a new `${node.name}` with its leading trivia removed.
241
- public func withoutLeadingTrivia( ) - > ${ node. name} {
242
- return withLeadingTrivia ( [ ] )
242
+ public func withoutLeadingTrivia( arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
243
+ return withLeadingTrivia ( [ ] , arena : arena )
243
244
}
244
245
245
246
/// Returns a new `${node.name}` with its trailing trivia removed.
246
- public func withoutTrailingTrivia( ) - > ${ node. name} {
247
- return withTrailingTrivia ( [ ] )
247
+ public func withoutTrailingTrivia( arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
248
+ return withTrailingTrivia ( [ ] , arena : arena )
248
249
}
249
250
250
251
/// Returns a new `${node.name}` with all trivia removed.
251
- public func withoutTrivia( ) - > ${ node. name} {
252
- return withoutLeadingTrivia ( ) . withoutTrailingTrivia ( )
252
+ public func withoutTrivia( arena : SyntaxArena = SyntaxArena ( ) ) - > ${ node. name} {
253
+ return withoutLeadingTrivia ( arena : arena ) . withoutTrailingTrivia ( arena : arena )
253
254
}
254
255
255
256
/// The leading trivia (spaces, newlines, etc.) associated with this `${node.name}`.
0 commit comments