use of com.puppycrawl.tools.checkstyle.xpath.ElementNode in project checkstyle by checkstyle.
the class XpathUtil method createChildren.
/**
* Iterates siblings of the given node and creates new Xpath-nodes.
*
* @param root the root node
* @param parent the parent node
* @param firstChild the first DetailAST
* @return children list
*/
public static List<AbstractNode> createChildren(AbstractNode root, AbstractNode parent, DetailAST firstChild) {
DetailAST currentChild = firstChild;
final int depth = parent.getDepth() + 1;
final List<AbstractNode> result = new ArrayList<>();
while (currentChild != null) {
final int index = result.size();
final ElementNode child = new ElementNode(root, parent, currentChild, depth, index);
result.add(child);
currentChild = currentChild.getNextSibling();
}
return result;
}
Aggregations