File: SyntaxTraits.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (850 lines) | stat: -rw-r--r-- 28,559 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
//// Automatically generated by generate-swift-syntax
//// Do not edit directly!
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

// MARK: - BracedSyntax

public protocol BracedSyntax: SyntaxProtocol {
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `{`.
  var leftBrace: TokenSyntax {
    get
    set
  }
  
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `}`.
  var rightBrace: TokenSyntax {
    get
    set
  }
}

extension BracedSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<BracedSyntax, T>, _ newChild: T) -> BracedSyntax {
    var copy: BracedSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `BracedSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: BracedSyntax.Protocol) -> Bool {
    return self.asProtocol(BracedSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `BracedSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: BracedSyntax.Protocol) -> BracedSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? BracedSyntax
  }
}

// MARK: - DeclGroupSyntax

public protocol DeclGroupSyntax: SyntaxProtocol, DeclSyntaxProtocol {
  var attributes: AttributeListSyntax {
    get
    set
  }
  
  var modifiers: DeclModifierListSyntax {
    get
    set
  }
  
  /// The token that introduces this declaration, eg. `class` for a class declaration.
  ///
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be one of the following kinds:
  ///  - `actor`
  ///  - `class`
  ///  - `enum`
  ///  - `extension`
  ///  - `protocol`
  ///  - `struct`
  var introducer: TokenSyntax {
    get
    set
  }
  
  var inheritanceClause: InheritanceClauseSyntax? {
    get
    set
  }
  
  /// A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`.
  var genericWhereClause: GenericWhereClauseSyntax? {
    get
    set
  }
  
  var memberBlock: MemberBlockSyntax {
    get
    set
  }
}

extension DeclGroupSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<DeclGroupSyntax, T>, _ newChild: T) -> DeclGroupSyntax {
    var copy: DeclGroupSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `DeclGroupSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: DeclGroupSyntax.Protocol) -> Bool {
    return self.asProtocol(DeclGroupSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `DeclGroupSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: DeclGroupSyntax.Protocol) -> DeclGroupSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? DeclGroupSyntax
  }
}

// MARK: - EffectSpecifiersSyntax

public protocol EffectSpecifiersSyntax: SyntaxProtocol {
  var unexpectedBeforeAsyncSpecifier: UnexpectedNodesSyntax? {
    get
    set
  }
  
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be one of the following kinds:
  ///  - `async`
  ///  - `reasync`
  var asyncSpecifier: TokenSyntax? {
    get
    set
  }
  
  var unexpectedBetweenAsyncSpecifierAndThrowsClause: UnexpectedNodesSyntax? {
    get
    set
  }
  
  var throwsClause: ThrowsClauseSyntax? {
    get
    set
  }
  
  var unexpectedAfterThrowsClause: UnexpectedNodesSyntax? {
    get
    set
  }
}

extension EffectSpecifiersSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<EffectSpecifiersSyntax, T>, _ newChild: T) -> EffectSpecifiersSyntax {
    var copy: EffectSpecifiersSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `EffectSpecifiersSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: EffectSpecifiersSyntax.Protocol) -> Bool {
    return self.asProtocol(EffectSpecifiersSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `EffectSpecifiersSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: EffectSpecifiersSyntax.Protocol) -> EffectSpecifiersSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? EffectSpecifiersSyntax
  }
}

// MARK: - FreestandingMacroExpansionSyntax

public protocol FreestandingMacroExpansionSyntax: SyntaxProtocol {
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `#`.
  var pound: TokenSyntax {
    get
    set
  }
  
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `<identifier>`.
  var macroName: TokenSyntax {
    get
    set
  }
  
  var genericArgumentClause: GenericArgumentClauseSyntax? {
    get
    set
  }
  
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `(`.
  var leftParen: TokenSyntax? {
    get
    set
  }
  
  var arguments: LabeledExprListSyntax {
    get
    set
  }
  
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `)`.
  var rightParen: TokenSyntax? {
    get
    set
  }
  
  var trailingClosure: ClosureExprSyntax? {
    get
    set
  }
  
  var additionalTrailingClosures: MultipleTrailingClosureElementListSyntax {
    get
    set
  }
}

extension FreestandingMacroExpansionSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<FreestandingMacroExpansionSyntax, T>, _ newChild: T) -> FreestandingMacroExpansionSyntax {
    var copy: FreestandingMacroExpansionSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `FreestandingMacroExpansionSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: FreestandingMacroExpansionSyntax.Protocol) -> Bool {
    return self.asProtocol(FreestandingMacroExpansionSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `FreestandingMacroExpansionSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: FreestandingMacroExpansionSyntax.Protocol) -> FreestandingMacroExpansionSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? FreestandingMacroExpansionSyntax
  }
}

// MARK: - NamedDeclSyntax

public protocol NamedDeclSyntax: SyntaxProtocol {
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `<identifier>`.
  var name: TokenSyntax {
    get
    set
  }
}

extension NamedDeclSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<NamedDeclSyntax, T>, _ newChild: T) -> NamedDeclSyntax {
    var copy: NamedDeclSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `NamedDeclSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: NamedDeclSyntax.Protocol) -> Bool {
    return self.asProtocol(NamedDeclSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `NamedDeclSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: NamedDeclSyntax.Protocol) -> NamedDeclSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? NamedDeclSyntax
  }
}

// MARK: - MissingNodeSyntax

/// Represents a layout node that is missing in the source file.
/// 
/// See the types conforming to this protocol for examples of where missing nodes can occur.
public protocol MissingNodeSyntax: SyntaxProtocol {
  /// A placeholder, i.e. `<#placeholder#>`, that can be inserted into the source code to represent the missing node.
  ///
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `<identifier>`.
  var placeholder: TokenSyntax {
    get
    set
  }
}

extension MissingNodeSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<MissingNodeSyntax, T>, _ newChild: T) -> MissingNodeSyntax {
    var copy: MissingNodeSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `MissingNodeSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: MissingNodeSyntax.Protocol) -> Bool {
    return self.asProtocol(MissingNodeSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `MissingNodeSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: MissingNodeSyntax.Protocol) -> MissingNodeSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? MissingNodeSyntax
  }
}

// MARK: - ParenthesizedSyntax

public protocol ParenthesizedSyntax: SyntaxProtocol {
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `(`.
  var leftParen: TokenSyntax {
    get
    set
  }
  
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `)`.
  var rightParen: TokenSyntax {
    get
    set
  }
}

extension ParenthesizedSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<ParenthesizedSyntax, T>, _ newChild: T) -> ParenthesizedSyntax {
    var copy: ParenthesizedSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `ParenthesizedSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: ParenthesizedSyntax.Protocol) -> Bool {
    return self.asProtocol(ParenthesizedSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `ParenthesizedSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: ParenthesizedSyntax.Protocol) -> ParenthesizedSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? ParenthesizedSyntax
  }
}

// MARK: - WithAttributesSyntax

public protocol WithAttributesSyntax: SyntaxProtocol {
  var attributes: AttributeListSyntax {
    get
    set
  }
}

extension WithAttributesSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<WithAttributesSyntax, T>, _ newChild: T) -> WithAttributesSyntax {
    var copy: WithAttributesSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `WithAttributesSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: WithAttributesSyntax.Protocol) -> Bool {
    return self.asProtocol(WithAttributesSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `WithAttributesSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: WithAttributesSyntax.Protocol) -> WithAttributesSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? WithAttributesSyntax
  }
}

// MARK: - WithCodeBlockSyntax

public protocol WithCodeBlockSyntax: SyntaxProtocol {
  var body: CodeBlockSyntax {
    get
    set
  }
}

extension WithCodeBlockSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<WithCodeBlockSyntax, T>, _ newChild: T) -> WithCodeBlockSyntax {
    var copy: WithCodeBlockSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `WithCodeBlockSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: WithCodeBlockSyntax.Protocol) -> Bool {
    return self.asProtocol(WithCodeBlockSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `WithCodeBlockSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: WithCodeBlockSyntax.Protocol) -> WithCodeBlockSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? WithCodeBlockSyntax
  }
}

// MARK: - WithGenericParametersSyntax

/// Syntax nodes that have generic parameters.
/// 
/// For example, functions or nominal types like `class` or `struct` can have generic parameters and have a generic where clause that restricts these generic parameters.
public protocol WithGenericParametersSyntax: SyntaxProtocol {
  /// The parameter clause that defines the generic parameters.
  var genericParameterClause: GenericParameterClauseSyntax? {
    get
    set
  }
  
  /// A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`.
  var genericWhereClause: GenericWhereClauseSyntax? {
    get
    set
  }
}

extension WithGenericParametersSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<WithGenericParametersSyntax, T>, _ newChild: T) -> WithGenericParametersSyntax {
    var copy: WithGenericParametersSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `WithGenericParametersSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: WithGenericParametersSyntax.Protocol) -> Bool {
    return self.asProtocol(WithGenericParametersSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `WithGenericParametersSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: WithGenericParametersSyntax.Protocol) -> WithGenericParametersSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? WithGenericParametersSyntax
  }
}

// MARK: - WithModifiersSyntax

public protocol WithModifiersSyntax: SyntaxProtocol {
  var modifiers: DeclModifierListSyntax {
    get
    set
  }
}

extension WithModifiersSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<WithModifiersSyntax, T>, _ newChild: T) -> WithModifiersSyntax {
    var copy: WithModifiersSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `WithModifiersSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: WithModifiersSyntax.Protocol) -> Bool {
    return self.asProtocol(WithModifiersSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `WithModifiersSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: WithModifiersSyntax.Protocol) -> WithModifiersSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? WithModifiersSyntax
  }
}

// MARK: - WithOptionalCodeBlockSyntax

public protocol WithOptionalCodeBlockSyntax: SyntaxProtocol {
  var body: CodeBlockSyntax? {
    get
    set
  }
}

extension WithOptionalCodeBlockSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<WithOptionalCodeBlockSyntax, T>, _ newChild: T) -> WithOptionalCodeBlockSyntax {
    var copy: WithOptionalCodeBlockSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `WithOptionalCodeBlockSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: WithOptionalCodeBlockSyntax.Protocol) -> Bool {
    return self.asProtocol(WithOptionalCodeBlockSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `WithOptionalCodeBlockSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: WithOptionalCodeBlockSyntax.Protocol) -> WithOptionalCodeBlockSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? WithOptionalCodeBlockSyntax
  }
}

// MARK: - WithStatementsSyntax

public protocol WithStatementsSyntax: SyntaxProtocol {
  var statements: CodeBlockItemListSyntax {
    get
    set
  }
}

extension WithStatementsSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<WithStatementsSyntax, T>, _ newChild: T) -> WithStatementsSyntax {
    var copy: WithStatementsSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `WithStatementsSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: WithStatementsSyntax.Protocol) -> Bool {
    return self.asProtocol(WithStatementsSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `WithStatementsSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: WithStatementsSyntax.Protocol) -> WithStatementsSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? WithStatementsSyntax
  }
}

// MARK: - WithTrailingCommaSyntax

public protocol WithTrailingCommaSyntax: SyntaxProtocol {
  /// ### Tokens
  /// 
  /// For syntax trees generated by the parser, this is guaranteed to be `,`.
  var trailingComma: TokenSyntax? {
    get
    set
  }
}

extension WithTrailingCommaSyntax {
  /// Without this function, the `with` function defined on `SyntaxProtocol`
  /// does not work on existentials of this protocol type.
  @_disfavoredOverload
  public func with<T>(_ keyPath: WritableKeyPath<WithTrailingCommaSyntax, T>, _ newChild: T) -> WithTrailingCommaSyntax {
    var copy: WithTrailingCommaSyntax = self
    copy[keyPath: keyPath] = newChild
    return copy
  }
}

extension SyntaxProtocol {
  /// Check whether the non-type erased version of this syntax node conforms to
  /// `WithTrailingCommaSyntax`.
  /// Note that this will incur an existential conversion.
  public func isProtocol(_: WithTrailingCommaSyntax.Protocol) -> Bool {
    return self.asProtocol(WithTrailingCommaSyntax.self) != nil
  }
  
  /// Return the non-type erased version of this syntax node if it conforms to
  /// `WithTrailingCommaSyntax`. Otherwise return `nil`.
  /// Note that this will incur an existential conversion.
  public func asProtocol(_: WithTrailingCommaSyntax.Protocol) -> WithTrailingCommaSyntax? {
    return Syntax(self).asProtocol(SyntaxProtocol.self) as? WithTrailingCommaSyntax
  }
}

extension AccessorBlockSyntax: BracedSyntax {}

extension AccessorDeclSyntax: WithOptionalCodeBlockSyntax, WithAttributesSyntax {}

extension AccessorEffectSpecifiersSyntax: EffectSpecifiersSyntax {}

extension AccessorParametersSyntax: ParenthesizedSyntax {}

extension ActorDeclSyntax: DeclGroupSyntax, NamedDeclSyntax, WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax {}

extension ArrayElementSyntax: WithTrailingCommaSyntax {}

extension AssociatedTypeDeclSyntax: NamedDeclSyntax, WithAttributesSyntax, WithModifiersSyntax {}

extension AttributedTypeSyntax: WithAttributesSyntax {}

extension AvailabilityArgumentSyntax: WithTrailingCommaSyntax {}

extension CatchClauseSyntax: WithCodeBlockSyntax {}

extension CatchItemSyntax: WithTrailingCommaSyntax {}

extension ClassDeclSyntax: DeclGroupSyntax, NamedDeclSyntax, WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax {}

extension ClosureCaptureSyntax: WithTrailingCommaSyntax {}

extension ClosureExprSyntax: BracedSyntax, WithStatementsSyntax {}

extension ClosureParameterClauseSyntax: ParenthesizedSyntax {}

extension ClosureParameterSyntax: WithTrailingCommaSyntax, WithAttributesSyntax, WithModifiersSyntax {}

extension ClosureShorthandParameterSyntax: WithTrailingCommaSyntax {}

extension ClosureSignatureSyntax: WithAttributesSyntax {}

extension CodeBlockSyntax: BracedSyntax, WithStatementsSyntax {}

extension ConditionElementSyntax: WithTrailingCommaSyntax {}

extension DeclModifierDetailSyntax: ParenthesizedSyntax {}

extension DeclNameArgumentsSyntax: ParenthesizedSyntax {}

extension DeferStmtSyntax: WithCodeBlockSyntax {}

extension DeinitializerDeclSyntax: WithAttributesSyntax, WithModifiersSyntax, WithOptionalCodeBlockSyntax {}

extension DictionaryElementSyntax: WithTrailingCommaSyntax {}

extension DifferentiabilityArgumentSyntax: WithTrailingCommaSyntax {}

extension DoExprSyntax: WithCodeBlockSyntax {}

extension DoStmtSyntax: WithCodeBlockSyntax {}

extension DocumentationAttributeArgumentSyntax: WithTrailingCommaSyntax {}

extension EditorPlaceholderDeclSyntax: WithAttributesSyntax, WithModifiersSyntax {}

extension EnumCaseDeclSyntax: WithAttributesSyntax, WithModifiersSyntax {}

extension EnumCaseElementSyntax: WithTrailingCommaSyntax {}

extension EnumCaseParameterClauseSyntax: ParenthesizedSyntax {}

extension EnumCaseParameterSyntax: WithTrailingCommaSyntax, WithModifiersSyntax {}

extension EnumDeclSyntax: DeclGroupSyntax, NamedDeclSyntax, WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax {}

extension ExpressionSegmentSyntax: ParenthesizedSyntax {}

extension ExtensionDeclSyntax: DeclGroupSyntax, WithAttributesSyntax, WithModifiersSyntax {}

extension ForStmtSyntax: WithCodeBlockSyntax {}

extension FunctionDeclSyntax: NamedDeclSyntax, WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax, WithOptionalCodeBlockSyntax {}

extension FunctionEffectSpecifiersSyntax: EffectSpecifiersSyntax {}

extension FunctionParameterClauseSyntax: ParenthesizedSyntax {}

extension FunctionParameterSyntax: WithTrailingCommaSyntax, WithAttributesSyntax, WithModifiersSyntax {}

extension FunctionTypeSyntax: ParenthesizedSyntax {}

extension GenericArgumentSyntax: WithTrailingCommaSyntax {}

extension GenericParameterSyntax: WithTrailingCommaSyntax, WithAttributesSyntax {}

extension GenericRequirementSyntax: WithTrailingCommaSyntax {}

extension GuardStmtSyntax: WithCodeBlockSyntax {}

extension IfExprSyntax: WithCodeBlockSyntax {}

extension ImportDeclSyntax: WithAttributesSyntax, WithModifiersSyntax {}

extension InheritedTypeSyntax: WithTrailingCommaSyntax {}

extension InitializerDeclSyntax: WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax, WithOptionalCodeBlockSyntax {}

extension LabeledExprSyntax: WithTrailingCommaSyntax {}

extension LabeledSpecializeArgumentSyntax: WithTrailingCommaSyntax {}

extension LifetimeSpecifierArgumentSyntax: WithTrailingCommaSyntax {}

extension MacroDeclSyntax: NamedDeclSyntax, WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax {}

extension MacroExpansionDeclSyntax: FreestandingMacroExpansionSyntax, WithAttributesSyntax, WithModifiersSyntax {}

extension MacroExpansionExprSyntax: FreestandingMacroExpansionSyntax {}

extension MemberBlockSyntax: BracedSyntax {}

extension MissingDeclSyntax: MissingNodeSyntax, WithAttributesSyntax, WithModifiersSyntax {}

extension MissingExprSyntax: MissingNodeSyntax {}

extension MissingPatternSyntax: MissingNodeSyntax {}

extension MissingStmtSyntax: MissingNodeSyntax {}

extension MissingSyntax: MissingNodeSyntax {}

extension MissingTypeSyntax: MissingNodeSyntax {}

extension OperatorDeclSyntax: NamedDeclSyntax {}

extension PatternBindingSyntax: WithTrailingCommaSyntax {}

extension PlatformVersionItemSyntax: WithTrailingCommaSyntax {}

extension PoundSourceLocationSyntax: ParenthesizedSyntax {}

extension PrecedenceGroupDeclSyntax: BracedSyntax, NamedDeclSyntax, WithAttributesSyntax, WithModifiersSyntax {}

extension PrecedenceGroupNameSyntax: WithTrailingCommaSyntax {}

extension PrimaryAssociatedTypeSyntax: WithTrailingCommaSyntax {}

extension ProtocolDeclSyntax: DeclGroupSyntax, NamedDeclSyntax, WithAttributesSyntax, WithModifiersSyntax {}

extension RepeatStmtSyntax: WithCodeBlockSyntax {}

extension SourceFileSyntax: WithStatementsSyntax {}

extension SpecializeTargetFunctionArgumentSyntax: WithTrailingCommaSyntax {}

extension StructDeclSyntax: DeclGroupSyntax, NamedDeclSyntax, WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax {}

extension SubscriptDeclSyntax: WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax {}

extension SwitchCaseItemSyntax: WithTrailingCommaSyntax {}

extension SwitchCaseSyntax: WithStatementsSyntax {}

extension SwitchExprSyntax: BracedSyntax {}

extension TupleExprSyntax: ParenthesizedSyntax {}

extension TuplePatternElementSyntax: WithTrailingCommaSyntax {}

extension TuplePatternSyntax: ParenthesizedSyntax {}

extension TupleTypeElementSyntax: WithTrailingCommaSyntax {}

extension TupleTypeSyntax: ParenthesizedSyntax {}

extension TypeAliasDeclSyntax: NamedDeclSyntax, WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax {}

extension TypeEffectSpecifiersSyntax: EffectSpecifiersSyntax {}

extension VariableDeclSyntax: WithAttributesSyntax, WithModifiersSyntax {}

extension WhileStmtSyntax: WithCodeBlockSyntax {}