signalNameForPort method
Look up the signal (hyperedge) name that connects to portId
at the parent scope of the node that owns the port.
Returns the hyperedge name, or null if no match is found.
Implementation
String? signalNameForPort(String nodeId, String portId) {
final node = nodeMap[nodeId];
if (node == null) {
return null;
}
final parent = node.parent;
if (parent == null) {
return null;
}
final hyperedges = parent.hyperedges;
if (hyperedges == null) {
return null;
}
final portIdx = node.portIndexById(portId);
if (portIdx < 0) {
return null;
}
for (final h in hyperedges) {
for (final (nId, pIdx) in h.sources) {
if (pIdx == portIdx && nId == nodeId) {
return h.name;
}
}
for (final (nId, pIdx) in h.targets) {
if (pIdx == portIdx && nId == nodeId) {
return h.name;
}
}
}
return null;
}