@@ -57,6 +57,9 @@ public class Node {
5757 /// function that should be invoked to create this node.
5858 public let parserFunction : TokenSyntax ?
5959
60+ /// If `true`, if the node is deprecated and should not be used anymore.
61+ public let isDeprecated : Bool
62+
6063 /// If `true`, this is for an experimental language feature, and any public
6164 /// API generated should be SPI.
6265 public var isExperimental : Bool { experimentalFeature != nil }
@@ -95,7 +98,7 @@ public class Node {
9598
9699 /// Retrieve the attributes that should be printed on any API for the
97100 /// 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 {
99102 let attrList = AttributeListSyntax {
100103 if isExperimental {
101104 // SPI for enum cases currently requires Swift 5.8 to work correctly.
@@ -106,10 +109,16 @@ public class Node {
106109 """
107110 experimentalSPI. with ( \. trailingTrivia, . newline)
108111 }
112+
109113 if forRaw {
110114 " @_spi(RawSyntax) "
111115 }
116+
117+ if isDeprecated, !ignoreAvailableAttribute {
118+ #"@available(*, deprecated, message: "Will be removed in a future version.")"#
119+ }
112120 }
121+
113122 return attrList. with ( \. trailingTrivia, attrList. isEmpty ? [ ] : . newline)
114123 }
115124
@@ -128,6 +137,7 @@ public class Node {
128137 kind: SyntaxNodeKind ,
129138 base: SyntaxNodeKind ,
130139 experimentalFeature: ExperimentalFeature ? = nil ,
140+ isDeprecated: Bool = false ,
131141 nameForDiagnostics: String ? ,
132142 documentation: String ? = nil ,
133143 parserFunction: TokenSyntax ? = nil ,
@@ -140,6 +150,7 @@ public class Node {
140150 self . kind = kind
141151 self . base = base
142152 self . experimentalFeature = experimentalFeature
153+ self . isDeprecated = isDeprecated
143154 self . nameForDiagnostics = nameForDiagnostics
144155 self . documentation = SwiftSyntax . Trivia. docCommentTrivia ( from: documentation)
145156 self . parserFunction = parserFunction
@@ -272,6 +283,7 @@ public class Node {
272283 kind: SyntaxNodeKind ,
273284 base: SyntaxNodeKind ,
274285 experimentalFeature: ExperimentalFeature ? = nil ,
286+ isDeprecated: Bool = false ,
275287 nameForDiagnostics: String ? ,
276288 documentation: String ? = nil ,
277289 parserFunction: TokenSyntax ? = nil ,
@@ -281,6 +293,7 @@ public class Node {
281293 precondition ( base == . syntaxCollection)
282294 self . base = base
283295 self . experimentalFeature = experimentalFeature
296+ self . isDeprecated = isDeprecated
284297 self . nameForDiagnostics = nameForDiagnostics
285298 self . documentation = SwiftSyntax . Trivia. docCommentTrivia ( from: documentation)
286299 self . parserFunction = parserFunction
0 commit comments