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.addPropertyAccess((PropertyAccess node) {
if (node.propertyName.name != 'scrollbarTheme') return;
final target = node.realTarget;
if (target is! MethodInvocation) return;
if (target.methodName.name != 'of') return;
final themeTarget = target.target;
if (themeTarget is! SimpleIdentifier || themeTarget.name != 'Theme') {
return;
}
final methodElement = target.methodName.element;
if (methodElement is MethodElement &&
!_isFlutterPackageLibrary(methodElement.library)) {
return;
}
reporter.atNode(node);
});
}