SwiftSyntaxRule
public protocol SwiftSyntaxRule : SourceKitFreeRule
A SwiftLint Rule backed by SwiftSyntax that does not use SourceKit requests.
-
Produce a
ViolationsSyntaxVisitorfor the given file.Declaration
Swift
func makeVisitor(file: SwiftLintFile) -> ViolationsSyntaxVisitor<ConfigurationType>Parameters
fileThe file for which to produce the visitor.
Return Value
A
ViolationsSyntaxVisitorfor 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) -> StyleViolationParameters
fileThe file for which to produce the violation.
violationA 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
SwiftOperatorsto “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
fileThe 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]
-
makeViolation(file:Default implementationviolation: ) Default Implementation
Declaration
Swift
func makeViolation(file: SwiftLintFile, violation: ReasonedRuleViolation) -> StyleViolation
View on GitHub
Install in Dash