@@ -42,6 +42,9 @@ public class Node: NodeChoiceConvertible {
4242
4343 public let experimentalFeature : ExperimentalFeature ?
4444
45+ /// SPI name if this node is only available for the SPI.
46+ public let spi : TokenSyntax ?
47+
4548 /// When the node name is printed for diagnostics, this name is used.
4649 /// If `nil`, `nameForDiagnostics` will print the parent node’s name.
4750 public let nameForDiagnostics : String ?
@@ -103,6 +106,14 @@ public class Node: NodeChoiceConvertible {
103106 """
104107 experimentalSPI. with ( \. trailingTrivia, . newline)
105108 }
109+ if let spi = self . spi {
110+ let spiAttr : AttributeListSyntax = """
111+ #if compiler(>=5.8)
112+ @_spi( \( spi) )
113+ #endif
114+ """
115+ spiAttr. with ( \. trailingTrivia, . newline)
116+ }
106117 if forRaw {
107118 " @_spi(RawSyntax) "
108119 }
@@ -119,6 +130,7 @@ public class Node: NodeChoiceConvertible {
119130 kind: SyntaxNodeKind ,
120131 base: SyntaxNodeKind ,
121132 experimentalFeature: ExperimentalFeature ? = nil ,
133+ spi: TokenSyntax ? = nil ,
122134 nameForDiagnostics: String ? ,
123135 documentation: String ? = nil ,
124136 parserFunction: TokenSyntax ? = nil ,
@@ -132,6 +144,7 @@ public class Node: NodeChoiceConvertible {
132144 self . kind = kind
133145 self . base = base
134146 self . experimentalFeature = experimentalFeature
147+ self . spi = spi
135148 self . nameForDiagnostics = nameForDiagnostics
136149 self . documentation = SwiftSyntax . Trivia. docCommentTrivia ( from: documentation)
137150 self . parserFunction = parserFunction
@@ -141,6 +154,10 @@ public class Node: NodeChoiceConvertible {
141154 self . data = . layout( children: childrenWithUnexpected, childHistory: childHistory, traits: traits)
142155 }
143156
157+ public var hiddenInDocumentation : Bool {
158+ self . isExperimental || self . spi != nil || self . kind. isDeprecated
159+ }
160+
144161 /// A doc comment that lists all the nodes in which this node occurs as a child in.
145162 public var containedIn : SwiftSyntax . Trivia {
146163 if kind == . unexpectedNodes {
@@ -149,7 +166,10 @@ public class Node: NodeChoiceConvertible {
149166 return [ ]
150167 }
151168 var childIn : [ ( node: SyntaxNodeKind , child: Child ? ) ] = [ ]
152- for node in SYNTAX_NODES where !node. isExperimental {
169+ for node in SYNTAX_NODES {
170+ if !self . hiddenInDocumentation && node. hiddenInDocumentation {
171+ continue
172+ }
153173 if let layout = node. layoutNode {
154174 for child in layout. children {
155175 if child. kinds. contains ( self . kind) {
@@ -202,7 +222,7 @@ public class Node: NodeChoiceConvertible {
202222
203223 let list =
204224 SYNTAX_NODES
205- . filter { $0. base == self . kind && !$0. isExperimental && !$0 . kind . isDeprecated }
225+ . filter { $0. base == self . kind && ( !$0. hiddenInDocumentation || self . hiddenInDocumentation ) }
206226 . map { " - \( $0. kind. doccLink) " }
207227 . joined ( separator: " \n " )
208228
@@ -226,6 +246,7 @@ public class Node: NodeChoiceConvertible {
226246 kind: SyntaxNodeKind ,
227247 base: SyntaxNodeKind ,
228248 experimentalFeature: ExperimentalFeature ? = nil ,
249+ spi: TokenSyntax ? = nil ,
229250 nameForDiagnostics: String ? ,
230251 documentation: String ? = nil ,
231252 parserFunction: TokenSyntax ? = nil ,
@@ -235,6 +256,7 @@ public class Node: NodeChoiceConvertible {
235256 precondition ( base == . syntaxCollection)
236257 self . base = base
237258 self . experimentalFeature = experimentalFeature
259+ self . spi = spi
238260 self . nameForDiagnostics = nameForDiagnostics
239261 self . documentation = SwiftSyntax . Trivia. docCommentTrivia ( from: documentation)
240262 self . parserFunction = parserFunction
0 commit comments