findAllBridgedEnumsByName method
Returns every bridged enum registered under name across the scope chain
— the primary (last-wins) enum of each scope first, followed by any
same-name enums it displaced.
Mirrors findAllBridgedClassesByName. Returns an empty list when no enum
with name is registered, and a single-element list in the ordinary case;
a longer list means two different definitions are competing for the name,
which is what scc76_bridge_name_collision_test.dart asserts against.
Implementation
List<BridgedEnum> findAllBridgedEnumsByName(String name) {
final result = <BridgedEnum>[];
Environment? current = this;
while (current != null) {
final primary = current._bridgedEnumsRaw?[name];
if (primary != null && !result.any((e) => identical(e, primary))) {
result.add(primary);
}
final shadowed = current._shadowedEnumsRaw?[name];
if (shadowed != null) {
for (final e in shadowed) {
if (!result.any((x) => identical(x, e))) result.add(e);
}
}
current = current._enclosing;
}
return result;
}