run method

  1. @override
void run(
  1. CustomLintResolver resolver,
  2. ErrorReporter reporter,
  3. 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.addInstanceCreationExpression((node) {
    if (node.constructorName.type.type?.element?.name == _className) {
      var parent = node.parent;
      while (parent != null) {
        if (parent is InstanceCreationExpression &&
            parent.constructorName.type.type?.element?.name == _className) {
          reporter.atNode(node, code);
          break;
        }
        parent = parent.parent;
      }
    }
  });
}