@@ -57,6 +57,9 @@ public class Node {
57
57
/// function that should be invoked to create this node.
58
58
public let parserFunction : TokenSyntax ?
59
59
60
+ /// If `true`, if the node is deprecated and should not be used anymore.
61
+ public let isDeprecated : Bool
62
+
60
63
/// If `true`, this is for an experimental language feature, and any public
61
64
/// API generated should be SPI.
62
65
public var isExperimental : Bool { experimentalFeature != nil }
@@ -95,7 +98,7 @@ public class Node {
95
98
96
99
/// Retrieve the attributes that should be printed on any API for the
97
100
/// generated node. If `forRaw` is true, this is for the raw syntax node.
98
- public func apiAttributes( forRaw: Bool = false ) -> AttributeListSyntax {
101
+ public func apiAttributes( forRaw: Bool = false , ignoreAvailableAttribute : Bool = false ) -> AttributeListSyntax {
99
102
let attrList = AttributeListSyntax {
100
103
if isExperimental {
101
104
// SPI for enum cases currently requires Swift 5.8 to work correctly.
@@ -106,10 +109,16 @@ public class Node {
106
109
"""
107
110
experimentalSPI. with ( \. trailingTrivia, . newline)
108
111
}
112
+
109
113
if forRaw {
110
114
" @_spi(RawSyntax) "
111
115
}
116
+
117
+ if isDeprecated, !ignoreAvailableAttribute {
118
+ #"@available(*, deprecated, message: "Will be removed in a future version.")"#
119
+ }
112
120
}
121
+
113
122
return attrList. with ( \. trailingTrivia, attrList. isEmpty ? [ ] : . newline)
114
123
}
115
124
@@ -128,6 +137,7 @@ public class Node {
128
137
kind: SyntaxNodeKind ,
129
138
base: SyntaxNodeKind ,
130
139
experimentalFeature: ExperimentalFeature ? = nil ,
140
+ isDeprecated: Bool = false ,
131
141
nameForDiagnostics: String ? ,
132
142
documentation: String ? = nil ,
133
143
parserFunction: TokenSyntax ? = nil ,
@@ -140,6 +150,7 @@ public class Node {
140
150
self . kind = kind
141
151
self . base = base
142
152
self . experimentalFeature = experimentalFeature
153
+ self . isDeprecated = isDeprecated
143
154
self . nameForDiagnostics = nameForDiagnostics
144
155
self . documentation = SwiftSyntax . Trivia. docCommentTrivia ( from: documentation)
145
156
self . parserFunction = parserFunction
@@ -272,6 +283,7 @@ public class Node {
272
283
kind: SyntaxNodeKind ,
273
284
base: SyntaxNodeKind ,
274
285
experimentalFeature: ExperimentalFeature ? = nil ,
286
+ isDeprecated: Bool = false ,
275
287
nameForDiagnostics: String ? ,
276
288
documentation: String ? = nil ,
277
289
parserFunction: TokenSyntax ? = nil ,
@@ -281,6 +293,7 @@ public class Node {
281
293
precondition ( base == . syntaxCollection)
282
294
self . base = base
283
295
self . experimentalFeature = experimentalFeature
296
+ self . isDeprecated = isDeprecated
284
297
self . nameForDiagnostics = nameForDiagnostics
285
298
self . documentation = SwiftSyntax . Trivia. docCommentTrivia ( from: documentation)
286
299
self . parserFunction = parserFunction
0 commit comments