JavadocDetailNodeParser.java 文件源码

java
阅读 23 收藏 0 点赞 0 评论 0

项目:checkstyle-backport-jre6 作者:
/**
 * Logs parser errors in Checkstyle manner. Parser can generate error
 * messages. There is special error that parser can generate. It is
 * missed close HTML tag. This case is special because parser prints
 * error like {@code "no viable alternative at input 'b \n *\n'"} and it
 * is not clear that error is about missed close HTML tag. Other error
 * messages are not special and logged simply as "Parse Error...".
 *
 * <p>{@inheritDoc}
 */
@Override
public void syntaxError(
        Recognizer<?, ?> recognizer, Object offendingSymbol,
        int line, int charPositionInLine,
        String msg, RecognitionException ex) {
    final int lineNumber = offset + line;

    if (MSG_JAVADOC_WRONG_SINGLETON_TAG.equals(msg)) {
        errorMessage = new ParseErrorMessage(lineNumber,
                MSG_JAVADOC_WRONG_SINGLETON_TAG, charPositionInLine,
                ((Token) offendingSymbol).getText());

        throw new IllegalArgumentException(msg);
    }
    else {
        final int ruleIndex = ex.getCtx().getRuleIndex();
        final String ruleName = recognizer.getRuleNames()[ruleIndex];
        final String upperCaseRuleName = CaseFormat.UPPER_CAMEL.to(
                CaseFormat.UPPER_UNDERSCORE, ruleName);

        errorMessage = new ParseErrorMessage(lineNumber,
                MSG_JAVADOC_PARSE_RULE_ERROR, charPositionInLine, msg, upperCaseRuleName);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号