Handle extensions

This commit is contained in:
Marcelo Fabri 2022-11-06 20:52:53 -08:00
parent f81e28c574
commit ce212e745e
1 changed files with 17 additions and 1 deletions

View File

@ -68,6 +68,13 @@ public struct ExplicitACLRule: SwiftSyntaxRule, OptInRule, ConfigurationProvider
} }
} }
} }
"""),
Example("""
private extension Foo {
var isValid: Bool {
true
}
}
""") """)
], ],
triggeringExamples: [ triggeringExamples: [
@ -100,7 +107,7 @@ private extension ExplicitACLRule {
SubscriptDeclSyntax.self, SubscriptDeclSyntax.self,
VariableDeclSyntax.self, VariableDeclSyntax.self,
ProtocolDeclSyntax.self, ProtocolDeclSyntax.self,
InitializerDeclSyntax.self, InitializerDeclSyntax.self
] ]
} }
@ -178,6 +185,15 @@ private extension ExplicitACLRule {
} }
} }
override func visit(_ node: ExtensionDeclSyntax) -> SyntaxVisitorContinueKind {
guard let modifiers = node.modifiers,
modifiers.contains(where: \.isACLModifier) else {
return .visitChildren
}
return .skipChildren
}
override func visit(_ node: CodeBlockSyntax) -> SyntaxVisitorContinueKind { override func visit(_ node: CodeBlockSyntax) -> SyntaxVisitorContinueKind {
.skipChildren .skipChildren
} }