public class JavadocDetailNodeParser extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
JavadocDetailNodeParser.DescriptiveErrorListener
Custom error listener for JavadocParser that prints user readable errors.
|
static class |
JavadocDetailNodeParser.ParseErrorMessage
Contains information about parse error message.
|
static class |
JavadocDetailNodeParser.ParseStatus
Contains result of parsing javadoc comment: DetailNode tree and parse
error message.
|
| Modifier and Type | Field and Description |
|---|---|
private int |
blockCommentLineNumber
Line number of the Block comment AST that is being parsed.
|
private static java.lang.String |
JAVADOC_START
Symbols with which javadoc starts.
|
static java.lang.String |
MSG_JAVADOC_MISSED_HTML_CLOSE
Message key of error message.
|
static java.lang.String |
MSG_JAVADOC_PARSE_RULE_ERROR
Parse error while rule recognition.
|
static java.lang.String |
MSG_JAVADOC_WRONG_SINGLETON_TAG
Message key of error message.
|
static java.lang.String |
MSG_UNCLOSED_HTML_TAG
Message property key for the Unclosed HTML message.
|
| Constructor and Description |
|---|
JavadocDetailNodeParser() |
| Modifier and Type | Method and Description |
|---|---|
private void |
adjustFirstLineToJavadocIndent(DetailNode tree,
int javadocColumnNumber)
Adjust first line nodes to javadoc indent.
|
private DetailNode |
convertParseTreeToDetailNode(org.antlr.v4.runtime.tree.ParseTree parseTreeNode)
Converts ParseTree (that is generated by ANTLRv4) to DetailNode tree.
|
private static java.lang.String |
convertUpperCamelToUpperUnderscore(java.lang.String text)
Converts the given
text from camel case to all upper case with
underscores separating each word. |
private JavadocNodeImpl[] |
createChildrenNodes(JavadocNodeImpl parentJavadocNode,
org.antlr.v4.runtime.tree.ParseTree parseTreeNode)
Creates children Javadoc nodes base on ParseTree node's children.
|
private JavadocNodeImpl |
createJavadocNode(org.antlr.v4.runtime.tree.ParseTree parseTree,
DetailNode parent,
int index)
Creates JavadocNodeImpl node on base of ParseTree node.
|
private static com.puppycrawl.tools.checkstyle.grammar.javadoc.JavadocParser |
createJavadocParser(java.lang.String blockComment,
JavadocDetailNodeParser.DescriptiveErrorListener errorListener)
Parses block comment content as javadoc comment.
|
private JavadocNodeImpl |
createRootJavadocNode(org.antlr.v4.runtime.tree.ParseTree parseTreeNode)
Creates root JavadocNodeImpl node base on ParseTree root node.
|
private static int |
getColumn(org.antlr.v4.runtime.tree.ParseTree tree)
Gets column number from ParseTree node.
|
private static org.antlr.v4.runtime.Token |
getFirstNonTightHtmlTag(com.puppycrawl.tools.checkstyle.grammar.javadoc.JavadocParser javadocParser,
int javadocLineOffset)
This method is used to get the first non-tight HTML tag encountered while parsing javadoc.
|
private static java.lang.String |
getFormattedNodeClassNameWithoutContext(org.antlr.v4.runtime.tree.ParseTree node)
Gets class name of ParseTree node and removes 'Context' postfix at the
end and formats it.
|
private static int |
getLine(org.antlr.v4.runtime.tree.ParseTree tree)
Gets line number from ParseTree node.
|
private static org.antlr.v4.runtime.Token |
getMissedHtmlTag(org.antlr.v4.runtime.RecognitionException exception)
Method to get the missed HTML tag to generate more informative error message for the user.
|
private static org.antlr.v4.runtime.tree.ParseTree |
getNextSibling(org.antlr.v4.runtime.tree.ParseTree node)
Gets next sibling of ParseTree node.
|
private static java.lang.String |
getNodeClassNameWithoutContext(org.antlr.v4.runtime.tree.ParseTree node)
Gets class name of ParseTree node and removes 'Context' postfix at the
end.
|
private static int |
getTokenType(org.antlr.v4.runtime.tree.ParseTree node)
Gets token type of ParseTree node from JavadocTokenTypes class.
|
private void |
insertChildrenNodes(JavadocNodeImpl[] nodes,
org.antlr.v4.runtime.tree.ParseTree parseTreeParent)
Creates child nodes for each node from 'nodes' array.
|
JavadocDetailNodeParser.ParseStatus |
parseJavadocAsDetailNode(DetailAST javadocCommentAst)
Parses Javadoc comment as DetailNode tree.
|
public static final java.lang.String MSG_JAVADOC_MISSED_HTML_CLOSE
"no viable alternative at input 'b \n *\n'" and it is not
clear that error is about missed close HTML tag.public static final java.lang.String MSG_JAVADOC_WRONG_SINGLETON_TAG
public static final java.lang.String MSG_JAVADOC_PARSE_RULE_ERROR
public static final java.lang.String MSG_UNCLOSED_HTML_TAG
private static final java.lang.String JAVADOC_START
private int blockCommentLineNumber
public JavadocDetailNodeParser()
public JavadocDetailNodeParser.ParseStatus parseJavadocAsDetailNode(DetailAST javadocCommentAst)
javadocCommentAst - DetailAST of Javadoc commentprivate static com.puppycrawl.tools.checkstyle.grammar.javadoc.JavadocParser createJavadocParser(java.lang.String blockComment, JavadocDetailNodeParser.DescriptiveErrorListener errorListener)
blockComment - block comment content.errorListener - custom error listenerprivate DetailNode convertParseTreeToDetailNode(org.antlr.v4.runtime.tree.ParseTree parseTreeNode)
parseTreeNode - root node of ParseTreeprivate void insertChildrenNodes(JavadocNodeImpl[] nodes, org.antlr.v4.runtime.tree.ParseTree parseTreeParent)
nodes - array of JavadocNodeImpl nodesparseTreeParent - original ParseTree parent nodeprivate JavadocNodeImpl[] createChildrenNodes(JavadocNodeImpl parentJavadocNode, org.antlr.v4.runtime.tree.ParseTree parseTreeNode)
parentJavadocNode - node that will be parent for created childrenparseTreeNode - original ParseTree nodeprivate JavadocNodeImpl createRootJavadocNode(org.antlr.v4.runtime.tree.ParseTree parseTreeNode)
parseTreeNode - ParseTree root nodeprivate JavadocNodeImpl createJavadocNode(org.antlr.v4.runtime.tree.ParseTree parseTree, DetailNode parent, int index)
parseTree - ParseTree nodeparent - DetailNode that will be parent of new nodeindex - child index that has new nodeprivate void adjustFirstLineToJavadocIndent(DetailNode tree, int javadocColumnNumber)
tree - DetailNode tree rootjavadocColumnNumber - javadoc indentprivate static int getLine(org.antlr.v4.runtime.tree.ParseTree tree)
tree - ParseTree nodeprivate static int getColumn(org.antlr.v4.runtime.tree.ParseTree tree)
tree - ParseTree nodeprivate static org.antlr.v4.runtime.tree.ParseTree getNextSibling(org.antlr.v4.runtime.tree.ParseTree node)
node - ParseTree nodeprivate static int getTokenType(org.antlr.v4.runtime.tree.ParseTree node)
node - ParseTree node.private static java.lang.String getFormattedNodeClassNameWithoutContext(org.antlr.v4.runtime.tree.ParseTree node)
node - ParseTree node whose class name is to be formatted and returnedprivate static java.lang.String getNodeClassNameWithoutContext(org.antlr.v4.runtime.tree.ParseTree node)
node - ParseTree node.private static org.antlr.v4.runtime.Token getMissedHtmlTag(org.antlr.v4.runtime.RecognitionException exception)
<p>
<li>
<tr>
<td>
<th>
<body>
<colgroup>
<dd>
<dt>
<head>
<html>
<option>
<tbody>
<thead>
<tfoot>
exception - NoViableAltException object catched while parsing javadocToken if a HTML close tag is missed;
null otherwiseprivate static org.antlr.v4.runtime.Token getFirstNonTightHtmlTag(com.puppycrawl.tools.checkstyle.grammar.javadoc.JavadocParser javadocParser, int javadocLineOffset)
JavadocDetailNodeParser.ParseStatus object returned by
parseJavadocAsDetailNode(DetailAST) method via the instance member
JavadocDetailNodeParser.ParseStatus.firstNonTightHtmlTag, and checks not supposed to process non-tight HTML
or the ones which are supposed to log violation for non-tight javadocs can utilize that.javadocParser - The ANTLR recognizer instance which has been used to parse the javadocjavadocLineOffset - The line number of beginning of the Javadoc commentprivate static java.lang.String convertUpperCamelToUpperUnderscore(java.lang.String text)
text from camel case to all upper case with
underscores separating each word.text - The string to convert.Copyright © 2001-2022. All Rights Reserved.