classPlusMethodName static method
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 ||
parent is MixinDeclaration ||
parent is EnumDeclaration) {
name = (parent as NamedCompilationUnitMember).name.lexeme;
break;
}
}
return name == null ? null : '${name}_$outerName';
}