classPlusMethodName 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) {
  ClassOrMixinDeclaration classNode(n) {
    if (n == null) return null;
    if (n is ClassOrMixinDeclaration) return n;
    return classNode(n.parent);
  }

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