BraceStyleListener.java 文件源码

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

项目:tailor 作者:
private void verifyCloseBraceStyle(ParseTree closeBrace, ParseTree closeBraceLeftSibling, String constructName) {
    Token closeBraceToken = ((TerminalNodeImpl)closeBrace).getSymbol();
    Location closeBraceLocation = ListenerUtil.getTokenLocation(closeBraceToken);

    if (commentLeftOfCloseBrace(closeBraceToken)) {
        this.printer.warn(Rules.BRACE_STYLE, constructName + Messages.CLOSE_BRACE_STYLE, closeBraceLocation);
        return;
    }

    Location closeBraceLeftSiblingLocation = ListenerUtil.getParseTreeStopLocation(closeBraceLeftSibling);
    if (closeBraceLocation.line == closeBraceLeftSiblingLocation.line) {
        if (!closeBraceLeftSibling.getText().equals("{")) {
            this.printer.warn(Rules.BRACE_STYLE, constructName + Messages.CLOSE_BRACE_STYLE, closeBraceLocation);
        } else if (closeBraceLocation.column - closeBraceLeftSiblingLocation.column != 1) {
            this.printer.warn(Rules.BRACE_STYLE, Messages.EMPTY_BODY, closeBraceLeftSiblingLocation);
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号