+ Before Checkstyle 6.0, there was no comments in AST tree + as commnents are not a code and ignored by complier, so it was not a primary focus of Checkstyle. + But more and more requests appear to do validation of code vs javadoc or comments. + So there was a simple solution to receive plain text of file in Check, do own parsing and searching for required comments in file. +
++ Since 6.0, there is a new method in AbstractCheck class that allow you to see or not comment nodes in AST Tree - + + isCommentNodesRequired(). It should return TRUE if Check want to see comments in AST Tree. +
++ It is done as optional because it is change for a AST Tree structure, and non of existing Checks ready for this. + Checkstyle does not do re-parse file one more time, comments were already in grammar and parsed, but skipped during AST nodes creation. +
++ Before execution, all Checks are divided into 2 groups (base on isCommentNodesRequired method): "java only Checks", "comments Checks". + Checkstyle execute "java only Checks" first, as all them finish, append to AST Tree missed comment AST nodes and call "comments Checks". + All Javadoc Checks that are child of AbstractJavadocCheck are "comments Checks". +
++ Comment tokens: + SINGLE_LINE_COMMENT, + BLOCK_COMMENT_BEGIN, + BLOCK_COMMENT_END, + COMMENT_CONTENT. +
+ +