run method
void
run(
- CustomLintResolver resolver,
- ErrorReporter reporter,
- CustomLintContext context
Emits lints for a given file.
run will only be invoked with files respecting filesToAnalyze
Implementation
@override
void run(
CustomLintResolver resolver,
ErrorReporter reporter,
CustomLintContext context,
) {
final path = resolver.source.fullName.replaceAll('\\', '/');
if (_isExempt(path)) return;
context.registry.addMethodInvocation((node) {
final target = node.realTarget;
if (target == null) return;
final name = switch (target) {
Identifier() => target.name,
_ => null,
};
if (name != 'Hive') return;
final uri = _libraryUri(_resolveElement(target));
if (!_isHiveLib(uri)) return;
reporter.atNode(node, _code);
});
context.registry.addPrefixedIdentifier((node) {
if (node.prefix.name != 'Hive') return;
final uri = _libraryUri(node.prefix.staticElement);
if (!_isHiveLib(uri)) return;
reporter.atNode(node, _code);
});
}