//continue for invalid sockets
if (invalidConnector(socket)) {
continue;
}
//if valid, then get link
BlockLink link = BlockLinkChecker.canLink(workspace, child, parent, socket, parent.getPlug());
//if link is invalid, continue
if (link == null) {
continue;
}
//if link is valid, then rturn it
return link;
}
}
//for every socket in parent, see if it can connect
//to the child's plug:
// P-socket <====== C-plug
if (child.hasPlug()) {
for (BlockConnector socket : parent.getSockets()) {
//continue if invalid socket
//Since we want block insertion between blocks, we don't
//want to do a total invaliCOnector check (which tests for hasBlock())
//if (invalidConnector(socket)) continue;
if (socket == null) {
continue;
}
if (child.isInfix()) {
//TAKE SPECIAL CARE FOR INFIX BLOCKS
//we want to recurse to the top level infix block
if (parent.isInfix()) {
continue;
}
//if valid, the get link
BlockLink link = BlockLinkChecker.canLink(workspace, parent, child, socket, child.getPlug());
//if link is invalid, continue
if (link == null) {
continue;
}
//if link is valid, then rturn it
return link;
} else {
//Don't NEED TO RECURSE for non-infix blocks
//if valid, the get link
BlockLink link = BlockLinkChecker.canLink(workspace, parent, child, socket, child.getPlug());
//if link is invalid, continue
if (link == null) {
continue;
}
//if link is valid, then rturn it
return link;
}
}
}
//for every socket in parent, see if it can connect
//to the child's before
// P-socket <======= C-before
if (child.hasBeforeConnector()) {
for (BlockConnector socket : parent.getSockets()) {
//continue if invalid socket
if (invalidConnector(socket)) {
continue;
}
//if valid, the get link
BlockLink link = BlockLinkChecker.canLink(workspace, parent, child, socket, child.getBeforeConnector());
//if link is invalid, continue
if (link == null) {
continue;
}
//if link is valid, then rturn it
return link;
}
}
//see if we can connect the child's before
//to the parent's after
// P-after <===== C-before
if (child.hasBeforeConnector()) {
if (parent.hasAfterConnector()) {
//before and after connectors exists
BlockLink link = BlockLinkChecker.canLink(workspace, parent, child, parent.getAfterConnector(), child.getBeforeConnector());
//if link is invalid, continue
if (link == null) {
//continue;
} else {
//if link is valid, then rturn it
return link;
}
}
}
//see if we can connect the child's after to
//the parent's before
// C-after <====== P-before
if (child.hasAfterConnector()) {
if (parent.hasBeforeConnector()) {
//before and after connectors exists
BlockLink link = BlockLinkChecker.canLink(workspace, child, parent, child.getAfterConnector(), parent.getBeforeConnector());
//if link is invalid, continue
if (link == null) {
//continue;
} else {
//if link is valid, then rturn it