@@ -17,7 +17,7 @@ import SwiftSyntaxBuilder
17
17
///
18
18
/// Using the cases of this enum, children of syntax nodes can refer the syntax
19
19
/// node that defines their layout.
20
- public enum SyntaxNodeKind : String , CaseIterable , IdentifierConvertible {
20
+ public enum SyntaxNodeKind : String , CaseIterable , IdentifierConvertible , TypeConvertible {
21
21
// Please keep this list sorted alphabetically
22
22
23
23
case _canImportExpr
@@ -327,7 +327,6 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible {
327
327
}
328
328
}
329
329
330
- /// Whether this is one of the syntax base nodes.
331
330
public var isBase : Bool {
332
331
switch self {
333
332
case . decl, . expr, . pattern, . stmt, . syntax, . syntaxCollection, . type:
@@ -337,12 +336,10 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible {
337
336
}
338
337
}
339
338
340
- /// A name for this node as an identifier.
341
339
public var identifier : TokenSyntax {
342
340
return . identifier( rawValue)
343
341
}
344
342
345
- /// The type name of this node in the SwiftSyntax module.
346
343
public var syntaxType : TypeSyntax {
347
344
switch self {
348
345
case . syntax:
@@ -354,7 +351,6 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible {
354
351
}
355
352
}
356
353
357
- /// Whether the node is public API and not underscored/deprecated and can thus be referenced in docc links.
358
354
public var isAvailableInDocc : Bool {
359
355
if let node = SYNTAX_NODE_MAP [ self ] , node. isExperimental {
360
356
return false
@@ -365,39 +361,10 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible {
365
361
}
366
362
}
367
363
368
- /// If this node is non-experimental a docc link wrapped in two backticks.
369
- ///
370
- /// For experimental nodes, the node's type name in code font.
371
- public var doccLink : String {
372
- if isAvailableInDocc {
373
- return " `` \( syntaxType) `` "
374
- } else {
375
- return " ` \( syntaxType) ` "
376
- }
377
- }
378
-
379
- /// For base nodes, the name of the corresponding protocol to which all the
380
- /// concrete nodes that have this base kind, conform.
381
364
public var protocolType : TypeSyntax {
382
365
return " \( syntaxType) Protocol "
383
366
}
384
367
385
- /// The name of this node at the `RawSyntax` level.
386
- public var rawType : TypeSyntax {
387
- return " Raw \( syntaxType) "
388
- }
389
-
390
- /// For base nodes, the name of the corresponding raw protocol to which all the
391
- /// concrete raw nodes that have this base kind, conform.
392
- public var rawProtocolType : TypeSyntax {
393
- switch self {
394
- case . syntax, . syntaxCollection:
395
- return " RawSyntaxNodeProtocol "
396
- default :
397
- return " Raw \( raw: rawValue. withFirstCharacterUppercased) SyntaxNodeProtocol "
398
- }
399
- }
400
-
401
368
/// For base node types, generates the name of the protocol to which all
402
369
/// concrete leaf nodes that derive from this base kind should conform.
403
370
///
@@ -507,4 +474,8 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible {
507
474
AttributeSyntax ( #"@available(*, deprecated, renamed: " \#( syntaxType) ")"# )
508
475
}
509
476
}
477
+
478
+ public var raw : RawSyntaxNodeKind {
479
+ RawSyntaxNodeKind ( syntaxNodeKind: self )
480
+ }
510
481
}
0 commit comments