startUp method

  1. @override
Future<void> startUp(
  1. CustomLintResolver resolver,
  2. CustomLintContext context,
  3. SourceRange target
)
inherited

Emits lints for a given file.

run will only be invoked with files respecting filesToAnalyze

Implementation

@override
Future<void> startUp(
  CustomLintResolver resolver,
  CustomLintContext context,
  SourceRange target,
) async {
  // Relying on shared state to execute all linters in a single AstVisitor
  if (context.sharedState.containsKey(_stateKey)) return;
  context.sharedState[_stateKey] = Object();

  final unit = await resolver.getResolvedUnitResult();

  context.addPostRunCallback(() {
    final linterVisitor = LinterVisitor(context.registry.nodeLintRegistry);

    unit.unit.accept(linterVisitor);
  });
}