Refine search
protected Node getLastChild(Node contextNode) { if (contextNode.jjtGetNumChildren() > 0) { return contextNode.jjtGetChild(contextNode.jjtGetNumChildren() - 1); } else { return null; } } }
protected Node getNextSibling(Node contextNode) { Node parentNode = contextNode.jjtGetParent(); if (parentNode != null) { int nextPosition = contextNode.jjtGetChildIndex() + 1; if (nextPosition < parentNode.jjtGetNumChildren()) { return parentNode.jjtGetChild(nextPosition); } } return null; }
private boolean hasAssignmentOperator(Node node) { if (node instanceof ASTStatementExpression || node instanceof ASTExpression) { if (node.jjtGetNumChildren() >= 2 && node.jjtGetChild(1) instanceof ASTAssignmentOperator) { return true; } } return false; }
private Node getNextSibling(Node current) { if (current.jjtGetParent().jjtGetNumChildren() > current.jjtGetChildIndex() + 1) { return current.jjtGetParent().jjtGetChild(current.jjtGetChildIndex() + 1); } return null; }
protected Node getFirstChild(Node contextNode) { if (contextNode.jjtGetNumChildren() > 0) { return contextNode.jjtGetChild(0); } else { return null; } }
private boolean couldBeMethodCall(JavaNode node) { if (node.getNthParent(2) instanceof ASTPrimaryExpression && node.getNthParent(1) instanceof ASTPrimaryPrefix) { int nextSibling = node.jjtGetParent().jjtGetChildIndex() + 1; if (node.getNthParent(2).jjtGetNumChildren() > nextSibling) { return node.getNthParent(2).jjtGetChild(nextSibling) instanceof ASTPrimarySuffix; } } return false; }
private boolean isAppendingStringLiteral(Node node) { Node n = node; while (n.jjtGetNumChildren() != 0 && !(n instanceof ASTLiteral)) { n = n.jjtGetChild(0); } return n instanceof ASTLiteral; }
private Node getFirstChildOrThis(Node node) { if (node.jjtGetNumChildren() > 0) { return node.jjtGetChild(0); } return node; }
/** * Returns the first child node going down 'level' levels or null if level * is invalid */ private Node getDescendant(Node node, int level) { Node n = node; for (int i = 0; i < level; i++) { if (n.jjtGetNumChildren() == 0) { return null; } n = n.jjtGetChild(0); } return n; }
private boolean hasName(Node n) { return n.jjtGetNumChildren() > 0 && n.jjtGetChild(0) instanceof ASTName; }
private void moveToNext() { while (i < parent.jjtGetNumChildren() && !(targetChildType.isInstance(parent.jjtGetChild(i)))) { i++; } }
private ASTCatchStatement getCatch(Node n) { for (int i = 0; i < n.jjtGetNumChildren(); i++) { if (n.jjtGetChild(i) instanceof ASTCatchStatement) { return (ASTCatchStatement) n.jjtGetChild(i); } } return null; } }
private Node skipAnnotations(Node p) { int index = 0; Node n = p.jjtGetChild(index++); while (n instanceof ASTAnnotation && index < p.jjtGetNumChildren()) { n = p.jjtGetChild(index++); } return n; } }
/** * Indicate whether this node is allocating a new object. * * @param n * node that might be allocating a new object * @return true if child 0 is an AllocationExpression */ private boolean isAllocation(Node n) { return n.jjtGetNumChildren() > 0 && n.jjtGetChild(0) instanceof ASTAllocationExpression && n.jjtGetParent().jjtGetNumChildren() == 1; }
/** * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object,java.lang.Object) */ @Override public int getIndexOfChild(Object parent, Object child) { Node node = (Node) parent; for (int i = 0; i < node.jjtGetNumChildren(); i++) { if (node.jjtGetChild(i).equals(child)) { return i; } } return -1; }
private boolean eachNodeHasOneChild(Node node) { if (node.jjtGetNumChildren() > 1) { return false; } if (node.jjtGetNumChildren() == 0) { return true; } return eachNodeHasOneChild(node.jjtGetChild(0)); }
private boolean isFirstChild(Node node, Class<?> clazz) { return node.jjtGetNumChildren() == 1 && clazz.isAssignableFrom(node.jjtGetChild(0).getClass()); } }
/** * checks the children and creates them if neccessary */ private void checkChildren() { if (children == null) { children = new ArrayList<>(node.jjtGetNumChildren()); for (int i = 0; i < node.jjtGetNumChildren(); i++) { children.add(new SimpleNodeTreeNodeAdapter(this, node.jjtGetChild(i))); } } }
private Node getLastChild(Node node) { if (node.jjtGetNumChildren() == 0) { return node; } return getLastChild(node.jjtGetChild(0)); }
private boolean hasNameAsChild(Node node) { if (node.jjtGetNumChildren() > 0) { if (node.jjtGetChild(0) instanceof ASTName) { return true; } else { return hasNameAsChild(node.jjtGetChild(0)); } } return false; }