@@ -42,6 +42,9 @@ public class Node: NodeChoiceConvertible {
42
42
43
43
public let experimentalFeature : ExperimentalFeature ?
44
44
45
+ /// SPI name if this node is only available for the SPI.
46
+ public let spi : TokenSyntax ?
47
+
45
48
/// When the node name is printed for diagnostics, this name is used.
46
49
/// If `nil`, `nameForDiagnostics` will print the parent node’s name.
47
50
public let nameForDiagnostics : String ?
@@ -103,6 +106,14 @@ public class Node: NodeChoiceConvertible {
103
106
"""
104
107
experimentalSPI. with ( \. trailingTrivia, . newline)
105
108
}
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
+ }
106
117
if forRaw {
107
118
" @_spi(RawSyntax) "
108
119
}
@@ -119,6 +130,7 @@ public class Node: NodeChoiceConvertible {
119
130
kind: SyntaxNodeKind ,
120
131
base: SyntaxNodeKind ,
121
132
experimentalFeature: ExperimentalFeature ? = nil ,
133
+ spi: TokenSyntax ? = nil ,
122
134
nameForDiagnostics: String ? ,
123
135
documentation: String ? = nil ,
124
136
parserFunction: TokenSyntax ? = nil ,
@@ -132,6 +144,7 @@ public class Node: NodeChoiceConvertible {
132
144
self . kind = kind
133
145
self . base = base
134
146
self . experimentalFeature = experimentalFeature
147
+ self . spi = spi
135
148
self . nameForDiagnostics = nameForDiagnostics
136
149
self . documentation = SwiftSyntax . Trivia. docCommentTrivia ( from: documentation)
137
150
self . parserFunction = parserFunction
@@ -141,6 +154,10 @@ public class Node: NodeChoiceConvertible {
141
154
self . data = . layout( children: childrenWithUnexpected, childHistory: childHistory, traits: traits)
142
155
}
143
156
157
+ public var hiddenInDocumentation : Bool {
158
+ self . isExperimental || self . spi != nil || self . kind. isDeprecated
159
+ }
160
+
144
161
/// A doc comment that lists all the nodes in which this node occurs as a child in.
145
162
public var containedIn : SwiftSyntax . Trivia {
146
163
if kind == . unexpectedNodes {
@@ -149,7 +166,10 @@ public class Node: NodeChoiceConvertible {
149
166
return [ ]
150
167
}
151
168
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
+ }
153
173
if let layout = node. layoutNode {
154
174
for child in layout. children {
155
175
if child. kinds. contains ( self . kind) {
@@ -202,7 +222,7 @@ public class Node: NodeChoiceConvertible {
202
222
203
223
let list =
204
224
SYNTAX_NODES
205
- . filter { $0. base == self . kind && !$0. isExperimental && !$0 . kind . isDeprecated }
225
+ . filter { $0. base == self . kind && ( !$0. hiddenInDocumentation || self . hiddenInDocumentation ) }
206
226
. map { " - \( $0. kind. doccLink) " }
207
227
. joined ( separator: " \n " )
208
228
@@ -226,6 +246,7 @@ public class Node: NodeChoiceConvertible {
226
246
kind: SyntaxNodeKind ,
227
247
base: SyntaxNodeKind ,
228
248
experimentalFeature: ExperimentalFeature ? = nil ,
249
+ spi: TokenSyntax ? = nil ,
229
250
nameForDiagnostics: String ? ,
230
251
documentation: String ? = nil ,
231
252
parserFunction: TokenSyntax ? = nil ,
@@ -235,6 +256,7 @@ public class Node: NodeChoiceConvertible {
235
256
precondition ( base == . syntaxCollection)
236
257
self . base = base
237
258
self . experimentalFeature = experimentalFeature
259
+ self . spi = spi
238
260
self . nameForDiagnostics = nameForDiagnostics
239
261
self . documentation = SwiftSyntax . Trivia. docCommentTrivia ( from: documentation)
240
262
self . parserFunction = parserFunction
0 commit comments