@@ -142,14 +142,14 @@ fileprivate class RuleStatusCollectionVisitor: SyntaxVisitor {
142
142
case subset( ruleNames: [ String ] )
143
143
}
144
144
145
- /// Computes source locations and ranges for syntax nodes in a source file.
146
- private let sourceLocationConverter : SourceLocationConverter
147
-
148
145
/// Cached regex object for ignoring rules at the node.
149
- private let ignoreRegex : IgnoreDirective . RegexExpression
146
+ private static let ignoreRegex : IgnoreDirective . RegexExpression = IgnoreDirective . node . makeRegex ( )
150
147
151
148
/// Cached regex object for ignoring rules at the file.
152
- private let ignoreFileRegex : IgnoreDirective . RegexExpression
149
+ private static let ignoreFileRegex : IgnoreDirective . RegexExpression = IgnoreDirective . file. makeRegex ( )
150
+
151
+ /// Computes source locations and ranges for syntax nodes in a source file.
152
+ private let sourceLocationConverter : SourceLocationConverter
153
153
154
154
/// Stores the source ranges in which all rules are ignored.
155
155
var allRulesIgnoredRanges : [ SourceRange ] = [ ]
@@ -158,9 +158,6 @@ fileprivate class RuleStatusCollectionVisitor: SyntaxVisitor {
158
158
var ruleMap : [ String : [ SourceRange ] ] = [ : ]
159
159
160
160
init ( sourceLocationConverter: SourceLocationConverter ) {
161
- ignoreRegex = IgnoreDirective . node. makeRegex ( )
162
- ignoreFileRegex = IgnoreDirective . file. makeRegex ( )
163
-
164
161
self . sourceLocationConverter = sourceLocationConverter
165
162
super. init ( viewMode: . sourceAccurate)
166
163
}
@@ -176,23 +173,23 @@ fileprivate class RuleStatusCollectionVisitor: SyntaxVisitor {
176
173
afterLeadingTrivia: false ,
177
174
afterTrailingTrivia: true
178
175
)
179
- return appendRuleStatus ( from: firstToken, of: sourceRange, using: ignoreFileRegex)
176
+ return appendRuleStatus ( from: firstToken, of: sourceRange, using: Self . ignoreFileRegex)
180
177
}
181
178
182
179
override func visit( _ node: CodeBlockItemSyntax ) -> SyntaxVisitorContinueKind {
183
180
guard let firstToken = node. firstToken ( viewMode: . sourceAccurate) else {
184
181
return . visitChildren
185
182
}
186
183
let sourceRange = node. sourceRange ( converter: sourceLocationConverter)
187
- return appendRuleStatus ( from: firstToken, of: sourceRange, using: ignoreRegex)
184
+ return appendRuleStatus ( from: firstToken, of: sourceRange, using: Self . ignoreRegex)
188
185
}
189
186
190
187
override func visit( _ node: MemberBlockItemSyntax ) -> SyntaxVisitorContinueKind {
191
188
guard let firstToken = node. firstToken ( viewMode: . sourceAccurate) else {
192
189
return . visitChildren
193
190
}
194
191
let sourceRange = node. sourceRange ( converter: sourceLocationConverter)
195
- return appendRuleStatus ( from: firstToken, of: sourceRange, using: ignoreRegex)
192
+ return appendRuleStatus ( from: firstToken, of: sourceRange, using: Self . ignoreRegex)
196
193
}
197
194
198
195
// MARK: - Helper Methods
0 commit comments