String _prettifyMember()

in lib/source_map_stack_trace.dart [79:104]


String _prettifyMember(String member) {
  return member
      // Get rid of the noise that Firefox sometimes adds.
      .replaceAll(RegExp(r'/?<$'), '')
      // Get rid of arity indicators and named arguments.
      .replaceAll(RegExp(r'\$\d+(\$[a-zA-Z_0-9]+)*$'), '')
      // Convert closures to <fn>.
      .replaceAllMapped(
          RegExp(r'(_+)closure\d*\.call$'),
          // The number of underscores before "closure" indicates how nested it
          // is.
          (match) => '.<fn>' * match[1]!.length)
      // Get rid of explicitly-generated calls.
      .replaceAll(RegExp(r'\.call$'), '')
      // Get rid of the top-level method prefix.
      .replaceAll(RegExp(r'^dart\.'), '')
      // Get rid of library namespaces.
      .replaceAll(RegExp(r'[a-zA-Z_0-9]+\$'), '')
      // Get rid of the static method prefix. The class name also exists in the
      // invocation, so we're not getting rid of any information.
      .replaceAll(RegExp(r'^[a-zA-Z_0-9]+.(static|dart).'), '')
      // Convert underscores after identifiers to dots. This runs the risk of
      // incorrectly converting members that contain underscores, but those are
      // contrary to the style guide anyway.
      .replaceAllMapped(RegExp(r'([a-zA-Z0-9]+)_'), (match) => match[1]! + '.');
}