entryOfInstance function
instance's library entry (V-5): the exact key@version of its
definition's SymbolComponent, else the key's highest version; null
when the library has neither.
Implementation
SymbolEntry? entryOfInstance(
SymbolLibrary library, DraftDocument doc, Handle instance) {
final node = doc.tree[instance];
if (node is! InstanceNode) return null;
final c = doc.components.get<SymbolComponent>(node.definition);
if (c == null) return null;
SymbolEntry? highest;
for (final e in library.entries) {
if (e.key != c.key) continue;
if (e.version == c.version) return e;
if (highest == null || e.version > highest.version) highest = e;
}
return highest;
}