Search in sources :

Example 1 with EmptyIterator

use of net.sf.saxon.tree.iter.EmptyIterator in project checkstyle by checkstyle.

the class ElementNodeTest method testIterateAxisEmptyChildren.

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

Example 2 with EmptyIterator

use of net.sf.saxon.tree.iter.EmptyIterator in project checkstyle by checkstyle.

the class ElementNodeTest method testIterateAxisWithNoSiblings.

@Test
public void testIterateAxisWithNoSiblings() {
    final DetailAstImpl detailAST = new DetailAstImpl();
    detailAST.setType(TokenTypes.VARIABLE_DEF);
    final DetailAstImpl parentAST = new DetailAstImpl();
    parentAST.setFirstChild(detailAST);
    parentAST.setType(TokenTypes.METHOD_DEF);
    final AbstractNode parentNode = new ElementNode(rootNode, rootNode, parentAST, 1, 0);
    final AbstractNode elementNode = parentNode.getChildren().get(0);
    try (AxisIterator iterator = elementNode.iterateAxis(AxisInfo.FOLLOWING_SIBLING)) {
        assertWithMessage("Invalid iterator").that(iterator instanceof EmptyIterator).isTrue();
    }
    try (AxisIterator iterator = elementNode.iterateAxis(AxisInfo.PRECEDING_SIBLING)) {
        assertWithMessage("Invalid iterator").that(iterator instanceof EmptyIterator).isTrue();
    }
}
Also used : DetailAstImpl(com.puppycrawl.tools.checkstyle.DetailAstImpl) EmptyIterator(net.sf.saxon.tree.iter.EmptyIterator) AxisIterator(net.sf.saxon.tree.iter.AxisIterator) Test(org.junit.jupiter.api.Test)

Aggregations

DetailAstImpl (com.puppycrawl.tools.checkstyle.DetailAstImpl)2 AxisIterator (net.sf.saxon.tree.iter.AxisIterator)2 EmptyIterator (net.sf.saxon.tree.iter.EmptyIterator)2 Test (org.junit.jupiter.api.Test)2