Beispiel #1
0
  /**
   * Checks whether node contains any node of specified type among children on any deep level.
   *
   * @param node DetailNode
   * @param type token type
   * @return true if node contains any node of type type among children on any deep level.
   */
  public static boolean branchContains(DetailNode node, int type) {
    DetailNode curNode = node;
    while (true) {

      if (type == curNode.getType()) {
        return true;
      }

      DetailNode toVisit = getFirstChild(curNode);
      while (curNode != null && toVisit == null) {
        toVisit = getNextSibling(curNode);
        if (toVisit == null) {
          curNode = curNode.getParent();
        }
      }

      if (curNode == toVisit) {
        break;
      }

      curNode = toVisit;
    }

    return false;
  }
Beispiel #2
0
 /**
  * Gets previous sibling of specified node.
  *
  * @param node DetailNode
  * @return previous sibling
  */
 public static DetailNode getPreviousSibling(DetailNode node) {
   final DetailNode parent = node.getParent();
   final int previousSiblingIndex = node.getIndex() - 1;
   final DetailNode[] children = parent.getChildren();
   if (previousSiblingIndex >= 0) {
     return children[previousSiblingIndex];
   }
   return null;
 }
Beispiel #3
0
 /**
  * Gets next sibling of specified node.
  *
  * @param node DetailNode
  * @return next sibling.
  */
 public static DetailNode getNextSibling(DetailNode node) {
   final DetailNode parent = node.getParent();
   if (parent != null) {
     final int nextSiblingIndex = node.getIndex() + 1;
     final DetailNode[] children = parent.getChildren();
     if (nextSiblingIndex <= children.length - 1) {
       return children[nextSiblingIndex];
     }
   }
   return null;
 }
 @Override
 public void visitJavadocToken(DetailNode ast) {
   if (isEmptyTag(ast.getParent())) {
     log(ast.getLineNumber(), MSG_KEY, ast.getText());
   }
 }