Skip to content

Commit

Permalink
Inline custom visitors (#5909)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny authored Dec 23, 2024
1 parent 610722c commit cbedb08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Source/SwiftLintCore/Visitors/BodyLengthRuleVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SwiftSyntax

/// Visitor that collection violations of code block lengths.
public final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<SeverityLevelsConfiguration<Parent>> {
private let kind: Kind
@usableFromInline let kind: Kind

/// The code block types to check.
public enum Kind {
Expand Down Expand Up @@ -31,6 +31,7 @@ public final class BodyLengthRuleVisitor<Parent: Rule>: ViolationsSyntaxVisitor<
/// - kind: The code block type to check. See ``Kind``.
/// - file: The file to collect violation for.
/// - configuration: The configuration that defines the acceptable limits.
@inlinable
public init(kind: Kind, file: SwiftLintFile, configuration: SeverityLevelsConfiguration<Parent>) {
self.kind = kind
super.init(configuration: configuration, file: file)
Expand Down
5 changes: 5 additions & 0 deletions Source/SwiftLintCore/Visitors/CodeBlockVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import SwiftSyntax

/// A visitor that collects style violations for all available code blocks.
open class CodeBlockVisitor<Configuration: RuleConfiguration>: ViolationsSyntaxVisitor<Configuration> {
@inlinable
override public init(configuration: Configuration, file: SwiftLintFile) {
super.init(configuration: configuration, file: file)
}

override open func visitPost(_ node: AccessorDeclSyntax) {
collectViolations(for: node.body)
}
Expand Down

0 comments on commit cbedb08

Please sign in to comment.