当前位置: 首页>>代码示例>>Java>>正文


Java DetailAST.getColumnNo方法代码示例

本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.DetailAST.getColumnNo方法的典型用法代码示例。如果您正苦于以下问题:Java DetailAST.getColumnNo方法的具体用法?Java DetailAST.getColumnNo怎么用?Java DetailAST.getColumnNo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.puppycrawl.tools.checkstyle.api.DetailAST的用法示例。


在下文中一共展示了DetailAST.getColumnNo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitToken

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
    if (ast.getChildCount() == 0) {
        //empty for iterator. test pad after semi.
        final DetailAST semi = ast.getPreviousSibling();
        final String line = getLines()[semi.getLineNo() - 1];
        final int after = semi.getColumnNo() + 1;
        //don't check if at end of line
        if (after < line.length()) {
            if (option == PadOption.NOSPACE
                && Character.isWhitespace(line.charAt(after))) {
                log(semi.getLineNo(), after, MSG_WS_FOLLOWED, SEMICOLON);
            }
            else if (option == PadOption.SPACE
                     && !Character.isWhitespace(line.charAt(after))) {
                log(semi.getLineNo(), after, MSG_WS_NOT_FOLLOWED, SEMICOLON);
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:21,代码来源:EmptyForIteratorPadCheck.java

示例2: processRight

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Process a token representing a right parentheses.
 * @param ast the token representing a right parentheses
 */
protected void processRight(DetailAST ast) {
    final int before = ast.getColumnNo() - 1;
    if (before >= 0) {
        final String line = getLines()[ast.getLineNo() - 1];
        if (option == PadOption.NOSPACE
            && Character.isWhitespace(line.charAt(before))
            && !CommonUtils.hasWhitespaceBefore(before, line)) {
            log(ast.getLineNo(), before, MSG_WS_PRECEDED, CLOSE_PARENTHESIS);
        }
        else if (option == PadOption.SPACE
            && !Character.isWhitespace(line.charAt(before))
            && line.charAt(before) != OPEN_PARENTHESIS) {
            log(ast.getLineNo(), ast.getColumnNo(),
                MSG_WS_NOT_PRECEDED, CLOSE_PARENTHESIS);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:22,代码来源:AbstractParenPadCheck.java

示例3: visitToken

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
    if (ast.getChildCount() == 0) {
        //empty for initializer. test pad before semi.
        final DetailAST semi = ast.getNextSibling();
        final int semiLineIdx = semi.getLineNo() - 1;
        final String line = getLines()[semiLineIdx];
        final int before = semi.getColumnNo() - 1;
        //don't check if semi at beginning of line
        if (!CommonUtils.hasWhitespaceBefore(before, line)) {
            if (option == PadOption.NOSPACE
                && Character.isWhitespace(line.charAt(before))) {
                log(semi.getLineNo(), before, MSG_PRECEDED, SEMICOLON);
            }
            else if (option == PadOption.SPACE
                     && !Character.isWhitespace(line.charAt(before))) {
                log(semi.getLineNo(), before, MSG_NOT_PRECEDED, SEMICOLON);
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:22,代码来源:EmptyForInitializerPadCheck.java

示例4: getPositionAfter

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Gets position after token (place of possible redundant whitespace).
 * @param ast Node representing token.
 * @return position after token.
 */
private static int getPositionAfter(DetailAST ast) {
    final int after;
    //If target of possible redundant whitespace is in method definition.
    if (ast.getType() == TokenTypes.IDENT
            && ast.getNextSibling() != null
            && ast.getNextSibling().getType() == TokenTypes.LPAREN) {
        final DetailAST methodDef = ast.getParent();
        final DetailAST endOfParams = methodDef.findFirstToken(TokenTypes.RPAREN);
        after = endOfParams.getColumnNo() + 1;
    }
    else {
        after = ast.getColumnNo() + ast.getText().length();
    }
    return after;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:21,代码来源:NoWhitespaceAfterCheck.java

示例5: visitToken

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
    final String text = ast.getText();
    final int colNo = ast.getColumnNo();
    final int lineNo = ast.getLineNo();
    final String currentLine = getLines()[lineNo - 1];
    final String substringAfterToken =
            currentLine.substring(colNo + text.length()).trim();
    final String substringBeforeToken =
            currentLine.substring(0, colNo).trim();

    if (option == WrapOption.EOL
            && substringBeforeToken.isEmpty()) {
        log(lineNo, colNo, MSG_LINE_PREVIOUS, text);
    }
    else if (option == WrapOption.NL
             && substringAfterToken.isEmpty()) {
        log(lineNo, colNo, MSG_LINE_NEW, text);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:21,代码来源:SeparatorWrapCheck.java

示例6: getNextSubTreeNode

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Gets the next node of a syntactical tree (child of a current node or
 * sibling of a current node, or sibling of a parent of a current node).
 * @param currentNodeAst Current node in considering
 * @param subTreeRootAst SubTree root
 * @return Current node after bypassing, if current node reached the root of a subtree
 *        method returns null
 */
private static DetailAST
    getNextSubTreeNode(DetailAST currentNodeAst, DetailAST subTreeRootAst) {
    DetailAST currentNode = currentNodeAst;
    DetailAST toVisitAst = currentNode.getFirstChild();
    while (toVisitAst == null) {
        toVisitAst = currentNode.getNextSibling();
        if (toVisitAst == null) {
            if (currentNode.getParent().equals(subTreeRootAst)
                     && currentNode.getParent().getColumnNo() == subTreeRootAst.getColumnNo()) {
                break;
            }
            currentNode = currentNode.getParent();
        }
    }
    return toVisitAst;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:25,代码来源:VisibilityModifierCheck.java

示例7: handleCommentAtTheEndOfTheCodeBlock

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Handles a comment which is placed at the end of non empty code block.
 * Note, if single line comment is placed at the end of non empty block the comment should have
 * the same indentation level as the previous statement. For example:
 * <p>
 * {@code
 *    if (a == true) {
 *        int b = 1;
 *        // comment
 *    }
 * }
 * </p>
 * @param prevStmt previous statement.
 * @param comment comment to check.
 * @param nextStmt next statement.
 */
private void handleCommentAtTheEndOfTheCodeBlock(DetailAST prevStmt, DetailAST comment,
                                                 DetailAST nextStmt) {
    if (prevStmt != null) {
        if (prevStmt.getType() == TokenTypes.LITERAL_CASE
                || prevStmt.getType() == TokenTypes.CASE_GROUP
                || prevStmt.getType() == TokenTypes.LITERAL_DEFAULT) {
            if (comment.getColumnNo() < nextStmt.getColumnNo()) {
                log(comment.getLineNo(), getMessageKey(comment), nextStmt.getLineNo(),
                    comment.getColumnNo(), nextStmt.getColumnNo());
            }
        }
        else if (isCommentForMultiblock(nextStmt)) {
            if (!areSameLevelIndented(comment, prevStmt, nextStmt)) {
                logMultilineIndentation(prevStmt, comment, nextStmt);
            }
        }
        else if (!areSameLevelIndented(comment, prevStmt, prevStmt)) {
            final int prevStmtLineNo = prevStmt.getLineNo();
            log(comment.getLineNo(), getMessageKey(comment), prevStmtLineNo,
                    comment.getColumnNo(), getLineStart(prevStmtLineNo));
        }
    }

}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:41,代码来源:CommentsIndentationCheck.java

示例8: processLeft

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Process a token representing a left parentheses.
 * @param ast the token representing a left parentheses
 */
protected void processLeft(DetailAST ast) {
    final String line = getLines()[ast.getLineNo() - 1];
    final int after = ast.getColumnNo() + 1;
    if (after < line.length()) {
        if (option == PadOption.NOSPACE
            && Character.isWhitespace(line.charAt(after))) {
            log(ast.getLineNo(), after, MSG_WS_FOLLOWED, OPEN_PARENTHESIS);
        }
        else if (option == PadOption.SPACE
                 && !Character.isWhitespace(line.charAt(after))
                 && line.charAt(after) != CLOSE_PARENTHESIS) {
            log(ast.getLineNo(), after, MSG_WS_NOT_FOLLOWED, OPEN_PARENTHESIS);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:AbstractParenPadCheck.java

示例9: verifyBrace

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Verifies that a specified left curly brace is placed correctly
 * according to policy.
 * @param brace token for left curly brace
 * @param startToken token for start of expression
 */
private void verifyBrace(final DetailAST brace,
                         final DetailAST startToken) {
    final String braceLine = getLine(brace.getLineNo() - 1);

    // Check for being told to ignore, or have '{}' which is a special case
    if (braceLine.length() <= brace.getColumnNo() + 1
            || braceLine.charAt(brace.getColumnNo() + 1) != '}') {
        if (option == LeftCurlyOption.NL) {
            if (!CommonUtils.hasWhitespaceBefore(brace.getColumnNo(), braceLine)) {
                log(brace, MSG_KEY_LINE_NEW, OPEN_CURLY_BRACE, brace.getColumnNo() + 1);
            }
        }
        else if (option == LeftCurlyOption.EOL) {

            validateEol(brace, braceLine);
        }
        else if (startToken.getLineNo() != brace.getLineNo()) {

            validateNewLinePosition(brace, startToken, braceLine);

        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:30,代码来源:LeftCurlyCheck.java

示例10: initialize

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * initialized this node with input node
 * @param aAST the node to initialize from. Must be a
 * <code>DetailAST</code> object.
 */
public void initialize(AST aAST)
{
    if (aAST != null) {
        super.initialize(aAST);
        final DetailAST detailAST = (DetailAST) aAST;
        setDetailNode(detailAST);
        _column = detailAST.getColumnNo() + 1;
        _line = detailAST.getLineNo();
    } 
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:SymTabAST.java

示例11: visitToken

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Override
public void visitToken(DetailAST ast) {
    final int currentType = ast.getType();
    if (!isNotRelevantSituation(ast, currentType)) {
        final String line = getLine(ast.getLineNo() - 1);
        final int before = ast.getColumnNo() - 1;
        final int after = ast.getColumnNo() + ast.getText().length();

        if (before >= 0) {
            final char prevChar = line.charAt(before);
            if (shouldCheckSeparationFromPreviousToken(ast)
                    && !Character.isWhitespace(prevChar)) {
                log(ast.getLineNo(), ast.getColumnNo(),
                        MSG_WS_NOT_PRECEDED, ast.getText());
            }
        }

        if (after < line.length()) {
            final char nextChar = line.charAt(after);
            if (shouldCheckSeparationFromNextToken(ast, nextChar)
                    && !Character.isWhitespace(nextChar)) {
                log(ast.getLineNo(), ast.getColumnNo() + ast.getText().length(),
                        MSG_WS_NOT_FOLLOWED, ast.getText());
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:28,代码来源:WhitespaceAroundCheck.java

示例12: checkPosition

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Whether the declaration is located before the checked ast.
 * @param ast1 the IDENT ast of the declaration.
 * @param ast2 the IDENT ast to check.
 * @return true, if the declaration is located before the checked ast.
 */
private static boolean checkPosition(DetailAST ast1, DetailAST ast2) {
    boolean result = false;
    if (ast1.getLineNo() < ast2.getLineNo()
            || ast1.getLineNo() == ast2.getLineNo()
            && ast1.getColumnNo() < ast2.getColumnNo()) {
        result = true;
    }
    return result;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:RequireThisCheck.java

示例13: isFollowedByWhitespace

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Checks whether token is followed by a whitespace.
 * @param targetAST Ast token.
 * @param line The line associated with the ast token.
 * @return true if ast token is followed by a whitespace.
 */
private static boolean isFollowedByWhitespace(DetailAST targetAST, String line) {
    final int after =
        targetAST.getColumnNo() + targetAST.getText().length();
    boolean followedByWhitespace = true;

    if (after < line.length()) {
        final char charAfter = line.charAt(after);
        followedByWhitespace = charAfter == ';'
            || charAfter == ')'
            || Character.isWhitespace(charAfter);
    }
    return followedByWhitespace;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:WhitespaceAfterCheck.java

示例14: processStart

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Checks the token for the start of Generics.
 * @param ast the token to check
 */
private void processStart(DetailAST ast) {
    final String line = getLine(ast.getLineNo() - 1);
    final int before = ast.getColumnNo() - 1;
    final int after = ast.getColumnNo() + 1;

    // Need to handle two cases as in:
    //
    //   public static <T> Callable<T> callable(Runnable task, T result)
    //                 ^           ^
    //      ws reqd ---+           +--- whitespace NOT required
    //
    if (before >= 0) {
        // Detect if the first case
        final DetailAST parent = ast.getParent();
        final DetailAST grandparent = parent.getParent();
        if (parent.getType() == TokenTypes.TYPE_PARAMETERS
            && (grandparent.getType() == TokenTypes.CTOR_DEF
                || grandparent.getType() == TokenTypes.METHOD_DEF)) {
            // Require whitespace
            if (!Character.isWhitespace(line.charAt(before))) {
                log(ast.getLineNo(), before, MSG_WS_NOT_PRECEDED, OPEN_ANGLE_BRACKET);
            }
        }
        // Whitespace not required
        else if (Character.isWhitespace(line.charAt(before))
            && !containsWhitespaceBefore(before, line)) {
            log(ast.getLineNo(), before, MSG_WS_PRECEDED, OPEN_ANGLE_BRACKET);
        }
    }

    if (after < line.length()
            && Character.isWhitespace(line.charAt(after))) {
        log(ast.getLineNo(), after, MSG_WS_FOLLOWED, OPEN_ANGLE_BRACKET);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:40,代码来源:GenericWhitespaceCheck.java

示例15: getSuggestedChildIndent

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Override
public IndentLevel getSuggestedChildIndent(AbstractExpressionHandler child) {
    // for whatever reason a method that crosses lines, like asList
    // here:
    //            System.out.println("methods are: " + Arrays.asList(
    //                new String[] {"method"}).toString());
    // will not have the right line num, so just get the child name

    final DetailAST first = getMainAst().getFirstChild();
    IndentLevel suggestedLevel = new IndentLevel(getLineStart(first));
    if (!areOnSameLine(child.getMainAst().getFirstChild(),
                       getMainAst().getFirstChild())) {
        suggestedLevel = new IndentLevel(suggestedLevel,
                getBasicOffset(),
                getIndentCheck().getLineWrappingIndentation());
    }

    // If the right parenthesis is at the start of a line;
    // include line wrapping in suggested indent level.
    final DetailAST rparen = getMainAst().findFirstToken(TokenTypes.RPAREN);
    if (getLineStart(rparen) == rparen.getColumnNo()) {
        suggestedLevel.addAcceptedIndent(new IndentLevel(
                getParent().getSuggestedChildIndent(this),
                getIndentCheck().getLineWrappingIndentation()
        ));
    }

    return suggestedLevel;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:30,代码来源:MethodCallHandler.java


注:本文中的com.puppycrawl.tools.checkstyle.api.DetailAST.getColumnNo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。