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


Java TokenTypes.COLON属性代码示例

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


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

示例1: visitToken

@Override
public void visitToken(DetailAST ast) {
    final DetailAST parent = ast.getParent();
    //we do not want to check colon for cases and defaults
    if (ast.getType() != TokenTypes.COLON
            || parent.getType() != TokenTypes.LITERAL_DEFAULT
                && parent.getType() != TokenTypes.LITERAL_CASE) {
        final String text = ast.getText();
        final int colNo = ast.getColumnNo();
        final int lineNo = ast.getLineNo();
        final String currentLine = getLine(lineNo - 1);

        // Check if rest of line is whitespace, and not just the operator
        // by itself. This last bit is to handle the operator on a line by
        // itself.
        if (option == WrapOption.NL
                && !text.equals(currentLine.trim())
                && CommonUtils.isBlank(currentLine.substring(colNo + text.length()))) {
            log(lineNo, colNo, MSG_LINE_NEW, text);
        }
        else if (option == WrapOption.EOL
                && CommonUtils.hasWhitespaceBefore(colNo - 1, currentLine)) {
            log(lineNo, colNo, MSG_LINE_PREVIOUS, text);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:26,代码来源:OperatorWrapCheck.java

示例2: resolveQuestion

private IClass resolveQuestion(
    SymTabAST question,
    Scope location,
    IClass context,
    boolean referencePhase) {
    SymTabAST test = (SymTabAST) question.getFirstChild();
    while (test.getType() == TokenTypes.LPAREN) {
        test = (SymTabAST) test.getNextSibling();
    }
    SymTabAST leftBranch = (SymTabAST) test.getNextSibling();
    while (leftBranch.getType() == TokenTypes.RPAREN) {
        leftBranch = (SymTabAST) leftBranch.getNextSibling();
    }
    SymTabAST rightBranch = (SymTabAST) leftBranch.getNextSibling();
    while (rightBranch.getType() != TokenTypes.COLON) {
        rightBranch = (SymTabAST) rightBranch.getNextSibling();
    }
    rightBranch = (SymTabAST) rightBranch.getNextSibling();

    resolveExpression(test, location, context, referencePhase);
    IClass leftClass =
        resolveExpression(leftBranch, location, context, referencePhase);
    IClass rightClass =
        resolveExpression(rightBranch, location, context, referencePhase);

    return moreGeneral(leftClass, rightClass);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:Resolver.java

示例3: getDefaultTokens

@Override
public int[] getDefaultTokens() {
    return new int[] {
        TokenTypes.QUESTION,          // '?'
        TokenTypes.COLON,             // ':' (not reported for a case)
        TokenTypes.EQUAL,             // "=="
        TokenTypes.NOT_EQUAL,         // "!="
        TokenTypes.DIV,               // '/'
        TokenTypes.PLUS,              //' +' (unary plus is UNARY_PLUS)
        TokenTypes.MINUS,             // '-' (unary minus is UNARY_MINUS)
        TokenTypes.STAR,              // '*'
        TokenTypes.MOD,               // '%'
        TokenTypes.SR,                // ">>"
        TokenTypes.BSR,               // ">>>"
        TokenTypes.GE,                // ">="
        TokenTypes.GT,                // ">"
        TokenTypes.SL,                // "<<"
        TokenTypes.LE,                // "<="
        TokenTypes.LT,                // '<'
        TokenTypes.BXOR,              // '^'
        TokenTypes.BOR,               // '|'
        TokenTypes.LOR,               // "||"
        TokenTypes.BAND,              // '&'
        TokenTypes.LAND,              // "&&"
        TokenTypes.TYPE_EXTENSION_AND,
        TokenTypes.LITERAL_INSTANCEOF,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:28,代码来源:OperatorWrapCheck.java

示例4: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.QUESTION,          // '?'
        TokenTypes.COLON,             // ':' (not reported for a case)
        TokenTypes.EQUAL,             // "=="
        TokenTypes.NOT_EQUAL,         // "!="
        TokenTypes.DIV,               // '/'
        TokenTypes.PLUS,              //' +' (unary plus is UNARY_PLUS)
        TokenTypes.MINUS,             // '-' (unary minus is UNARY_MINUS)
        TokenTypes.STAR,              // '*'
        TokenTypes.MOD,               // '%'
        TokenTypes.SR,                // ">>"
        TokenTypes.BSR,               // ">>>"
        TokenTypes.GE,                // ">="
        TokenTypes.GT,                // ">"
        TokenTypes.SL,                // "<<"
        TokenTypes.LE,                // "<="
        TokenTypes.LT,                // '<'
        TokenTypes.BXOR,              // '^'
        TokenTypes.BOR,               // '|'
        TokenTypes.LOR,               // "||"
        TokenTypes.BAND,              // '&'
        TokenTypes.LAND,              // "&&"
        TokenTypes.LITERAL_INSTANCEOF,
        TokenTypes.TYPE_EXTENSION_AND,
        TokenTypes.ASSIGN,            // '='
        TokenTypes.DIV_ASSIGN,        // "/="
        TokenTypes.PLUS_ASSIGN,       // "+="
        TokenTypes.MINUS_ASSIGN,      //"-="
        TokenTypes.STAR_ASSIGN,       // "*="
        TokenTypes.MOD_ASSIGN,        // "%="
        TokenTypes.SR_ASSIGN,         // ">>="
        TokenTypes.BSR_ASSIGN,        // ">>>="
        TokenTypes.SL_ASSIGN,         // "<<="
        TokenTypes.BXOR_ASSIGN,       // "^="
        TokenTypes.BOR_ASSIGN,        // "|="
        TokenTypes.BAND_ASSIGN,       // "&="
        TokenTypes.METHOD_REF,        // "::"

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

示例5: getDefaultTokens

@Override
public int[] getDefaultTokens() {
    return new int[] {
        TokenTypes.ASSIGN,
        TokenTypes.BAND,
        TokenTypes.BAND_ASSIGN,
        TokenTypes.BOR,
        TokenTypes.BOR_ASSIGN,
        TokenTypes.BSR,
        TokenTypes.BSR_ASSIGN,
        TokenTypes.BXOR,
        TokenTypes.BXOR_ASSIGN,
        TokenTypes.COLON,
        TokenTypes.DIV,
        TokenTypes.DIV_ASSIGN,
        TokenTypes.DO_WHILE,
        TokenTypes.EQUAL,
        TokenTypes.GE,
        TokenTypes.GT,
        TokenTypes.LAMBDA,
        TokenTypes.LAND,
        TokenTypes.LCURLY,
        TokenTypes.LE,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.LITERAL_FOR,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_RETURN,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.LITERAL_SYNCHRONIZED,
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LOR,
        TokenTypes.LT,
        TokenTypes.MINUS,
        TokenTypes.MINUS_ASSIGN,
        TokenTypes.MOD,
        TokenTypes.MOD_ASSIGN,
        TokenTypes.NOT_EQUAL,
        TokenTypes.PLUS,
        TokenTypes.PLUS_ASSIGN,
        TokenTypes.QUESTION,
        TokenTypes.RCURLY,
        TokenTypes.SL,
        TokenTypes.SLIST,
        TokenTypes.SL_ASSIGN,
        TokenTypes.SR,
        TokenTypes.SR_ASSIGN,
        TokenTypes.STAR,
        TokenTypes.STAR_ASSIGN,
        TokenTypes.LITERAL_ASSERT,
        TokenTypes.TYPE_EXTENSION_AND,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:56,代码来源:WhitespaceAroundCheck.java

示例6: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.ASSIGN,
        TokenTypes.ARRAY_INIT,
        TokenTypes.BAND,
        TokenTypes.BAND_ASSIGN,
        TokenTypes.BOR,
        TokenTypes.BOR_ASSIGN,
        TokenTypes.BSR,
        TokenTypes.BSR_ASSIGN,
        TokenTypes.BXOR,
        TokenTypes.BXOR_ASSIGN,
        TokenTypes.COLON,
        TokenTypes.DIV,
        TokenTypes.DIV_ASSIGN,
        TokenTypes.DO_WHILE,
        TokenTypes.EQUAL,
        TokenTypes.GE,
        TokenTypes.GT,
        TokenTypes.LAMBDA,
        TokenTypes.LAND,
        TokenTypes.LCURLY,
        TokenTypes.LE,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.LITERAL_FOR,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_RETURN,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.LITERAL_SYNCHRONIZED,
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LOR,
        TokenTypes.LT,
        TokenTypes.MINUS,
        TokenTypes.MINUS_ASSIGN,
        TokenTypes.MOD,
        TokenTypes.MOD_ASSIGN,
        TokenTypes.NOT_EQUAL,
        TokenTypes.PLUS,
        TokenTypes.PLUS_ASSIGN,
        TokenTypes.QUESTION,
        TokenTypes.RCURLY,
        TokenTypes.SL,
        TokenTypes.SLIST,
        TokenTypes.SL_ASSIGN,
        TokenTypes.SR,
        TokenTypes.SR_ASSIGN,
        TokenTypes.STAR,
        TokenTypes.STAR_ASSIGN,
        TokenTypes.LITERAL_ASSERT,
        TokenTypes.TYPE_EXTENSION_AND,
        TokenTypes.WILDCARD_TYPE,
        TokenTypes.GENERIC_START,
        TokenTypes.GENERIC_END,
        TokenTypes.ELLIPSIS,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:61,代码来源:WhitespaceAroundCheck.java

示例7: testGetAcceptableTokens

@Test
public void testGetAcceptableTokens() {
    final WhitespaceAroundCheck whitespaceAroundCheckObj = new WhitespaceAroundCheck();
    final int[] actual = whitespaceAroundCheckObj.getAcceptableTokens();
    final int[] expected = {
        TokenTypes.ASSIGN,
        TokenTypes.ARRAY_INIT,
        TokenTypes.BAND,
        TokenTypes.BAND_ASSIGN,
        TokenTypes.BOR,
        TokenTypes.BOR_ASSIGN,
        TokenTypes.BSR,
        TokenTypes.BSR_ASSIGN,
        TokenTypes.BXOR,
        TokenTypes.BXOR_ASSIGN,
        TokenTypes.COLON,
        TokenTypes.DIV,
        TokenTypes.DIV_ASSIGN,
        TokenTypes.DO_WHILE,
        TokenTypes.EQUAL,
        TokenTypes.GE,
        TokenTypes.GT,
        TokenTypes.LAMBDA,
        TokenTypes.LAND,
        TokenTypes.LCURLY,
        TokenTypes.LE,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.LITERAL_FOR,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_RETURN,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.LITERAL_SYNCHRONIZED,
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LOR,
        TokenTypes.LT,
        TokenTypes.MINUS,
        TokenTypes.MINUS_ASSIGN,
        TokenTypes.MOD,
        TokenTypes.MOD_ASSIGN,
        TokenTypes.NOT_EQUAL,
        TokenTypes.PLUS,
        TokenTypes.PLUS_ASSIGN,
        TokenTypes.QUESTION,
        TokenTypes.RCURLY,
        TokenTypes.SL,
        TokenTypes.SLIST,
        TokenTypes.SL_ASSIGN,
        TokenTypes.SR,
        TokenTypes.SR_ASSIGN,
        TokenTypes.STAR,
        TokenTypes.STAR_ASSIGN,
        TokenTypes.LITERAL_ASSERT,
        TokenTypes.TYPE_EXTENSION_AND,
        TokenTypes.WILDCARD_TYPE,
        TokenTypes.GENERIC_START,
        TokenTypes.GENERIC_END,
        TokenTypes.ELLIPSIS,
    };
    assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:64,代码来源:WhitespaceAroundCheckTest.java

示例8: isColonOfCaseOrDefault

/**
 * Whether colon belongs to cases or defaults.
 * @param currentType current
 * @param parentType parent
 * @return true if current token in colon of case or default tokens
 */
private static boolean isColonOfCaseOrDefault(int currentType, int parentType) {
    return currentType == TokenTypes.COLON
            && (parentType == TokenTypes.LITERAL_DEFAULT
                    || parentType == TokenTypes.LITERAL_CASE);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:11,代码来源:WhitespaceAroundCheck.java

示例9: isColonOfForEach

/**
 * Whether colon belongs to for-each.
 * @param currentType current
 * @param parentType parent
 * @return true if current token in colon of for-each token
 */
private boolean isColonOfForEach(int currentType, int parentType) {
    return currentType == TokenTypes.COLON
            && parentType == TokenTypes.FOR_EACH_CLAUSE
            && ignoreEnhancedForColon;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:11,代码来源:WhitespaceAroundCheck.java


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