// Make sure inputs from the disconnected subtree make sense.
Set<CollectorGem> affectedCollectorSet = new HashSet<CollectorGem>(reconcileArgumentTargetsOnDisconnect(conn));
{
PartInput freedInput = conn.getDestination();
Gem.PartOutput disconnectedOutput = conn.getSource();
// (HACK!?) Temporarily re-bind a connection so that argument target resolution can take place for the connected tree.
// Collectors targeted by arguments on trees rooted at collectors at inner scopes of the current tree will be affected.
freedInput.bindConnection(conn);
disconnectedOutput.bindConnection(conn);
// Find collectors targeted by free inputs in the descendant gem forest
// (when considering the gem graph after connection)
List<PartInput> freeInputsInDescendantForestList =
GemGraph.obtainUnboundDescendantInputs(freedInput.getGem(), TraversalScope.FOREST, InputCollectMode.UNBURNT_ONLY);
for (final PartInput partInput : freeInputsInDescendantForestList) {
CollectorGem inputArgumentTarget = GemGraph.getInputArgumentTarget(partInput);
if (inputArgumentTarget != null) {
affectedCollectorSet.add(inputArgumentTarget);
}
}
// Unbind the connection.
freedInput.bindConnection(null);
disconnectedOutput.bindConnection(null);
}
// Update the corresponding collectors.
updateForArgumentChange(affectedCollectorSet);