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.addMethodInvocation((MethodInvocation node) {
if (node.methodName.name != 'toString') return;
final Expression? target = node.target;
if (target == null) return;
final DartType? type = target.staticType;
if (type != null && _staticTypeIsFuture(type)) {
reporter.atNode(node);
}
});
context.addInterpolationExpression((InterpolationExpression node) {
final Expression expr = node.expression;
final DartType? type = expr.staticType;
if (type != null && _staticTypeIsFuture(type)) {
reporter.atNode(node);
}
});
}