static int getIndexInParent(Node node) { Node parent = node.jjtGetParent(); for (int ii = 0; ii < parent.jjtGetNumChildren(); ii++) { if (parent.jjtGetChild(ii) == node) { return ii; } } throw new IllegalStateException(); }
static Node getNext(Node node) { Node parent = node.jjtGetParent(); int ii = getIndexInParent(node); return ii < parent.jjtGetNumChildren() - 1 ? parent.jjtGetChild(ii + 1) : null; }
static Node getPrev(Node node) { Node parent = node.jjtGetParent(); int ii = getIndexInParent(node); return ii > 0 ? parent.jjtGetChild(ii - 1) : null; }
static Node getLastSibling(Node node) { Node parent = node.jjtGetParent(); return parent.jjtGetChild(parent.jjtGetNumChildren() - 1); }
static Node getFirstSibling(Node node) { return node.jjtGetParent().jjtGetChild(0); }