Example #1
0
 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();
 }
Example #2
0
 static Node getNext(Node node) {
   Node parent = node.jjtGetParent();
   int ii = getIndexInParent(node);
   return ii < parent.jjtGetNumChildren() - 1 ? parent.jjtGetChild(ii + 1) : null;
 }
Example #3
0
 static Node getPrev(Node node) {
   Node parent = node.jjtGetParent();
   int ii = getIndexInParent(node);
   return ii > 0 ? parent.jjtGetChild(ii - 1) : null;
 }
Example #4
0
 static Node getLastSibling(Node node) {
   Node parent = node.jjtGetParent();
   return parent.jjtGetChild(parent.jjtGetNumChildren() - 1);
 }
Example #5
0
 static Node getFirstSibling(Node node) {
   return node.jjtGetParent().jjtGetChild(0);
 }