From ff6526252e03136ef899263be8e65967d71ed0ee Mon Sep 17 00:00:00 2001
From: Baratali Izmailov
Javadoc parser requires XHTML to be used in Javadoc comments, i.e. if there is some open tag(for example <div>) then there have to be its close tag </div>. This means that if Javadoc comment has incorrect XHTML structure then Javadoc Parser will fail processing the comment, therefore, your new Check can't get its parse tree and process anything from this Javadoc comment. For more details and examples go to "HTML code in Javadoc comments" section.
- Javadoc grammar requires XHTML, but it can also parse some parts of HTML code (like some unclosed tags). However result tree will be unpredictable. + Javadoc grammar requires XHTML, but it can also parse some parts of HTML code (like some unclosed tags). If HTML tags are not closed Javadoc grammar cannot determine content of these tags, + so structure of the parse tree will not be nested like it is while using XHTML. It is done just to not fail on every Javadoc comment, because there are tons of using unclosed tags, etc.
@@ -73,17 +74,6 @@ public class MyClass { There is also TokenTypes class in Checkstyle. Make sure you use JavadocTokenTypes class in your Check, because the TokenTypes is used to describe standard Java DetailAST token type.- In Javadoc comment every whitespace matters, so parse tree contains whitespace nodes - (WS javadoc token type). - So do CHAR javadoc token that presents single character. - The only redundancy Javadoc tree has because of this is that - TEXT node consists of - CHAR and - WS nodes which is useless, but it is implementation nuance. - (In future we will try to resolve this. See Github Issue #3170). -
+ Main Java grammar skips any whitespaces and newlines, so in Java Abstract Syntax Tree there are no whitespace/newline nodes. + In Javadoc comment every whitespace matters, and Javadoc Checks need all those whitespaces and newline nodes to verify format and content of the Javadoc comment. + Because of that Javadoc grammar includes all whitespaces, newlines to the parse tree + (WS, NEWLINE). + As you may notice there is also CHAR javadoc token that presents single character. + It is quite useless and is used for building only TEXT node which consists of + CHAR and + WS nodes, but it is implementation nuance. + (In future we will try to resolve this. See Github Issue #3170). +