Esempio n. 1
0
  /**
   * Determines if an endline comment will be printed before the given else node.
   *
   * @param elseNode else node to check for endline comments before.
   * @return <code>true</code> if an endline comment will be printed before the given else node.
   */
  private boolean isCommentBefore(JavaNode elseNode) {
    JavaNode slist = elseNode.getPreviousSibling();
    JavaNode rcurly = null;

    for (AST child = slist.getFirstChild(); child != null; child = child.getNextSibling()) {
      switch (child.getType()) {
        case JavaTokenTypes.RCURLY:
          if (child.getNextSibling() == null) {
            rcurly = (JavaNode) child;
          }

          break;
      }
    }

    if (rcurly != null) {
      return rcurly.hasCommentsAfter();
    }

    return false;
  }