DeclaredIdentifiersTrackingVisitor

open class DeclaredIdentifiersTrackingVisitor<Configuration: RuleConfiguration>:
        ViolationsSyntaxVisitor<Configuration>

A specialized ViolationsSyntaxVisitor that tracks declared identifiers per scope while traversing the AST.

  • A type that remembers the declared identifiers (in order) up to the current position in the code.

    Declaration

    Swift

    public typealias Scope = Stack<[IdentifierDeclaration]>
  • The hierarchical stack of identifiers declared up to the current position in the code.

    Declaration

    Swift

    public var scope: Scope
  • Initializer.

    Declaration

    Swift

    @inlinable
    public init(configuration: Configuration, file: SwiftLintFile, scope: Scope = Scope())

    Parameters

    configuration

    Configuration of a rule.

    file

    File from which the syntax tree stems from.

    scope

    A (potentially already pre-filled) scope to collect identifiers into.

  • Indicate whether a given identifier is in scope.

    Declaration

    Swift

    public func hasSeenDeclaration(for identifier: String) -> Bool

    Parameters

    identifier

    An identifier.

    Return Value

    true if the identifier was declared previously.

  • Declaration

    Swift

    override open func visit(_ node: CodeBlockItemListSyntax) -> SyntaxVisitorContinueKind
  • Declaration

    Swift

    override open func visitPost(_: CodeBlockItemListSyntax)
  • Declaration

    Swift

    override open func visitPost(_ node: VariableDeclSyntax)
  • Declaration

    Swift

    override open func visitPost(_ node: GuardStmtSyntax)

Type declaration boundaries