Java Code Examples for com.puppycrawl.tools.checkstyle.api.TokenTypes#CASE_GROUP

The following examples show how to use com.puppycrawl.tools.checkstyle.api.TokenTypes#CASE_GROUP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Resolver.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * processes a switch statement and resolves references in it
 *
 * @param block the <code>BlockDef</code> to process
 */
private void handleSwitch(BlockDef block) {
    SymTabAST node = block.getTreeNode();

    SymTabAST expr = node.findFirstToken(TokenTypes.EXPR);
    resolveExpression(expr, block, null, true);

    SymTabAST caseGroup = (SymTabAST) (expr.getNextSibling());
    while (caseGroup != null
        && (caseGroup.getType() != TokenTypes.CASE_GROUP)) {
        caseGroup = (SymTabAST) caseGroup.getNextSibling();
    }
    if (caseGroup != null) {
        while (caseGroup.getType() == TokenTypes.CASE_GROUP) {
            SymTabAST caseNode =
                caseGroup.findFirstToken(TokenTypes.LITERAL_CASE);
            while (caseNode != null
                && caseNode.getType() == TokenTypes.LITERAL_CASE) {
                resolveExpression(
                    (SymTabAST) caseNode.getFirstChild(),
                    block,
                    null,
                    true);
                caseNode = (SymTabAST) caseNode.getNextSibling();
            }

            SymTabAST caseSlist =
                caseGroup.findFirstToken(TokenTypes.SLIST);
            handleSList(caseSlist, block);

            caseGroup = (SymTabAST) (caseGroup.getNextSibling());
        }
    }
}
 
Example 2
Source File: Resolver.java    From contribution with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * processes a switch statement and resolves references in it
 *
 * @param block the <code>BlockDef</code> to process
 */
private void handleSwitch(BlockDef block) {
    SymTabAST node = block.getTreeNode();

    SymTabAST expr = node.findFirstToken(TokenTypes.EXPR);
    resolveExpression(expr, block, null, true);

    SymTabAST caseGroup = (SymTabAST) (expr.getNextSibling());
    while (caseGroup != null
        && (caseGroup.getType() != TokenTypes.CASE_GROUP)) {
        caseGroup = (SymTabAST) caseGroup.getNextSibling();
    }
    if (caseGroup != null) {
        while (caseGroup.getType() == TokenTypes.CASE_GROUP) {
            SymTabAST caseNode =
                caseGroup.findFirstToken(TokenTypes.LITERAL_CASE);
            while (caseNode != null
                && caseNode.getType() == TokenTypes.LITERAL_CASE) {
                resolveExpression(
                    (SymTabAST) caseNode.getFirstChild(),
                    block,
                    null,
                    true);
                caseNode = (SymTabAST) caseNode.getNextSibling();
            }

            SymTabAST caseSlist =
                caseGroup.findFirstToken(TokenTypes.SLIST);
            handleSList(caseSlist, block);

            caseGroup = (SymTabAST) (caseGroup.getNextSibling());
        }
    }
}