SwiftSyntaxRule
public protocol SwiftSyntaxRule : SourceKitFreeRule
A SwiftLint Rule backed by SwiftSyntax that does not use SourceKit requests.
-
Produce a
ViolationsSyntaxVisitor
for the given file.Declaration
Swift
func makeVisitor(file: SwiftLintFile) -> ViolationsSyntaxVisitor<ConfigurationType>
Parameters
file
The file for which to produce the visitor.
Return Value
A
ViolationsSyntaxVisitor
for the given file. -
makeViolation(file:
Default implementationviolation: ) Produce a violation for the given file and absolute position.
Default Implementation
Declaration
Swift
func makeViolation(file: SwiftLintFile, violation: ReasonedRuleViolation) -> StyleViolation
Parameters
file
The file for which to produce the violation.
violation
A violation in the file.
Return Value
A violation for the given file and absolute position.
-
preprocess(file:
Default implementation) Gives a chance for the rule to do some pre-processing on the syntax tree. One typical example is using
SwiftOperators
to “fold” the tree, resolving operators precedence. This can also be used to skip validation in a given file. By default, it just returns the file’ssyntaxTree
.Default Implementation
Declaration
Swift
func preprocess(file: SwiftLintFile) -> SourceFileSyntax?
Parameters
file
The file to run pre-processing on.
Return Value
The tree that will be used to check for violations. If
nil
, this rule will return no violations. -
validate(file:
Extension method) Declaration
Swift
@inlinable func validate(file: SwiftLintFile) -> [StyleViolation]