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