use of com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseStatus in project checkstyle by checkstyle.
the class DetailNodeTreeStringPrinter method parseJavadocAsDetailNode.
/**
* Parse block comment DetailAST as Javadoc DetailNode tree.
*
* @param blockComment DetailAST
* @return DetailNode tree
* @throws IllegalArgumentException if there is an error parsing the Javadoc.
*/
public static DetailNode parseJavadocAsDetailNode(DetailAST blockComment) {
final JavadocDetailNodeParser parser = new JavadocDetailNodeParser();
final ParseStatus status = parser.parseJavadocAsDetailNode(blockComment);
if (status.getParseErrorMessage() != null) {
throw new IllegalArgumentException(getParseErrorMessage(status.getParseErrorMessage()));
}
return status.getTree();
}
use of com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseStatus in project checkstyle by checkstyle.
the class AbstractJavadocCheck method visitToken.
@Override
public final void visitToken(DetailAST blockCommentNode) {
if (JavadocUtil.isJavadocComment(blockCommentNode)) {
// store as field, to share with child Checks
context.get().blockCommentAst = blockCommentNode;
final LineColumn treeCacheKey = new LineColumn(blockCommentNode.getLineNo(), blockCommentNode.getColumnNo());
final ParseStatus result;
if (TREE_CACHE.get().containsKey(treeCacheKey)) {
result = TREE_CACHE.get().get(treeCacheKey);
} else {
result = context.get().parser.parseJavadocAsDetailNode(blockCommentNode);
TREE_CACHE.get().put(treeCacheKey, result);
}
if (result.getParseErrorMessage() == null) {
if (acceptJavadocWithNonTightHtml() || !result.isNonTight()) {
processTree(result.getTree());
}
if (violateExecutionOnNonTightHtml && result.isNonTight()) {
log(result.getFirstNonTightHtmlTag().getLine(), JavadocDetailNodeParser.MSG_UNCLOSED_HTML_TAG, result.getFirstNonTightHtmlTag().getText());
}
} else {
final ParseErrorMessage parseErrorMessage = result.getParseErrorMessage();
log(parseErrorMessage.getLineNumber(), parseErrorMessage.getMessageKey(), parseErrorMessage.getMessageArguments());
}
}
}
Aggregations