-
Notifications
You must be signed in to change notification settings - Fork 29
DeclarationCollector
A Swift syntax visitor that collects declarations.
open class DeclarationCollector: SyntaxVisitor
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"
SyntaxVisitor
Creates a new declaration collector.
public override init()
The collected associated type declarations.
var associatedTypes: [AssociatedType] = []
The collected class declarations.
var classes: [Class] = []
The collected conditional compilation block declarations.
var conditionalCompilationBlocks: [ConditionalCompilationBlock] = []
The collected deinitializer declarations.
var deinitializers: [Deinitializer] = []
The collected enumeration declarations.
var enumerations: [Enumeration] = []
The collected enumeration case declarations.
var enumerationCases: [Enumeration.Case] = []
The collected extension declarations.
var extensions: [Extension] = []
The collected function declarations.
var functions: [Function] = []
The collected import declarations.
var imports: [Import] = []
The collected initializer declarations.
var initializers: [Initializer] = []
The collected operator declarations.
var operators: [Operator] = []
The collected precedence group declarations.
var precedenceGroups: [PrecedenceGroup] = []
The collected protocol declarations.
var protocols: [Protocol] = []
The collected structure declarations.
var structures: [Structure] = []
The collected subscript declarations.
var subscripts: [Subscript] = []
The collected type alias declarations.
var typealiases: [Typealias] = []
The collected variable declarations.
var variables: [Variable] = []
Called when visiting an AssociatedtypeDeclSyntax
node
public override func visit(_ node: AssociatedtypeDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting a ClassDeclSyntax
node
public override func visit(_ node: ClassDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting a DeinitializerDeclSyntax
node
public override func visit(_ node: DeinitializerDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting an EnumDeclSyntax
node
public override func visit(_ node: EnumDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting an EnumCaseDeclSyntax
node
public override func visit(_ node: EnumCaseDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting an ExtensionDeclSyntax
node
public override func visit(_ node: ExtensionDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting a FunctionDeclSyntax
node
public override func visit(_ node: FunctionDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting an IfConfigDeclSyntax
node
public override func visit(_ node: IfConfigDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting an ImportDeclSyntax
node
public override func visit(_ node: ImportDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting an InitializerDeclSyntax
node
public override func visit(_ node: InitializerDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting an OperatorDeclSyntax
node
public override func visit(_ node: OperatorDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting a PrecedenceGroupDeclSyntax
node
public override func visit(_ node: PrecedenceGroupDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting a ProtocolDeclSyntax
node
public override func visit(_ node: ProtocolDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting a SubscriptDeclSyntax
node
public override func visit(_ node: SubscriptDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting a StructDeclSyntax
node
public override func visit(_ node: StructDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting a TypealiasDeclSyntax
node
public override func visit(_ node: TypealiasDeclSyntax) -> SyntaxVisitorContinueKind
Called when visiting a VariableDeclSyntax
node
public override func visit(_ node: VariableDeclSyntax) -> SyntaxVisitorContinueKind
Generated at 2020-08-02T12:14:07+0000 using swift-doc 1.0.0-beta.3.
Types
- AssociatedType
- Attribute
- Attribute.Argument
- Class
- ConditionalCompilationBlock
- ConditionalCompilationBlock.Branch
- DeclarationCollector
- Deinitializer
- Enumeration
- Enumeration.Case
- Extension
- Function
- Function.Parameter
- Function.Signature
- GenericParameter
- GenericRequirement
- GenericRequirement.Relation
- Import
- Initializer
- Modifier
- Operator
- Operator.Kind
- PrecedenceGroup
- PrecedenceGroup.Associativity
- PrecedenceGroup.Relation
- Protocol
- Structure
- Subscript
- Typealias
- Variable
- Variable.Accessor
- Variable.Accessor.Kind