ASTRule
public protocol ASTRule : Rule
A rule that leverages the Swift source’s pre-typechecked Abstract Syntax Tree to recurse into the source’s structure, validating the rule recursively in nested source bodies.
-
The kind of token being recursed over.
Declaration
Swift
associatedtype KindType : RawRepresentable
-
Executes the rule on a file and a subset of its AST structure, returning any violations to the rule’s expectations.
Declaration
Swift
func validate(file: SwiftLintFile, kind: KindType, dictionary: SourceKittenDictionary) -> [StyleViolation]
Parameters
file
The file for which to execute the rule.
kind
The kind of token being recursed over.
dictionary
The dictionary for an AST subset to validate.
Return Value
All style violations to the rule’s expectations.
-
Get the
kind
from the specified dictionary.Declaration
Swift
func kind(from dictionary: SourceKittenDictionary) -> KindType?
Parameters
dictionary
The
SourceKittenDictionary
representing the source structure from which to extract thekind
.Return Value
The
kind
from the specified dictionary, if one was found. -
validate(file:
Extension method) Declaration
Swift
func validate(file: SwiftLintFile) -> [StyleViolation]
-
validate(file:
Extension methoddictionary: ) Executes the rule on a file and a subset of its AST structure, returning any violations to the rule’s expectations.
Declaration
Swift
func validate(file: SwiftLintFile, dictionary: SourceKittenDictionary) -> [StyleViolation]
Parameters
file
The file for which to execute the rule.
dictionary
The dictionary for an AST subset to validate.
Return Value
All style violations to the rule’s expectations.