classPlusMethodName static method

String? classPlusMethodName(
  1. MethodInvocation node,
  2. String? outerName
)

Return the name of the enclosing class (if any) plus method name, or null if there's no enclosing class.

For a method foo in class Bar we allow either "foo" or "Bar_Foo" as the name.

Implementation

static String? classPlusMethodName(MethodInvocation node, String? outerName) {
  ClassDeclaration? classNode(dynamic n) {
    if (n == null) return null;
    if (n is ClassDeclaration) return n;
    return classNode(n.parent);
  }

  var classDeclaration = classNode(node);
  return classDeclaration == null
      ? null
      : "${classDeclaration.name}_$outerName";
}