uniqueName method

String uniqueName(
  1. String base
)

A fresh identifier-shaped name — names are field names in the file, so they must be unique and valid Dart identifiers from the moment a node is created, not sanitized at save time.

Implementation

String uniqueName(String base) {
  var taken = {for (var (n, _) in walk()) n.name};
  var i = 1;
  while (taken.contains('$base$i')) {
    i++;
  }
  return '$base$i';
}