private static NodePair splitBlock(final View view,final Function function,final CodeNode node,final Instruction instruction){
  boolean before=true;
  final List<Instruction> beforeInstructions=new ArrayList<Instruction>();
  final List<Instruction> afterInstructions=new ArrayList<Instruction>();
  for (  final Instruction nodeInstruction : node.getInstructions()) {
    if (before) {
      beforeInstructions.add(nodeInstruction);
    }
 else {
      afterInstructions.add(nodeInstruction);
    }
    if (nodeInstruction == instruction) {
      before=false;
    }
  }
  if (afterInstructions.isEmpty()) {
    return new NodePair(node,null);
  }
 else {
    final CodeNode firstNode=view.createCodeNode(function,beforeInstructions);
    final CodeNode secondNode=view.createCodeNode(function,afterInstructions);
    firstNode.setColor(node.getColor());
    secondNode.setColor(DEFAULT_BLOCK_COLOR);
    for (    final ViewEdge edge : node.getIncomingEdges()) {
      final ViewEdge newEdge=view.createEdge(edge.getSource(),firstNode,edge.getType());
      newEdge.setColor(edge.getColor());
    }
    for (    final ViewEdge edge : node.getOutgoingEdges()) {
      final ViewEdge newEdge=view.createEdge(secondNode,edge.getTarget(),edge.getType());
      newEdge.setColor(edge.getColor());
    }
    view.deleteNode(node);
    return new NodePair(firstNode,secondNode);
  }
}

private static NodePair splitBlock ( final View view , final Function function , final CodeNode node , final Instruction instruction ) { boolean before = true ; final List < Instruction > beforeInstructions = new ArrayList < Instruction > ( ) ; final List < Instruction > afterInstructions = new ArrayList < Instruction > ( ) ; for ( final Instruction nodeInstruction : node . getInstructions ( ) ) { if ( before ) { beforeInstructions . add ( nodeInstruction ) ; } else { afterInstructions . add ( nodeInstruction ) ; } if ( nodeInstruction == instruction ) { before = false ; } } if ( afterInstructions . isEmpty ( ) ) { return new NodePair ( node , null ) ; } else { final CodeNode firstNode = view . createCodeNode ( function , beforeInstructions ) ; final CodeNode secondNode = view . createCodeNode ( function , afterInstructions ) ; firstNode . setColor ( node . getColor ( ) ) ; secondNode . setColor ( DEFAULT_BLOCK_COLOR ) ; for ( final ViewEdge edge : node . getIncomingEdges ( ) ) { final ViewEdge newEdge = view . createEdge ( edge . getSource ( ) , firstNode , edge . getType ( ) ) ; newEdge . setColor ( edge . getColor ( ) ) ; } for ( final ViewEdge edge : node . getOutgoingEdges ( ) ) { final ViewEdge newEdge = view . createEdge ( secondNode , edge . getTarget ( ) , edge . getType ( ) ) ; newEdge . setColor ( edge . getColor ( ) ) ; } view . deleteNode ( node ) ; return new NodePair ( firstNode , secondNode ) ; } }
splits a code node into two nodes at a function call . if the input node really is split , it is removed from the view . if the input node is not split ( because the calling instruction is the last instruction of the code node ) then the view nodes remain unchanged .
