@@ -129,28 +129,24 @@ public struct CodeBlockItemSyntax: SyntaxProtocol, SyntaxHashable {
129
129
self._syntaxNode = Syntax(data)
130
130
}
131
131
132
- public init<E: SyntaxProtocol> (
132
+ public init(
133
133
leadingTrivia: Trivia? = nil,
134
134
_ unexpectedBeforeItem: UnexpectedNodesSyntax? = nil,
135
135
item: Item,
136
136
_ unexpectedBetweenItemAndSemicolon: UnexpectedNodesSyntax? = nil,
137
137
semicolon: TokenSyntax? = nil,
138
- _ unexpectedBetweenSemicolonAndErrorTokens: UnexpectedNodesSyntax? = nil,
139
- errorTokens: E? = nil,
140
- _ unexpectedAfterErrorTokens: UnexpectedNodesSyntax? = nil,
138
+ _ unexpectedAfterSemicolon: UnexpectedNodesSyntax? = nil,
141
139
trailingTrivia: Trivia? = nil
142
140
) {
143
141
// Extend the lifetime of all parameters so their arenas don't get destroyed
144
142
// before they can be added as children of the new arena.
145
- let data: SyntaxData = withExtendedLifetime((SyntaxArena(), (unexpectedBeforeItem, item, unexpectedBetweenItemAndSemicolon, semicolon, unexpectedBetweenSemicolonAndErrorTokens, errorTokens, unexpectedAfterErrorTokens ))) { (arena, _) in
143
+ let data: SyntaxData = withExtendedLifetime((SyntaxArena(), (unexpectedBeforeItem, item, unexpectedBetweenItemAndSemicolon, semicolon, unexpectedAfterSemicolon ))) { (arena, _) in
146
144
let layout: [RawSyntax?] = [
147
145
unexpectedBeforeItem?.raw,
148
146
item.raw,
149
147
unexpectedBetweenItemAndSemicolon?.raw,
150
148
semicolon?.raw,
151
- unexpectedBetweenSemicolonAndErrorTokens?.raw,
152
- errorTokens?.raw,
153
- unexpectedAfterErrorTokens?.raw,
149
+ unexpectedAfterSemicolon?.raw,
154
150
]
155
151
let raw = RawSyntax.makeLayout(
156
152
kind: SyntaxKind.codeBlockItem, from: layout, arena: arena,
@@ -160,40 +156,6 @@ public struct CodeBlockItemSyntax: SyntaxProtocol, SyntaxHashable {
160
156
self.init(data)
161
157
}
162
158
163
- /// This initializer exists solely because Swift 5.6 does not support
164
- /// `Optional<ConcreteType>.none` as a default value of a generic parameter.
165
- /// The above initializer thus defaults to `nil` instead, but that means it
166
- /// is not actually callable when either not passing the defaulted parameter,
167
- /// or passing `nil`.
168
- ///
169
- /// Hack around that limitation using this initializer, which takes a
170
- /// `Missing*` syntax node instead. `Missing*` is used over the base type as
171
- /// the base type would allow implicit conversion from a string literal,
172
- /// which the above initializer doesn't support.
173
- public init(
174
- leadingTrivia: Trivia? = nil,
175
- _ unexpectedBeforeItem: UnexpectedNodesSyntax? = nil,
176
- item: Item,
177
- _ unexpectedBetweenItemAndSemicolon: UnexpectedNodesSyntax? = nil,
178
- semicolon: TokenSyntax? = nil,
179
- _ unexpectedBetweenSemicolonAndErrorTokens: UnexpectedNodesSyntax? = nil,
180
- errorTokens: MissingSyntax? = nil,
181
- _ unexpectedAfterErrorTokens: UnexpectedNodesSyntax? = nil,
182
- trailingTrivia: Trivia? = nil
183
- ) {
184
- self.init(
185
- leadingTrivia: leadingTrivia,
186
- unexpectedBeforeItem,
187
- item: item,
188
- unexpectedBetweenItemAndSemicolon,
189
- semicolon: semicolon,
190
- unexpectedBetweenSemicolonAndErrorTokens,
191
- errorTokens: Optional<Syntax>.none,
192
- unexpectedAfterErrorTokens,
193
- trailingTrivia: trailingTrivia
194
- )
195
- }
196
-
197
159
public var unexpectedBeforeItem: UnexpectedNodesSyntax? {
198
160
get {
199
161
let childData = data.child(at: 0, parent: Syntax(self))
@@ -281,78 +243,34 @@ public struct CodeBlockItemSyntax: SyntaxProtocol, SyntaxHashable {
281
243
return CodeBlockItemSyntax(newData)
282
244
}
283
245
284
- public var unexpectedBetweenSemicolonAndErrorTokens : UnexpectedNodesSyntax? {
246
+ public var unexpectedAfterSemicolon : UnexpectedNodesSyntax? {
285
247
get {
286
248
let childData = data.child(at: 4, parent: Syntax(self))
287
249
if childData == nil { return nil }
288
250
return UnexpectedNodesSyntax(childData!)
289
251
}
290
252
set(value) {
291
- self = withUnexpectedBetweenSemicolonAndErrorTokens (value)
253
+ self = withUnexpectedAfterSemicolon (value)
292
254
}
293
255
}
294
256
295
- /// Returns a copy of the receiver with its `unexpectedBetweenSemicolonAndErrorTokens ` replaced.
296
- /// - param newChild: The new `unexpectedBetweenSemicolonAndErrorTokens ` to replace the node's
297
- /// current `unexpectedBetweenSemicolonAndErrorTokens `, if present.
298
- public func withUnexpectedBetweenSemicolonAndErrorTokens (_ newChild: UnexpectedNodesSyntax?) -> CodeBlockItemSyntax {
257
+ /// Returns a copy of the receiver with its `unexpectedAfterSemicolon ` replaced.
258
+ /// - param newChild: The new `unexpectedAfterSemicolon ` to replace the node's
259
+ /// current `unexpectedAfterSemicolon `, if present.
260
+ public func withUnexpectedAfterSemicolon (_ newChild: UnexpectedNodesSyntax?) -> CodeBlockItemSyntax {
299
261
let arena = SyntaxArena()
300
262
let raw = newChild?.raw
301
263
let newData = data.replacingChild(at: 4, with: raw, arena: arena)
302
264
return CodeBlockItemSyntax(newData)
303
265
}
304
266
305
- public var errorTokens: Syntax? {
306
- get {
307
- let childData = data.child(at: 5, parent: Syntax(self))
308
- if childData == nil { return nil }
309
- return Syntax(childData!)
310
- }
311
- set(value) {
312
- self = withErrorTokens(value)
313
- }
314
- }
315
-
316
- /// Returns a copy of the receiver with its `errorTokens` replaced.
317
- /// - param newChild: The new `errorTokens` to replace the node's
318
- /// current `errorTokens`, if present.
319
- public func withErrorTokens(_ newChild: Syntax?) -> CodeBlockItemSyntax {
320
- let arena = SyntaxArena()
321
- let raw = newChild?.raw
322
- let newData = data.replacingChild(at: 5, with: raw, arena: arena)
323
- return CodeBlockItemSyntax(newData)
324
- }
325
-
326
- public var unexpectedAfterErrorTokens: UnexpectedNodesSyntax? {
327
- get {
328
- let childData = data.child(at: 6, parent: Syntax(self))
329
- if childData == nil { return nil }
330
- return UnexpectedNodesSyntax(childData!)
331
- }
332
- set(value) {
333
- self = withUnexpectedAfterErrorTokens(value)
334
- }
335
- }
336
-
337
- /// Returns a copy of the receiver with its `unexpectedAfterErrorTokens` replaced.
338
- /// - param newChild: The new `unexpectedAfterErrorTokens` to replace the node's
339
- /// current `unexpectedAfterErrorTokens`, if present.
340
- public func withUnexpectedAfterErrorTokens(_ newChild: UnexpectedNodesSyntax?) -> CodeBlockItemSyntax {
341
- let arena = SyntaxArena()
342
- let raw = newChild?.raw
343
- let newData = data.replacingChild(at: 6, with: raw, arena: arena)
344
- return CodeBlockItemSyntax(newData)
345
- }
346
-
347
267
public static var structure: SyntaxNodeStructure {
348
268
return .layout([
349
269
\Self.unexpectedBeforeItem,
350
270
\Self.item,
351
271
\Self.unexpectedBetweenItemAndSemicolon,
352
272
\Self.semicolon,
353
- \Self.unexpectedBetweenSemicolonAndErrorTokens,
354
- \Self.errorTokens,
355
- \Self.unexpectedAfterErrorTokens,
273
+ \Self.unexpectedAfterSemicolon,
356
274
])
357
275
}
358
276
@@ -368,10 +286,6 @@ public struct CodeBlockItemSyntax: SyntaxProtocol, SyntaxHashable {
368
286
return nil
369
287
case 4:
370
288
return nil
371
- case 5:
372
- return nil
373
- case 6:
374
- return nil
375
289
default:
376
290
fatalError("Invalid index")
377
291
}
@@ -385,9 +299,7 @@ extension CodeBlockItemSyntax: CustomReflectable {
385
299
"item": Syntax(item).asProtocol(SyntaxProtocol.self),
386
300
"unexpectedBetweenItemAndSemicolon": unexpectedBetweenItemAndSemicolon.map(Syntax.init)?.asProtocol(SyntaxProtocol.self) as Any,
387
301
"semicolon": semicolon.map(Syntax.init)?.asProtocol(SyntaxProtocol.self) as Any,
388
- "unexpectedBetweenSemicolonAndErrorTokens": unexpectedBetweenSemicolonAndErrorTokens.map(Syntax.init)?.asProtocol(SyntaxProtocol.self) as Any,
389
- "errorTokens": errorTokens.map(Syntax.init)?.asProtocol(SyntaxProtocol.self) as Any,
390
- "unexpectedAfterErrorTokens": unexpectedAfterErrorTokens.map(Syntax.init)?.asProtocol(SyntaxProtocol.self) as Any,
302
+ "unexpectedAfterSemicolon": unexpectedAfterSemicolon.map(Syntax.init)?.asProtocol(SyntaxProtocol.self) as Any,
391
303
])
392
304
}
393
305
}
0 commit comments