check method

  1. @override
void check(
  1. DcqRegistry registry
)

Implementation

@override
void check(
  DcqRegistry registry,
) {
  registry.addMethodInvocation((node) {
    final target = node.target;
    if (target != null && target is! ThisExpression) return;

    final name = node.methodName.name;

    final enclosingMethod = _findEnclosingMethod(node);
    if (enclosingMethod != null && enclosingMethod.name.lexeme == name) {
      reportAtNode(node);
      return;
    }

    final enclosingFunction = _findEnclosingFunction(node);
    if (enclosingFunction != null &&
        target == null &&
        enclosingFunction.name.lexeme == name) {
      reportAtNode(node);
    }
  });
}