findAllBridgedClassesByName method
Returns every bridged class registered under name across the scope
chain — the primary (last-wins) bridge of each scope first, followed by
any same-name bridges it displaced.
Used by static/constructor resolution to disambiguate identically named
bridges from different packages (e.g. two libraries each exporting a
MarkdownParser): when the primary bridge lacks the requested member, the
caller can fall back to a sibling that declares it. Returns an empty list
when no bridge with name is registered.
Implementation
List<BridgedClass> findAllBridgedClassesByName(String name) {
final result = <BridgedClass>[];
Environment? current = this;
while (current != null) {
final primary = current._bridgedClassesRaw?[name];
if (primary != null && !result.any((b) => identical(b, primary))) {
result.add(primary);
}
final shadowed = current._shadowedBridgesRaw?[name];
if (shadowed != null) {
for (final b in shadowed) {
if (!result.any((x) => identical(x, b))) result.add(b);
}
}
current = current._enclosing;
}
return result;
}