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
configurationConfiguration of a rule.
fileFile from which the syntax tree stems from.
scopeA (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) -> BoolParameters
identifierAn identifier.
Return Value
trueif 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)
-
Declaration
Swift
override open func visit(_ node: MemberBlockSyntax) -> SyntaxVisitorContinueKind -
Declaration
Swift
override open func visitPost(_ node: MemberBlockSyntax)
View on GitHub
Install in Dash