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) {
  String? name;
  for (AstNode? parent = node; parent != null; parent = parent.parent) {
    if (parent is ClassDeclaration) {
      name = parent.namePart.typeName.lexeme;
      break;
    } else if (parent is EnumDeclaration) {
      name = parent.namePart.typeName.lexeme;
      break;
    } else if (parent is MixinDeclaration) {
      name = parent.name.lexeme;
      break;
    }
  }

  return name == null ? null : '${name}_$outerName';
}