| 1146 | |
| 1147 | // nearest first through what node references, as an alias can replace a node sharing its id |
| 1148 | const referenceOf = (node: BaseNode, id: NodeId): BaseNode | undefined => { |
| 1149 | if (node.c.byId) return node.byId[id] |
| 1150 | const queued = new Set<BaseNode>([node]) |
| 1151 | for (const reference of queued) { |
| 1152 | if (reference.hasAlias) return node.byId[id] |
| 1153 | if (reference.id === id) return reference |
| 1154 | for (const child of reference.children) queued.add(child) |
| 1155 | for (const other of reference.otherRefs) queued.add(other) |
| 1156 | } |
| 1157 | } |
| 1158 | |
| 1159 | const isPatternInstanceIn = (node: BaseNode, value: RegExp): boolean => { |
| 1160 | for (const id in node.byId) { |