File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -314,6 +314,20 @@ public extension Syntax {
314
314
% else :
315
315
return . ${ node. swift_syntax_kind} ( ${ node. name} ( self ) !)
316
316
% end
317
+ % end
318
+ }
319
+ }
320
+
321
+ /// Retrieve the concretely typed node that this Syntax node wraps.
322
+ var asConcreteType : Any {
323
+ switch self . asSyntaxEnum {
324
+ case . token( let node) :
325
+ return node
326
+ case . unknown( let node) :
327
+ return node
328
+ % for node in SYNTAX_NODES:
329
+ case . ${ node. swift_syntax_kind} ( let node) :
330
+ return node
317
331
% end
318
332
}
319
333
}
Original file line number Diff line number Diff line change @@ -399,11 +399,11 @@ func performRoundtrip(args: CommandLineArguments) throws {
399
399
struct NodePrinter : SyntaxAnyVisitor {
400
400
func visitAny( _ node: Syntax ) -> SyntaxVisitorContinueKind {
401
401
assert ( !node. isUnknown)
402
- print ( " < \( type ( of: node) ) > " , terminator: " " )
402
+ print ( " < \( type ( of: node. asConcreteType ) ) > " , terminator: " " )
403
403
return . visitChildren
404
404
}
405
405
func visitAnyPost( _ node: Syntax ) {
406
- print ( " </ \( type ( of: node) ) > " , terminator: " " )
406
+ print ( " </ \( type ( of: node. asConcreteType ) ) > " , terminator: " " )
407
407
}
408
408
func visit( _ token: TokenSyntax ) -> SyntaxVisitorContinueKind {
409
409
print ( " < \( type ( of: token) ) > " , terminator: " " )
You can’t perform that action at this time.
0 commit comments