use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class AnnotationUtilTest method testContainsAnnotationListWithNullList.
@Test
public void testContainsAnnotationListWithNullList() {
final DetailAST ast = new DetailAstImpl();
final List<String> annotations = null;
try {
AnnotationUtil.containsAnnotation(ast, annotations);
assertWithMessage("IllegalArgumentException is expected").fail();
} catch (IllegalArgumentException ex) {
assertWithMessage("Invalid exception message").that(ex.getMessage()).isEqualTo("annotations cannot be null");
}
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class XpathIteratorUtil method createNode.
/**
* Creates {@link DetailAstImpl} node.
*
* @param tokenType token type, see {@link TokenTypes}
* @param lineNo line number
* @param columnNo column number
*
* @return {@link DetailAstImpl} object.
*/
private static DetailAstImpl createNode(int tokenType, int lineNo, int columnNo) {
final DetailAstImpl result = new DetailAstImpl();
result.setType(tokenType);
result.setLineNo(lineNo);
result.setColumnNo(columnNo);
return result;
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class AbstractCheckTest method testAstLog.
@Test
public void testAstLog() throws Exception {
final ViolationAstCheck check = new ViolationAstCheck();
check.configure(new DefaultConfiguration("check"));
final File file = new File("fileName");
final FileText theText = new FileText(file, Collections.singletonList("test123"));
check.setFileContents(new FileContents(theText));
check.clearViolations();
final DetailAstImpl ast = new DetailAstImpl();
ast.setLineNo(1);
ast.setColumnNo(4);
check.visitToken(ast);
final SortedSet<Violation> internalViolations = check.getViolations();
assertWithMessage("Internal violation should only have 1").that(internalViolations).hasSize(1);
final Violation firstViolation = internalViolations.iterator().next();
assertWithMessage("expected line").that(firstViolation.getLineNo()).isEqualTo(1);
assertWithMessage("expected column").that(firstViolation.getColumnNo()).isEqualTo(5);
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class JavadocUtilTest method testEmptyJavadocCommentAst.
@Test
public void testEmptyJavadocCommentAst() {
final DetailAstImpl commentBegin = new DetailAstImpl();
commentBegin.setType(TokenTypes.BLOCK_COMMENT_BEGIN);
commentBegin.setText("/*");
final DetailAstImpl javadocCommentContent = new DetailAstImpl();
javadocCommentContent.setType(TokenTypes.COMMENT_CONTENT);
javadocCommentContent.setText("*");
final DetailAstImpl commentEnd = new DetailAstImpl();
commentEnd.setType(TokenTypes.BLOCK_COMMENT_END);
commentEnd.setText("*/");
commentBegin.setFirstChild(javadocCommentContent);
javadocCommentContent.setNextSibling(commentEnd);
final DetailAstImpl commentBeginParent = new DetailAstImpl();
commentBeginParent.setType(TokenTypes.MODIFIERS);
commentBeginParent.setFirstChild(commentBegin);
final DetailAstImpl aJavadocPosition = new DetailAstImpl();
aJavadocPosition.setType(TokenTypes.METHOD_DEF);
aJavadocPosition.setFirstChild(commentBeginParent);
assertWithMessage("Should return true when empty javadoc comment ast is passed").that(JavadocUtil.isJavadocComment(commentBegin)).isTrue();
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class JavadocUtilTest method testEmptyBlockCommentAst.
@Test
public void testEmptyBlockCommentAst() {
final DetailAstImpl commentBegin = new DetailAstImpl();
commentBegin.setType(TokenTypes.BLOCK_COMMENT_BEGIN);
commentBegin.setText("/*");
final DetailAstImpl commentContent = new DetailAstImpl();
commentContent.setType(TokenTypes.COMMENT_CONTENT);
commentContent.setText("");
final DetailAstImpl commentEnd = new DetailAstImpl();
commentEnd.setType(TokenTypes.BLOCK_COMMENT_END);
commentEnd.setText("*/");
commentBegin.setFirstChild(commentContent);
commentContent.setNextSibling(commentEnd);
assertWithMessage("Should return false when empty block comment is passed").that(JavadocUtil.isJavadocComment(commentBegin)).isFalse();
}
Aggregations