File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
Sources/SwiftSyntaxBuilderGeneration Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class Node {
22
22
let baseKind : String
23
23
let traits : [ String ]
24
24
let children : [ Child ]
25
+ let nonGarbageChildren : [ Child ]
25
26
let collectionElementName : String ?
26
27
let collectionElementChoices : [ String ] ?
27
28
let omitWhenEmpty : Bool
@@ -84,9 +85,30 @@ class Node {
84
85
self . description = description
85
86
86
87
self . traits = traits
87
- self . children = children
88
88
self . baseKind = kind
89
89
90
+ if kind == " SyntaxCollection " {
91
+ self . children = children
92
+ } else {
93
+ // Add implicitly generated GarbageNodes children between
94
+ // any two defined children
95
+ self . children = children. enumerated ( ) . flatMap { ( i, child) in
96
+ [
97
+ Child (
98
+ name: i == 0
99
+ ? " GarbageBefore \( child. name) "
100
+ : " GarbageBetween \( children [ i - 1 ] . name) And \( children [ i] . name) " ,
101
+ kind: " GarbageNodes " ,
102
+ isOptional: true ,
103
+ collectionElementName: name
104
+ ) ,
105
+ child,
106
+ ]
107
+ }
108
+ }
109
+
110
+ self . nonGarbageChildren = children. filter { !$0. isGarbageNodes }
111
+
90
112
if !SYNTAX_BASE_KINDS. contains ( baseKind) {
91
113
fatalError ( " unknown base kind ' \( baseKind) ' for node ' \( syntaxKind) ' " )
92
114
}
You can’t perform that action at this time.
0 commit comments