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,
) {
context.registry.addCatchClause((catchClause) {
final body = catchClause.thisOrAncestorOfType<FunctionBody>();
if (body == null) return;
final mentionsTarget = _functionBodyHasValueNotifierWithPickerItem(body, resolver);
if (!mentionsTarget) return;
final hasRethrow = _catchHasRethrow(catchClause);
if (hasRethrow) return;
reporter.reportError(
AnalysisError.forValues(
source: resolver.source,
offset: catchClause.offset,
length: catchClause.length,
errorCode: _code,
message: 'ValueNotifier<...> 且泛型包含 PickerItem 时,catch 须包含 rethrow',
),
);
});
}