runWithReporter method
Override this method to implement your lint rule.
Use context to register callbacks for AST node types:
context.addMethodInvocation((node) {
if (condition) {
reporter.atNode(node);
}
});
Implementation
@override
void runWithReporter(
SaropaDiagnosticReporter reporter,
SaropaContext context,
) {
context.addPrefixedIdentifier((PrefixedIdentifier node) {
if (node.prefix.name != 'ConnectivityResult') return;
if (!_connectivityValues.contains(node.identifier.name)) return;
// Walk up to find enclosing binary expression (== or !=)
AstNode? current = node.parent;
while (current != null) {
if (current is BinaryExpression) {
final String op = current.operator.lexeme;
if (op == '==' || op == '!=') {
reporter.atNode(current);
return;
}
}
// Stop at statement boundary
if (current is Statement || current is FunctionBody) break;
current = current.parent;
}
});
}