use of com.puppycrawl.tools.checkstyle.grammar.javadoc.JavadocLexer in project checkstyle by checkstyle.
the class JavadocDetailNodeParser method createJavadocParser.
/**
* Parses block comment content as javadoc comment.
*
* @param blockComment
* block comment content.
* @param errorListener custom error listener
* @return parse tree
*/
private static JavadocParser createJavadocParser(String blockComment, DescriptiveErrorListener errorListener) {
final JavadocLexer lexer = new JavadocLexer(CharStreams.fromString(blockComment), true);
final CommonTokenStream tokens = new CommonTokenStream(lexer);
final JavadocParser parser = new JavadocParser(tokens);
// remove default error listeners
parser.removeErrorListeners();
// add custom error listener that logs syntax errors
parser.addErrorListener(errorListener);
// JavadocParserErrorStrategy stops parsing on first parse error encountered unlike the
// DefaultErrorStrategy used by ANTLR which rather attempts error recovery.
parser.setErrorHandler(new CheckstyleParserErrorStrategy());
return parser;
}
Aggregations