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 (!_isHomeWidgetCall(node, const <String>{'saveWidgetData'})) return;
if (!fileImportsPackage(node, PackageImports.homeWidget)) return;
final FunctionBody? body = _enclosingMemberBody(node);
if (body == null) return;
final _HomeWidgetScan scan = _HomeWidgetScan();
body.accept(scan);
final bool hasUpdate = scan.invocations.any(
(MethodInvocation inv) =>
_isHomeWidgetCall(inv, const <String>{'updateWidget'}),
);
if (hasUpdate) return;
reporter.atNode(node);
});
}