use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class ElementNodeTest method testGetAttributeValueWrongAttribute.
@Test
public void testGetAttributeValueWrongAttribute() {
final DetailAstImpl detailAST = new DetailAstImpl();
detailAST.setType(TokenTypes.IDENT);
detailAST.setText("HelloWorld");
final ElementNode elementNode = new ElementNode(rootNode, rootNode, detailAST, 1, 0);
assertWithMessage("Must be null").that(elementNode.getAttributeValue(null, "somename")).isNull();
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class ElementNodeTest method testGetAttributeValue.
@Test
public void testGetAttributeValue() {
final DetailAstImpl detailAST = new DetailAstImpl();
detailAST.setType(TokenTypes.IDENT);
detailAST.setText("HelloWorld");
final ElementNode elementNode = new ElementNode(rootNode, rootNode, detailAST, 1, 0);
assertWithMessage("Invalid text attribute").that(elementNode.getAttributeValue(null, "text")).isEqualTo("HelloWorld");
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl 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();
}
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl 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();
}
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class JavadocUtilTest method testGetJavadocCommentContent.
@Test
public void testGetJavadocCommentContent() {
final DetailAstImpl detailAST = new DetailAstImpl();
final DetailAstImpl javadoc = new DetailAstImpl();
javadoc.setText("1javadoc");
detailAST.setFirstChild(javadoc);
final String commentContent = JavadocUtil.getJavadocCommentContent(detailAST);
assertWithMessage("Invalid comment content").that(commentContent).isEqualTo("javadoc");
}
Aggregations