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 identifers (in order) up to the current position in the code.
Declaration
Swift
public typealias Scope = Stack<Set<String>>
-
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 identifers into.
-
Indicate whether a given identifier is in scope.
Declaration
Swift
public func hasSeenDeclaration(for identifier: String) -> Bool
Parameters
identifier
An identifier.
-
Declaration
Swift
override open func visit(_ node: CodeBlockItemListSyntax) -> SyntaxVisitorContinueKind
-
Declaration
Swift
override open func visitPost(_ node: CodeBlockItemListSyntax)
-
Declaration
Swift
override open func visitPost(_ node: VariableDeclSyntax)
-
Declaration
Swift
override open func visitPost(_ node: GuardStmtSyntax)