/** * Returns the index of the node block in relation to its siblings. * * @param block SimpleJavaNode * @param node Node * @return int */ private static int indexOf(AbstractJavaNode block, Node node) { int count = block.jjtGetNumChildren(); for (int i = 0; i < count; i++) { if (node == block.jjtGetChild(i)) return i; } return -1; }
/** * Returns all the blocks found right after the node supplied within the its current scope. * * @param block SimpleJavaNode * @param node SimpleNode * @return List */ private static List<Node> blocksAfter(AbstractJavaNode block, AbstractJavaNode node) { int count = block.jjtGetNumChildren(); int start = indexOf(block, node.jjtGetParent()) + 1; List<Node> nextBlocks = new ArrayList<Node>(count); for (int i = start; i < count; i++) { nextBlocks.add(block.jjtGetChild(i)); } return nextBlocks; }