Search in sources :

Example 1 with DescendantIterator

use of com.puppycrawl.tools.checkstyle.xpath.iterators.DescendantIterator in project checkstyle by checkstyle.

the class ElementNodeTest method testIterateAxisWithChildren.

@Test
public void testIterateAxisWithChildren() {
    final DetailAstImpl detailAST = new DetailAstImpl();
    detailAST.setType(TokenTypes.METHOD_DEF);
    final DetailAstImpl childAst = new DetailAstImpl();
    childAst.setType(TokenTypes.VARIABLE_DEF);
    detailAST.addChild(childAst);
    final ElementNode elementNode = new ElementNode(rootNode, rootNode, detailAST, 1, 0);
    try (AxisIterator iterator = elementNode.iterateAxis(AxisInfo.CHILD)) {
        assertWithMessage("Invalid iterator").that(iterator instanceof ArrayIterator).isTrue();
    }
    try (AxisIterator iterator = elementNode.iterateAxis(AxisInfo.DESCENDANT)) {
        assertWithMessage("Invalid iterator").that(iterator instanceof DescendantIterator).isTrue();
    }
}
Also used : DetailAstImpl(com.puppycrawl.tools.checkstyle.DetailAstImpl) AxisIterator(net.sf.saxon.tree.iter.AxisIterator) ArrayIterator(net.sf.saxon.tree.iter.ArrayIterator) DescendantIterator(com.puppycrawl.tools.checkstyle.xpath.iterators.DescendantIterator) Test(org.junit.jupiter.api.Test)

Aggregations

DetailAstImpl (com.puppycrawl.tools.checkstyle.DetailAstImpl)1 DescendantIterator (com.puppycrawl.tools.checkstyle.xpath.iterators.DescendantIterator)1 ArrayIterator (net.sf.saxon.tree.iter.ArrayIterator)1 AxisIterator (net.sf.saxon.tree.iter.AxisIterator)1 Test (org.junit.jupiter.api.Test)1