localScopeOf method
The LocalScope node id (in instance) gives itself and the nodes
inside it, or null when it gives none (localNames) or nothing binds.
Implementation
LocalScope? localScopeOf(NodeSource source, String id, Object? instance) {
final n = source.node(id);
if (n == null || !_binds) return null;
final names = _localNamesOf(n);
if (names.isEmpty) return null;
final existing = _locals[(id, instance)];
if (existing != null && setEquals(existing.names, names)) return existing;
existing?.dispose();
final parentId = source.parentOf(id);
final parentNode = parentId == null ? null : source.node(parentId);
// An item's root reads around it what the item does.
final around = parentId == null || parentNode == null || _repeats(source, parentNode)
? _itemScopeFor(source, id, instance)
: scopeFor(source, parentId, instance);
return _locals[(id, instance)] = LocalScope(names, parent: around);
}