From 1ef75b520f27e67eb96fc44de81e62889289d3b0 Mon Sep 17 00:00:00 2001
From: Baratali Izmailov
Date: Thu, 12 May 2016 23:24:23 +0100
Subject: [PATCH] Issue #410: Writing JavadocChecks wiki-page. Classes and
methods as links
---
src/xdocs/writingjavadocchecks.xml.vm | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/src/xdocs/writingjavadocchecks.xml.vm b/src/xdocs/writingjavadocchecks.xml.vm
index dc312b43e..11597baa6 100644
--- a/src/xdocs/writingjavadocchecks.xml.vm
+++ b/src/xdocs/writingjavadocchecks.xml.vm
@@ -66,19 +66,17 @@ public class MyClass {
- To start implementing new Check create new class and extend AbstractJavadocCheck. It has two abstract methods you should implement:
+ To start implementing new Check create new class and extend AbstractJavadocCheck. It has two abstract methods you should implement:
-
getDefaultJavadocTokens() - return int array of javadoc token types your Check is going to process. The array should contain int constants from JavadocTokenTypes class.
- 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.
-
visitJavadocToken(DetailNode) - it's the place you should put tree nodes proccessing. The argument is Javadoc tree node of type you described
- before in getDefaultJavadocTokens() method.
+
getDefaultJavadocTokens() - return int array of javadoc token types your Check is going to process. The array should contain int constants from JavadocTokenTypes class.
+ 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.
+
visitJavadocToken(DetailNode) - it's the place you should put tree nodes proccessing. The argument is Javadoc tree node of type you described before in getDefaultJavadocTokens() method.
- 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).
+ 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).
@@ -91,7 +89,7 @@ public class MyClass {
The problem is that Java grammar is old one and uses ANTLR v2, while Javadoc grammar uses ANTLR v4. Because of that, these two grammars and their trees are not compatible.
- Java AST consists of DetailAST objects, while Javadoc AST consists of DetailNode objects.
+ Java AST consists of DetailAST objects, while Javadoc AST consists of DetailNode objects.
* My class.\r\n * @see AbstractClass [0:0]
@@ -214,9 +212,9 @@ JAVADOC -> * My class.\r\n * @see AbstractClass [0:0]
As you alreasy know Javadoc parse tree is result of parsing block comment. There is a method to get the original block comment from Javadoc Check.
- You may need this block comment to check its position or something else in main DetailAST tree.
+ You may need this block comment to check its position or something else in main DetailAST tree.
- For example, to write a JavadocCheck that verifies @param tags in Javadoc comment of a method definition, you also need all method's parameter names. To get method definition AST you should access main DetailAST tree throuth block comment AST. For this purpose use getBlockCommentAst() method that returns DetailAST node.
+ For example, to write a JavadocCheck that verifies @param tags in Javadoc comment of a method definition, you also need all method's parameter names. To get method definition AST you should access main DetailAST tree throuth block comment AST. For this purpose use getBlockCommentAst() method that returns DetailAST node.