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


Java TokenTypes.LITERAL_TRY属性代码示例

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


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

示例1: getRequiredTokens

@Override
public int[] getRequiredTokens() {
    return new int[] {
        TokenTypes.CTOR_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.STATIC_INIT,
        TokenTypes.INSTANCE_INIT,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_FOR,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.CASE_GROUP,
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.QUESTION,
        TokenTypes.LITERAL_RETURN,
        TokenTypes.LITERAL_DEFAULT,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:21,代码来源:NPathComplexityCheck.java

示例2: getRequiredTokens

@Override
public int[] getRequiredTokens() {
    return new int[] {
        TokenTypes.METHOD_CALL,
        TokenTypes.CLASS_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_FOR,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_TRY,
        TokenTypes.VARIABLE_DEF,
        TokenTypes.PARAMETER_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.SLIST,
        TokenTypes.ENUM_DEF,
        TokenTypes.ENUM_CONSTANT_DEF,
        TokenTypes.LITERAL_NEW,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:21,代码来源:EqualsAvoidNullCheck.java

示例3: getDefaultTokens

@Override
public int[] getDefaultTokens() {
    return new int[] {
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_FOR,
        TokenTypes.INSTANCE_INIT,
        TokenTypes.STATIC_INIT,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.LITERAL_SYNCHRONIZED,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:EmptyBlockCheck.java

示例4: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_FOR,
        TokenTypes.INSTANCE_INIT,
        TokenTypes.STATIC_INIT,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.LITERAL_SYNCHRONIZED,
        TokenTypes.LITERAL_CASE,
        TokenTypes.LITERAL_DEFAULT,
        TokenTypes.ARRAY_INIT,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:EmptyBlockCheck.java

示例5: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.INTERFACE_DEF,
        TokenTypes.CLASS_DEF,
        TokenTypes.ANNOTATION_DEF,
        TokenTypes.ENUM_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.ENUM_CONSTANT_DEF,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.LITERAL_SYNCHRONIZED,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_FOR,
        TokenTypes.STATIC_INIT,
        TokenTypes.OBJBLOCK,
        TokenTypes.LAMBDA,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:25,代码来源:LeftCurlyCheck.java

示例6: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.CLASS_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.LITERAL_FOR,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_DO,
        TokenTypes.STATIC_INIT,
        TokenTypes.INSTANCE_INIT,
        TokenTypes.LAMBDA,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:RightCurlyCheck.java

示例7: testGetRequiredTokens

@Test
public void testGetRequiredTokens() {
    final NPathComplexityCheck npathComplexityCheckObj = new NPathComplexityCheck();
    final int[] actual = npathComplexityCheckObj.getRequiredTokens();
    final int[] expected = {
        TokenTypes.CTOR_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.STATIC_INIT,
        TokenTypes.INSTANCE_INIT,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_FOR,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.CASE_GROUP,
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.QUESTION,
        TokenTypes.LITERAL_RETURN,
        TokenTypes.LITERAL_DEFAULT,
    };
    Assert.assertNotNull("Required tokens should not be null", actual);
    Assert.assertArrayEquals("Invalid required tokens", expected, actual);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:25,代码来源:NPathComplexityCheckTest.java

示例8: leaveToken

@Override
public void leaveToken(DetailAST ast) {
    switch (ast.getType()) {
        case TokenTypes.LITERAL_WHILE:
        case TokenTypes.LITERAL_DO:
        case TokenTypes.LITERAL_FOR:
        case TokenTypes.LITERAL_IF:
        case TokenTypes.LITERAL_SWITCH:
            leaveConditional();
            break;
        case TokenTypes.LITERAL_TRY:
            leaveMultiplyingConditional();
            break;
        case TokenTypes.LITERAL_RETURN:
        case TokenTypes.QUESTION:
            leaveUnitaryOperator();
            break;
        case TokenTypes.LITERAL_CATCH:
            leaveAddingConditional();
            break;
        case TokenTypes.LITERAL_DEFAULT:
            leaveBranch();
            break;
        case TokenTypes.LITERAL_ELSE:
        case TokenTypes.CASE_GROUP:
            leaveBranch();
            branchVisited = false;
            break;
        case TokenTypes.CTOR_DEF:
        case TokenTypes.METHOD_DEF:
        case TokenTypes.INSTANCE_INIT:
        case TokenTypes.STATIC_INIT:
            leaveMethodDef(ast);
            break;
        default:
            break;
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:38,代码来源:NPathComplexityCheck.java

示例9: isStatementWithPossibleCurlies

/**
 * Whether the statement can have or always have curly brackets.
 * @param previousSibling the statement to check.
 * @return true if the statement can have or always have curly brackets.
 */
private static boolean isStatementWithPossibleCurlies(DetailAST previousSibling) {
    return previousSibling.getType() == TokenTypes.LITERAL_IF
        || previousSibling.getType() == TokenTypes.LITERAL_TRY
        || previousSibling.getType() == TokenTypes.LITERAL_FOR
        || previousSibling.getType() == TokenTypes.LITERAL_DO
        || previousSibling.getType() == TokenTypes.LITERAL_WHILE
        || previousSibling.getType() == TokenTypes.LITERAL_SWITCH
        || isDefinition(previousSibling);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:14,代码来源:CommentsIndentationCheck.java

示例10: getDefaultTokens

@Override
public int[] getDefaultTokens() {
    return new int[] {
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:10,代码来源:RightCurlyCheck.java

示例11: getDetails

/**
 * Collects validation Details.
 * @param ast a {@code DetailAST} value
 * @return object containing all details to make a validation
 */
private static Details getDetails(DetailAST ast) {
    final Details details;
    switch (ast.getType()) {
        case TokenTypes.LITERAL_TRY:
        case TokenTypes.LITERAL_CATCH:
        case TokenTypes.LITERAL_FINALLY:
            details = getDetailsForTryCatchFinally(ast);
            break;
        case TokenTypes.LITERAL_IF:
        case TokenTypes.LITERAL_ELSE:
            details = getDetailsForIfElse(ast);
            break;
        case TokenTypes.LITERAL_DO:
        case TokenTypes.LITERAL_WHILE:
        case TokenTypes.LITERAL_FOR:
            details = getDetailsForLoops(ast);
            break;
        case TokenTypes.LAMBDA:
            details = getDetailsForLambda(ast);
            break;
        default:
            details = getDetailsForOthers(ast);
            break;
    }
    return details;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:31,代码来源:RightCurlyCheck.java

示例12: getDetailsForTryCatchFinally

/**
 * Collects validation details for LITERAL_TRY, LITERAL_CATCH, and LITERAL_FINALLY.
 * @param ast a {@code DetailAST} value
 * @return object containing all details to make a validation
 */
private static Details getDetailsForTryCatchFinally(DetailAST ast) {
    boolean shouldCheckLastRcurly = false;
    final DetailAST rcurly;
    final DetailAST lcurly;
    DetailAST nextToken;
    final int tokenType = ast.getType();
    if (tokenType == TokenTypes.LITERAL_TRY) {
        if (ast.getFirstChild().getType() == TokenTypes.RESOURCE_SPECIFICATION) {
            lcurly = ast.getFirstChild().getNextSibling();
        }
        else {
            lcurly = ast.getFirstChild();
        }
        nextToken = lcurly.getNextSibling();
        rcurly = lcurly.getLastChild();

        if (nextToken == null) {
            shouldCheckLastRcurly = true;
            nextToken = getNextToken(ast);
        }
    }
    else if (tokenType == TokenTypes.LITERAL_CATCH) {
        nextToken = ast.getNextSibling();
        lcurly = ast.getLastChild();
        rcurly = lcurly.getLastChild();
        if (nextToken == null) {
            shouldCheckLastRcurly = true;
            nextToken = getNextToken(ast);
        }

    }
    else {
        shouldCheckLastRcurly = true;
        nextToken = getNextToken(ast);
        lcurly = ast.getFirstChild();
        rcurly = lcurly.getLastChild();
    }
    return new Details(lcurly, rcurly, nextToken, shouldCheckLastRcurly);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:44,代码来源:RightCurlyCheck.java

示例13: testGetAcceptableTokens

@Test
public void testGetAcceptableTokens() {
    final LeftCurlyCheck check = new LeftCurlyCheck();
    final int[] actual = check.getAcceptableTokens();
    final int[] expected = {
        TokenTypes.INTERFACE_DEF,
        TokenTypes.CLASS_DEF,
        TokenTypes.ANNOTATION_DEF,
        TokenTypes.ENUM_DEF,
        TokenTypes.CTOR_DEF,
        TokenTypes.METHOD_DEF,
        TokenTypes.ENUM_CONSTANT_DEF,
        TokenTypes.LITERAL_WHILE,
        TokenTypes.LITERAL_TRY,
        TokenTypes.LITERAL_CATCH,
        TokenTypes.LITERAL_FINALLY,
        TokenTypes.LITERAL_SYNCHRONIZED,
        TokenTypes.LITERAL_SWITCH,
        TokenTypes.LITERAL_DO,
        TokenTypes.LITERAL_IF,
        TokenTypes.LITERAL_ELSE,
        TokenTypes.LITERAL_FOR,
        TokenTypes.STATIC_INIT,
        TokenTypes.OBJBLOCK,
        TokenTypes.LAMBDA, };
    assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:27,代码来源:LeftCurlyCheckTest.java

示例14: handleBlock

/**
 * processes a <code>BlockDef</code> and resolves references in it
 *
 * @param block the <code>BlockDef</code> to process
 */
protected void handleBlock(BlockDef block) {
    SymTabAST node = block.getTreeNode();

    switch (node.getType()) {

        case TokenTypes.LITERAL_FOR :
            handleFor(block);
            break;

        case TokenTypes.LITERAL_IF :
            handleIf(block);
            break;

        case TokenTypes.LITERAL_WHILE :
            handleWhileAndSynchronized(block);
            break;

        case TokenTypes.LITERAL_DO :
            handleDoWhile(block);
            break;

        case TokenTypes.LITERAL_TRY :
        case TokenTypes.LITERAL_FINALLY :
            SymTabAST slist = node.findFirstToken(TokenTypes.SLIST);

            handleSList(slist, block);
            break;

        case TokenTypes.LITERAL_CATCH :
            handleCatch(block);
            break;

        case TokenTypes.LITERAL_SWITCH :
            handleSwitch(block);
            break;

        case TokenTypes.SLIST :
            handleSList(node, block);
            break;

        case TokenTypes.EXPR :
            resolveExpression(node, block, null, true);
            break;

        case TokenTypes.INSTANCE_INIT :
        case TokenTypes.STATIC_INIT :
            handleSList((SymTabAST) node.getFirstChild(), block);
            break;

        case TokenTypes.LITERAL_SYNCHRONIZED :
            handleWhileAndSynchronized(block);
            break;

        case TokenTypes.LITERAL_ASSERT :
            handleAssert(block);
            break;

        default :
            if (mInitialized) {
                final Log log = mLogFactory.getInstance(this.getClass());
                log.error(
                    "Unhandled block "
                        + block
                        + " of type "
                        + node.getType());
            }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:73,代码来源:Resolver.java

示例15: visitToken

@Override
public void visitToken(DetailAST ast) {
    switch (ast.getType()) {
        case TokenTypes.LITERAL_IF:
        case TokenTypes.LITERAL_SWITCH:
        case TokenTypes.LITERAL_WHILE:
        case TokenTypes.LITERAL_DO:
        case TokenTypes.LITERAL_FOR:
            visitConditional(ast, 1);
            break;
        case TokenTypes.QUESTION:
            visitUnitaryOperator(ast, 2);
            break;
        case TokenTypes.LITERAL_RETURN:
            visitUnitaryOperator(ast, 0);
            break;
        case TokenTypes.CASE_GROUP:
            final int caseNumber = countCaseTokens(ast);
            branchVisited = true;
            pushValue(caseNumber);
            break;
        case TokenTypes.LITERAL_ELSE:
            branchVisited = true;
            if (currentRangeValue.equals(BigInteger.ZERO)) {
                currentRangeValue = BigInteger.ONE;
            }
            pushValue(0);
            break;
        case TokenTypes.LITERAL_TRY:
        case TokenTypes.LITERAL_CATCH:
        case TokenTypes.LITERAL_DEFAULT:
            pushValue(1);
            break;
        case TokenTypes.CTOR_DEF:
        case TokenTypes.METHOD_DEF:
        case TokenTypes.INSTANCE_INIT:
        case TokenTypes.STATIC_INIT:
            pushValue(0);
            break;
        default:
            break;
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:43,代码来源:NPathComplexityCheck.java


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