Classes

The following classes are available globally.

  • A Swift syntax visitor that collects declarations.

    Create an instance of DeclarationCollector and pass it by reference when walking an AST created by SyntaxParser to collect any visited declarations:

    import SwiftSyntax
    import SwiftSemantics
    
    let source = #"enum E {}"#
    
    var collector = DeclarationCollector()
    let tree = try SyntaxParser.parse(source: source)
    tree.walk(&collector)
    
    collector.enumerations.first?.name // "E"
    
    See more

    Declaration

    Swift

    open class DeclarationCollector
    extension DeclarationCollector: SyntaxVisitor