本文整理汇总了Java中com.puppycrawl.tools.checkstyle.grammars.javadoc.JavadocLexer类的典型用法代码示例。如果您正苦于以下问题:Java JavadocLexer类的具体用法?Java JavadocLexer怎么用?Java JavadocLexer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavadocLexer类属于com.puppycrawl.tools.checkstyle.grammars.javadoc包,在下文中一共展示了JavadocLexer类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseJavadocFromFile
import com.puppycrawl.tools.checkstyle.grammars.javadoc.JavadocLexer; //导入依赖的package包/类
private static ParseTree parseJavadocFromFile(File file)
throws IOException {
final String content = Files.toString(file, Charsets.UTF_8);
final InputStream in = new ByteArrayInputStream(content.getBytes(Charsets.UTF_8));
final ANTLRInputStream input = new ANTLRInputStream(in);
final JavadocLexer lexer = new JavadocLexer(input);
lexer.removeErrorListeners();
final BaseErrorListener errorListener = new FailOnErrorListener();
lexer.addErrorListener(errorListener);
final CommonTokenStream tokens = new CommonTokenStream(lexer);
final JavadocParser parser = new JavadocParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(errorListener);
return parser.javadoc();
}
示例2: createJavadocParser
import com.puppycrawl.tools.checkstyle.grammars.javadoc.JavadocLexer; //导入依赖的package包/类
/**
* Parses block comment content as javadoc comment.
* @param blockComment
* block comment content.
* @return parse tree
* @noinspection deprecation
*/
private JavadocParser createJavadocParser(String blockComment) {
final ANTLRInputStream input = new ANTLRInputStream(blockComment);
final JavadocLexer lexer = new JavadocLexer(input);
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 JavadocParserErrorStrategy());
return parser;
}