resolve method

List<String> resolve(
  1. String list
)

The paths a list (core,tom_ai/basics) names. Throws RepoNameException for an unknown or ambiguous name, naming the candidates.

Implementation

List<String> resolve(String list) {
  final out = <String>[];
  for (final raw in list.split(',')) {
    final name = raw.trim();
    if (name.isEmpty) continue;
    final path = name == '.' ? '' : name;
    if (paths.contains(path)) {
      out.add(path);
      continue;
    }
    final matches = _bySegment[name] ?? const <String>[];
    if (matches.length == 1) {
      out.add(matches.single);
      continue;
    }
    if (matches.length > 1) {
      throw RepoNameException(name, ambiguous: true, candidates: matches);
    }
    final lower = name.toLowerCase();
    final near = [
      for (final p in paths)
        if (p.toLowerCase().contains(lower)) p.isEmpty ? '.' : p,
    ];
    throw RepoNameException(name, ambiguous: false, candidates: near);
  }
  return out;
}