@@ -43,129 +43,289 @@ public protocol SyntaxParseable: SyntaxProtocol {
43
43
44
44
extension AccessorDeclSyntax : SyntaxParseable {
45
45
public static func parse( from parser: inout Parser ) -> Self {
46
+ // Keep the parser alive so that the arena in which `raw` is allocated
47
+ // doesn’t get deallocated before we have a chance to create a syntax node
48
+ // from it. We can’t use `parser.arena` as the parameter to
49
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
50
+ // incremental parse and would then live in a different arena than
51
+ // `parser.arena`.
52
+ defer {
53
+ withExtendedLifetime ( parser) {
54
+ }
55
+ }
46
56
let node = parser. parseAccessorDecl ( )
47
57
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
48
- return Syntax ( raw: raw) . cast ( Self . self)
58
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
49
59
}
50
60
}
51
61
52
62
extension AttributeSyntax : SyntaxParseable {
53
63
public static func parse( from parser: inout Parser ) -> Self {
64
+ // Keep the parser alive so that the arena in which `raw` is allocated
65
+ // doesn’t get deallocated before we have a chance to create a syntax node
66
+ // from it. We can’t use `parser.arena` as the parameter to
67
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
68
+ // incremental parse and would then live in a different arena than
69
+ // `parser.arena`.
70
+ defer {
71
+ withExtendedLifetime ( parser) {
72
+ }
73
+ }
54
74
let node = parser. parseAttribute ( )
55
75
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
56
- return Syntax ( raw: raw) . cast ( Self . self)
76
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
57
77
}
58
78
}
59
79
60
80
extension CatchClauseSyntax : SyntaxParseable {
61
81
public static func parse( from parser: inout Parser ) -> Self {
82
+ // Keep the parser alive so that the arena in which `raw` is allocated
83
+ // doesn’t get deallocated before we have a chance to create a syntax node
84
+ // from it. We can’t use `parser.arena` as the parameter to
85
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
86
+ // incremental parse and would then live in a different arena than
87
+ // `parser.arena`.
88
+ defer {
89
+ withExtendedLifetime ( parser) {
90
+ }
91
+ }
62
92
let node = parser. parseCatchClause ( )
63
93
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
64
- return Syntax ( raw: raw) . cast ( Self . self)
94
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
65
95
}
66
96
}
67
97
68
98
extension ClosureParameterSyntax : SyntaxParseable {
69
99
public static func parse( from parser: inout Parser ) -> Self {
100
+ // Keep the parser alive so that the arena in which `raw` is allocated
101
+ // doesn’t get deallocated before we have a chance to create a syntax node
102
+ // from it. We can’t use `parser.arena` as the parameter to
103
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
104
+ // incremental parse and would then live in a different arena than
105
+ // `parser.arena`.
106
+ defer {
107
+ withExtendedLifetime ( parser) {
108
+ }
109
+ }
70
110
let node = parser. parseClosureParameter ( )
71
111
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
72
- return Syntax ( raw: raw) . cast ( Self . self)
112
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
73
113
}
74
114
}
75
115
76
116
extension CodeBlockItemSyntax : SyntaxParseable {
77
117
public static func parse( from parser: inout Parser ) -> Self {
118
+ // Keep the parser alive so that the arena in which `raw` is allocated
119
+ // doesn’t get deallocated before we have a chance to create a syntax node
120
+ // from it. We can’t use `parser.arena` as the parameter to
121
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
122
+ // incremental parse and would then live in a different arena than
123
+ // `parser.arena`.
124
+ defer {
125
+ withExtendedLifetime ( parser) {
126
+ }
127
+ }
78
128
let node = parser. parseNonOptionalCodeBlockItem ( )
79
129
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
80
- return Syntax ( raw: raw) . cast ( Self . self)
130
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
81
131
}
82
132
}
83
133
84
134
extension DeclSyntax : SyntaxParseable {
85
135
public static func parse( from parser: inout Parser ) -> Self {
136
+ // Keep the parser alive so that the arena in which `raw` is allocated
137
+ // doesn’t get deallocated before we have a chance to create a syntax node
138
+ // from it. We can’t use `parser.arena` as the parameter to
139
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
140
+ // incremental parse and would then live in a different arena than
141
+ // `parser.arena`.
142
+ defer {
143
+ withExtendedLifetime ( parser) {
144
+ }
145
+ }
86
146
let node = parser. parseDeclaration ( )
87
147
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
88
- return Syntax ( raw: raw) . cast ( Self . self)
148
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
89
149
}
90
150
}
91
151
92
152
extension EnumCaseParameterSyntax : SyntaxParseable {
93
153
public static func parse( from parser: inout Parser ) -> Self {
154
+ // Keep the parser alive so that the arena in which `raw` is allocated
155
+ // doesn’t get deallocated before we have a chance to create a syntax node
156
+ // from it. We can’t use `parser.arena` as the parameter to
157
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
158
+ // incremental parse and would then live in a different arena than
159
+ // `parser.arena`.
160
+ defer {
161
+ withExtendedLifetime ( parser) {
162
+ }
163
+ }
94
164
let node = parser. parseEnumCaseParameter ( )
95
165
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
96
- return Syntax ( raw: raw) . cast ( Self . self)
166
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
97
167
}
98
168
}
99
169
100
170
extension ExprSyntax : SyntaxParseable {
101
171
public static func parse( from parser: inout Parser ) -> Self {
172
+ // Keep the parser alive so that the arena in which `raw` is allocated
173
+ // doesn’t get deallocated before we have a chance to create a syntax node
174
+ // from it. We can’t use `parser.arena` as the parameter to
175
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
176
+ // incremental parse and would then live in a different arena than
177
+ // `parser.arena`.
178
+ defer {
179
+ withExtendedLifetime ( parser) {
180
+ }
181
+ }
102
182
let node = parser. parseExpression ( )
103
183
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
104
- return Syntax ( raw: raw) . cast ( Self . self)
184
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
105
185
}
106
186
}
107
187
108
188
extension FunctionParameterSyntax : SyntaxParseable {
109
189
public static func parse( from parser: inout Parser ) -> Self {
190
+ // Keep the parser alive so that the arena in which `raw` is allocated
191
+ // doesn’t get deallocated before we have a chance to create a syntax node
192
+ // from it. We can’t use `parser.arena` as the parameter to
193
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
194
+ // incremental parse and would then live in a different arena than
195
+ // `parser.arena`.
196
+ defer {
197
+ withExtendedLifetime ( parser) {
198
+ }
199
+ }
110
200
let node = parser. parseFunctionParameter ( )
111
201
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
112
- return Syntax ( raw: raw) . cast ( Self . self)
202
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
113
203
}
114
204
}
115
205
116
206
extension GenericParameterClauseSyntax : SyntaxParseable {
117
207
public static func parse( from parser: inout Parser ) -> Self {
208
+ // Keep the parser alive so that the arena in which `raw` is allocated
209
+ // doesn’t get deallocated before we have a chance to create a syntax node
210
+ // from it. We can’t use `parser.arena` as the parameter to
211
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
212
+ // incremental parse and would then live in a different arena than
213
+ // `parser.arena`.
214
+ defer {
215
+ withExtendedLifetime ( parser) {
216
+ }
217
+ }
118
218
let node = parser. parseGenericParameters ( )
119
219
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
120
- return Syntax ( raw: raw) . cast ( Self . self)
220
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
121
221
}
122
222
}
123
223
124
224
extension MemberDeclBlockSyntax : SyntaxParseable {
125
225
public static func parse( from parser: inout Parser ) -> Self {
226
+ // Keep the parser alive so that the arena in which `raw` is allocated
227
+ // doesn’t get deallocated before we have a chance to create a syntax node
228
+ // from it. We can’t use `parser.arena` as the parameter to
229
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
230
+ // incremental parse and would then live in a different arena than
231
+ // `parser.arena`.
232
+ defer {
233
+ withExtendedLifetime ( parser) {
234
+ }
235
+ }
126
236
let node = parser. parseMemberDeclList ( )
127
237
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
128
- return Syntax ( raw: raw) . cast ( Self . self)
238
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
129
239
}
130
240
}
131
241
132
242
extension PatternSyntax : SyntaxParseable {
133
243
public static func parse( from parser: inout Parser ) -> Self {
244
+ // Keep the parser alive so that the arena in which `raw` is allocated
245
+ // doesn’t get deallocated before we have a chance to create a syntax node
246
+ // from it. We can’t use `parser.arena` as the parameter to
247
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
248
+ // incremental parse and would then live in a different arena than
249
+ // `parser.arena`.
250
+ defer {
251
+ withExtendedLifetime ( parser) {
252
+ }
253
+ }
134
254
let node = parser. parsePattern ( )
135
255
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
136
- return Syntax ( raw: raw) . cast ( Self . self)
256
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
137
257
}
138
258
}
139
259
140
260
extension SourceFileSyntax : SyntaxParseable {
141
261
public static func parse( from parser: inout Parser ) -> Self {
262
+ // Keep the parser alive so that the arena in which `raw` is allocated
263
+ // doesn’t get deallocated before we have a chance to create a syntax node
264
+ // from it. We can’t use `parser.arena` as the parameter to
265
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
266
+ // incremental parse and would then live in a different arena than
267
+ // `parser.arena`.
268
+ defer {
269
+ withExtendedLifetime ( parser) {
270
+ }
271
+ }
142
272
let node = parser. parseSourceFile ( )
143
273
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
144
- return Syntax ( raw: raw) . cast ( Self . self)
274
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
145
275
}
146
276
}
147
277
148
278
extension StmtSyntax : SyntaxParseable {
149
279
public static func parse( from parser: inout Parser ) -> Self {
280
+ // Keep the parser alive so that the arena in which `raw` is allocated
281
+ // doesn’t get deallocated before we have a chance to create a syntax node
282
+ // from it. We can’t use `parser.arena` as the parameter to
283
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
284
+ // incremental parse and would then live in a different arena than
285
+ // `parser.arena`.
286
+ defer {
287
+ withExtendedLifetime ( parser) {
288
+ }
289
+ }
150
290
let node = parser. parseStatement ( )
151
291
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
152
- return Syntax ( raw: raw) . cast ( Self . self)
292
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
153
293
}
154
294
}
155
295
156
296
extension SwitchCaseSyntax : SyntaxParseable {
157
297
public static func parse( from parser: inout Parser ) -> Self {
298
+ // Keep the parser alive so that the arena in which `raw` is allocated
299
+ // doesn’t get deallocated before we have a chance to create a syntax node
300
+ // from it. We can’t use `parser.arena` as the parameter to
301
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
302
+ // incremental parse and would then live in a different arena than
303
+ // `parser.arena`.
304
+ defer {
305
+ withExtendedLifetime ( parser) {
306
+ }
307
+ }
158
308
let node = parser. parseSwitchCase ( )
159
309
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
160
- return Syntax ( raw: raw) . cast ( Self . self)
310
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
161
311
}
162
312
}
163
313
164
314
extension TypeSyntax : SyntaxParseable {
165
315
public static func parse( from parser: inout Parser ) -> Self {
316
+ // Keep the parser alive so that the arena in which `raw` is allocated
317
+ // doesn’t get deallocated before we have a chance to create a syntax node
318
+ // from it. We can’t use `parser.arena` as the parameter to
319
+ // `Syntax(raw:arena:)` because the node might have been re-used during an
320
+ // incremental parse and would then live in a different arena than
321
+ // `parser.arena`.
322
+ defer {
323
+ withExtendedLifetime ( parser) {
324
+ }
325
+ }
166
326
let node = parser. parseType ( )
167
327
let raw = RawSyntax ( parser. parseRemainder ( into: node) )
168
- return Syntax ( raw: raw) . cast ( Self . self)
328
+ return Syntax ( raw: raw, rawNodeArena : raw . arena ) . cast ( Self . self)
169
329
}
170
330
}
171
331
0 commit comments