private static boolean lookAhead(final AstNode start, final Set<AstNode> targets) { for (AstNode current = start; current != null && !targets.isEmpty(); current = current.getNextSibling()) { if (targets.contains(current)) { return true; } } return false; }
public final Statement getNextStatement() { AstNode next = getNextSibling(); while (next != null && !(next instanceof Statement)) { next = next.getNextSibling(); } return (Statement) next; }
public final Statement getNextStatement() { AstNode next = getNextSibling(); while (next != null && !(next instanceof Statement)) { next = next.getNextSibling(); } return (Statement) next; }
@SuppressWarnings("unchecked") public final <T extends AstNode> T getNextSibling(final Role<T> role) { for (AstNode current = _nextSibling; current != null; current = current.getNextSibling()) { if (current.getRole() == role) { return (T) current; } } return null; }
@SuppressWarnings("unchecked") public final <T extends AstNode> T getNextSibling(final Role<T> role) { for (AstNode current = _nextSibling; current != null; current = current.getNextSibling()) { if (current.getRole() == role) { return (T) current; } } return null; }
@Override protected AstNode visitChildren(final AstNode node, final Void data) { AstNode next; for (AstNode child = node.getFirstChild(); child != null; child = next) { next = child.getNextSibling(); final AstNode childResult = child.acceptVisitor(this, data); if (childResult != null && childResult != child) { next = childResult; } } return node; }
@Override public boolean isEmpty() { for (AstNode current = _node.getFirstChild(); current != null; current = current.getNextSibling()) { if (current.getRole() == _role) { return false; } } return true; }
@Override public int size() { int count = 0; for (AstNode current = _node.getFirstChild(); current != null; current = current.getNextSibling()) { if (current.getRole() == _role) { count++; } } return count; }
@Override public boolean isEmpty() { for (AstNode current = _node.getFirstChild(); current != null; current = current.getNextSibling()) { if (current.getRole() == _role) { return false; } } return true; }
public final AstNode getNextNode() { final AstNode nextSibling = getNextSibling(); if (nextSibling != null) { return nextSibling; } final AstNode parent = getParent(); if (parent != null) { return parent.getNextNode(); } return null; }
@Override public int size() { int count = 0; for (AstNode current = _node.getFirstChild(); current != null; current = current.getNextSibling()) { if (current.getRole() == _role) { count++; } } return count; }
protected S visitChildren(final AstNode node, final T data) { AstNode next; for (AstNode child = node.getFirstChild(); child != null; child = next) { // // Store next to allow the loop to continue if the visitor removes/replaces child. // next = child.getNextSibling(); child.acceptVisitor(this, data); } return null; }
public final AstNode getNextNode() { final AstNode nextSibling = getNextSibling(); if (nextSibling != null) { return nextSibling; } final AstNode parent = getParent(); if (parent != null) { return parent.getNextNode(); } return null; }
private void optionalSemicolon() { // Look if there's a Semicolon after the current node, and insert it if it exists. AstNode pos = positionStack.peek(); while (pos != null && pos.getNodeType() == NodeType.WHITESPACE) { pos = pos.getNextSibling(); } if (pos != null && pos.getRole() == Roles.SEMICOLON) { semicolon(); } }
void optionalComma() { // Look if there's a comma after the current node, and insert it if it exists. AstNode position = positionStack.peek(); while (position != null && position.getNodeType() == NodeType.WHITESPACE) { position = position.getNextSibling(); } if (position != null && position.getRole() == Roles.COMMA) { comma(null, true); } }
private void optionalSemicolon() { // Look if there's a Semicolon after the current node, and insert it if it exists. AstNode pos = positionStack.peek(); while (pos != null && pos.getNodeType() == NodeType.WHITESPACE) { pos = pos.getNextSibling(); } if (pos != null && pos.getRole() == Roles.SEMICOLON) { semicolon(); } }
private void optionalSemicolon() { // Look if there's a Semicolon after the current node, and insert it if it exists. AstNode pos = positionStack.peek(); while (pos != null && pos.getNodeType() == NodeType.WHITESPACE) { pos = pos.getNextSibling(); } if (pos != null && pos.getRole() == Roles.SEMICOLON) { semicolon(); } }
private void writeSpecials(final AstNode start, final AstNode end) { for (AstNode current = start; current != end; current = current.getNextSibling()) { if (current.getRole() == Roles.COMMENT || current.getRole() == Roles.NEW_LINE) { current.acceptVisitor(this, null); } } }
private void writeSpecials(final AstNode start, final AstNode end) { for (AstNode current = start; current != end; current = current.getNextSibling()) { if (current.getRole() == Roles.COMMENT || current.getRole() == Roles.NEW_LINE) { current.acceptVisitor(this, null); } } }
public void acceptVisitor(final IAstVisitor<? super T, ?> visitor) { AstNode next; for (AstNode current = _node.getFirstChild(); current != null; current = next) { assert current.getParent() == _node; next = current.getNextSibling(); if (current.getRole() == _role) { current.acceptVisitor(visitor, null); } } }