Java Code Examples for com.puppycrawl.tools.checkstyle.api.TokenTypes#RPAREN
The following examples show how to use
com.puppycrawl.tools.checkstyle.api.TokenTypes#RPAREN .
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: TableMaker.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * process the given SymTabAST as an if block * * @param tree the SymTabAST to process * @return <code>void</code> * @see #makeBlock(SymTabAST) * @see #walkTree(SymTabAST, boolean) * @see #processElse(SymTabAST) */ public void processIf(SymTabAST tree) { BlockDef block = makeBlock(tree); SymTabAST expr = tree.findFirstToken(TokenTypes.EXPR); SymTabAST ifBranch = (SymTabAST)expr.getNextSibling(); // handle Checkstyle grammar if (ifBranch.getType() == TokenTypes.RPAREN) { ifBranch = (SymTabAST) ifBranch.getNextSibling(); } SymTabAST elseBranch = (SymTabAST)ifBranch.getNextSibling(); // handle Checkstyle grammar if ((elseBranch != null) && (elseBranch.getType() == TokenTypes.SEMI)) { elseBranch = (SymTabAST) elseBranch.getNextSibling(); } if ((elseBranch != null) && (elseBranch.getType() == TokenTypes.LITERAL_ELSE)) { elseBranch = (SymTabAST) elseBranch.getFirstChild(); } symbolTable.pushScope( block ); walkTree(expr, false); walkTree(ifBranch, false); symbolTable.popScope(); processElse(elseBranch); }
Example 2
Source File: TableMaker.java From contribution with GNU Lesser General Public License v2.1 | 6 votes |
/** * process the given SymTabAST as an if block * * @param tree the SymTabAST to process * @return <code>void</code> * @see #makeBlock(SymTabAST) * @see #walkTree(SymTabAST, boolean) * @see #processElse(SymTabAST) */ public void processIf(SymTabAST tree) { BlockDef block = makeBlock(tree); SymTabAST expr = tree.findFirstToken(TokenTypes.EXPR); SymTabAST ifBranch = (SymTabAST)expr.getNextSibling(); // handle Checkstyle grammar if (ifBranch.getType() == TokenTypes.RPAREN) { ifBranch = (SymTabAST) ifBranch.getNextSibling(); } SymTabAST elseBranch = (SymTabAST)ifBranch.getNextSibling(); // handle Checkstyle grammar if ((elseBranch != null) && (elseBranch.getType() == TokenTypes.SEMI)) { elseBranch = (SymTabAST) elseBranch.getNextSibling(); } if ((elseBranch != null) && (elseBranch.getType() == TokenTypes.LITERAL_ELSE)) { elseBranch = (SymTabAST) elseBranch.getFirstChild(); } symbolTable.pushScope( block ); walkTree(expr, false); walkTree(ifBranch, false); symbolTable.popScope(); processElse(elseBranch); }
Example 3
Source File: Resolver.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * processes a while loop and resolves references in it * * @param block the <code>BlockDef</code> to process */ private void handleWhileAndSynchronized(BlockDef block) { SymTabAST node = block.getTreeNode(); SymTabAST condition = (node.findFirstToken(TokenTypes.EXPR)); SymTabAST slist = (SymTabAST) (condition.getNextSibling()); // handle Checkstyle grammar if (slist.getType() == TokenTypes.RPAREN) { slist = (SymTabAST) slist.getNextSibling(); } resolveExpression(condition, block, null, true); handleSList(slist, block); }
Example 4
Source File: Resolver.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
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); }
Example 5
Source File: Resolver.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Finds the right sibling of the left child of a binary operator, * skipping parentheses. * @param aLeftChild the left child of a binary operator. * @return the node of the right sibling. */ private SymTabAST findRightSibling(SymTabAST aLeftChild) { SymTabAST rightChild = (SymTabAST) (aLeftChild.getNextSibling()); // handle Checkstyle grammar while ((rightChild != null) && (rightChild.getType() == TokenTypes.RPAREN)) { rightChild = (SymTabAST) rightChild.getNextSibling(); } return rightChild; }
Example 6
Source File: TableMaker.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * process the given SymTabAST as a for block * * @param tree the SymTabAST to process * @return <code>void</code> * @see #makeBlock(SymTabAST) * @see #walkTree(SymTabAST, boolean) */ public void processFor(SymTabAST tree) { BlockDef block = makeBlock(tree); symbolTable.pushScope( block ); SymTabAST body; SymTabAST forEach = tree.findFirstToken(TokenTypes.FOR_EACH_CLAUSE); if (forEach != null) { walkTree(forEach, false); body = (SymTabAST)forEach.getNextSibling(); } else { walkTree(tree.findFirstToken(TokenTypes.FOR_INIT), false); walkTree(tree.findFirstToken(TokenTypes.FOR_CONDITION), false); SymTabAST forIter = tree.findFirstToken(TokenTypes.FOR_ITERATOR); walkTree(forIter, false); body = (SymTabAST)forIter.getNextSibling(); } //handle Checkstyle grammar if (body.getType() == TokenTypes.RPAREN) { body = (SymTabAST) body.getNextSibling(); } walkTree(body, false); symbolTable.popScope(); }
Example 7
Source File: Resolver.java From contribution with GNU Lesser General Public License v2.1 | 5 votes |
/** * processes a while loop and resolves references in it * * @param block the <code>BlockDef</code> to process */ private void handleWhileAndSynchronized(BlockDef block) { SymTabAST node = block.getTreeNode(); SymTabAST condition = (node.findFirstToken(TokenTypes.EXPR)); SymTabAST slist = (SymTabAST) (condition.getNextSibling()); // handle Checkstyle grammar if (slist.getType() == TokenTypes.RPAREN) { slist = (SymTabAST) slist.getNextSibling(); } resolveExpression(condition, block, null, true); handleSList(slist, block); }
Example 8
Source File: Resolver.java From contribution with GNU Lesser General Public License v2.1 | 5 votes |
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); }
Example 9
Source File: Resolver.java From contribution with GNU Lesser General Public License v2.1 | 5 votes |
/** * Finds the right sibling of the left child of a binary operator, * skipping parentheses. * @param aLeftChild the left child of a binary operator. * @return the node of the right sibling. */ private SymTabAST findRightSibling(SymTabAST aLeftChild) { SymTabAST rightChild = (SymTabAST) (aLeftChild.getNextSibling()); // handle Checkstyle grammar while ((rightChild != null) && (rightChild.getType() == TokenTypes.RPAREN)) { rightChild = (SymTabAST) rightChild.getNextSibling(); } return rightChild; }
Example 10
Source File: TableMaker.java From contribution with GNU Lesser General Public License v2.1 | 5 votes |
/** * process the given SymTabAST as a for block * * @param tree the SymTabAST to process * @return <code>void</code> * @see #makeBlock(SymTabAST) * @see #walkTree(SymTabAST, boolean) */ public void processFor(SymTabAST tree) { BlockDef block = makeBlock(tree); symbolTable.pushScope( block ); SymTabAST body; SymTabAST forEach = tree.findFirstToken(TokenTypes.FOR_EACH_CLAUSE); if (forEach != null) { walkTree(forEach, false); body = (SymTabAST)forEach.getNextSibling(); } else { walkTree(tree.findFirstToken(TokenTypes.FOR_INIT), false); walkTree(tree.findFirstToken(TokenTypes.FOR_CONDITION), false); SymTabAST forIter = tree.findFirstToken(TokenTypes.FOR_ITERATOR); walkTree(forIter, false); body = (SymTabAST)forIter.getNextSibling(); } //handle Checkstyle grammar if (body.getType() == TokenTypes.RPAREN) { body = (SymTabAST) body.getNextSibling(); } walkTree(body, false); symbolTable.popScope(); }
Example 11
Source File: Resolver.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * processes a for loop and resolves references in it * * @param block the <code>BlockDef</code> to process */ private void handleFor(BlockDef block) { SymTabAST node = block.getTreeNode(); SymTabAST body; SymTabAST forEach = node.findFirstToken(TokenTypes.FOR_EACH_CLAUSE); if (forEach == null) { SymTabAST init = node.findFirstToken(TokenTypes.FOR_INIT); // only need to handle the elist case. if the init node is a variable // definition, the variable def will be handled later on in the resolution if (init.getFirstChild() != null) { if (init.getFirstChild().getType() == TokenTypes.ELIST) { resolveExpression( (SymTabAST) (init.getFirstChild()), block, null, true); } } SymTabAST cond = node.findFirstToken(TokenTypes.FOR_CONDITION); if (cond.getFirstChild() != null) { resolveExpression( (SymTabAST) (cond.getFirstChild()), block, null, true); } SymTabAST iterator = node.findFirstToken(TokenTypes.FOR_ITERATOR); if (iterator.getFirstChild() != null) { resolveExpression( (SymTabAST) (iterator.getFirstChild()), block, null, true); } body = (SymTabAST) (iterator.getNextSibling()); } else { resolveExpression( (forEach.findFirstToken(TokenTypes.EXPR)), block, null, true); body = (SymTabAST) (forEach.getNextSibling()); } //could be an SLIST, EXPR or an EMPTY_STAT if (body.getType() == TokenTypes.RPAREN) { body = (SymTabAST) body.getNextSibling(); } if (body.getType() == TokenTypes.SLIST) { handleSList(body, block); } else { resolveExpression(body, block, null, true); } }
Example 12
Source File: Resolver.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * processes an if statement and resolves references in it * * @param block the <code>BlockDef</code> to process */ private void handleIf(BlockDef block) { SymTabAST node = block.getTreeNode(); SymTabAST conditional = (node.findFirstToken(TokenTypes.EXPR)); resolveExpression(conditional, block, null, true); SymTabAST body = (SymTabAST) conditional.getNextSibling(); // Handle Checkstyle grammar if (body.getType() == TokenTypes.RPAREN) { body = (SymTabAST) body.getNextSibling(); } if (body != null) { if (body.getType() == TokenTypes.SLIST) { handleSList(body, block); } else { resolveExpression(body, block, null, true); } SymTabAST elseBody = (SymTabAST) body.getNextSibling(); //handle Checkstyle grammar while ((elseBody != null) && (elseBody.getType() != TokenTypes.LITERAL_ELSE)) { elseBody = (SymTabAST) elseBody.getNextSibling(); } /* if (elseBody != null && elseBody.getType() == TokenTypes.SLIST) { handleSList(elseBody, block); }else{ resolveExpression(elseBody, block, null, true); } */ if (elseBody != null) { elseBody = (SymTabAST) elseBody.getFirstChild(); } if (elseBody != null) { resolveExpression(elseBody, block.getParentScope(), null, true); } } }
Example 13
Source File: Resolver.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
private IClass resolveTypecast( SymTabAST node, Scope location, IClass context, boolean referencePhase) { SymTabAST typeNode = (SymTabAST) node.getFirstChild(); SymTabAST exprNode = (SymTabAST) typeNode.getNextSibling(); //handle Checkstyle grammar if (exprNode.getType() == TokenTypes.RPAREN) { exprNode = (SymTabAST) exprNode.getNextSibling(); } IClass type = null; final SymTabAST child = (SymTabAST) typeNode.getFirstChild(); // TODO: Checkstyle change. // Do not create references from typecast. // Original transmogrify code is equivalent to // final boolean createReference = referencePhase; // which creates non-existant references for variables. final boolean createReference = false; if (child.getType() == TokenTypes.ARRAY_DECLARATOR) { type = new ArrayDef( resolveType( (SymTabAST) typeNode.getFirstChild(), location, context, createReference)); } else { type = resolveType(typeNode, location, context, createReference); } resolveExpression(exprNode, location, context, referencePhase); //TODO: Checkstyle change. Can this be ignored? if (type != null) { ((SymTabAST) typeNode.getFirstChild()).setDefinition( type, location, referencePhase); } return type; }
Example 14
Source File: Resolver.java From contribution with GNU Lesser General Public License v2.1 | 4 votes |
/** * processes a for loop and resolves references in it * * @param block the <code>BlockDef</code> to process */ private void handleFor(BlockDef block) { SymTabAST node = block.getTreeNode(); SymTabAST body; SymTabAST forEach = node.findFirstToken(TokenTypes.FOR_EACH_CLAUSE); if (forEach == null) { SymTabAST init = node.findFirstToken(TokenTypes.FOR_INIT); // only need to handle the elist case. if the init node is a variable // definition, the variable def will be handled later on in the resolution if (init.getFirstChild() != null) { if (init.getFirstChild().getType() == TokenTypes.ELIST) { resolveExpression( (SymTabAST) (init.getFirstChild()), block, null, true); } } SymTabAST cond = node.findFirstToken(TokenTypes.FOR_CONDITION); if (cond.getFirstChild() != null) { resolveExpression( (SymTabAST) (cond.getFirstChild()), block, null, true); } SymTabAST iterator = node.findFirstToken(TokenTypes.FOR_ITERATOR); if (iterator.getFirstChild() != null) { resolveExpression( (SymTabAST) (iterator.getFirstChild()), block, null, true); } body = (SymTabAST) (iterator.getNextSibling()); } else { resolveExpression( (forEach.findFirstToken(TokenTypes.EXPR)), block, null, true); body = (SymTabAST) (forEach.getNextSibling()); } //could be an SLIST, EXPR or an EMPTY_STAT if (body.getType() == TokenTypes.RPAREN) { body = (SymTabAST) body.getNextSibling(); } if (body.getType() == TokenTypes.SLIST) { handleSList(body, block); } else { resolveExpression(body, block, null, true); } }
Example 15
Source File: Resolver.java From contribution with GNU Lesser General Public License v2.1 | 4 votes |
/** * processes an if statement and resolves references in it * * @param block the <code>BlockDef</code> to process */ private void handleIf(BlockDef block) { SymTabAST node = block.getTreeNode(); SymTabAST conditional = (node.findFirstToken(TokenTypes.EXPR)); resolveExpression(conditional, block, null, true); SymTabAST body = (SymTabAST) conditional.getNextSibling(); // Handle Checkstyle grammar if (body.getType() == TokenTypes.RPAREN) { body = (SymTabAST) body.getNextSibling(); } if (body != null) { if (body.getType() == TokenTypes.SLIST) { handleSList(body, block); } else { resolveExpression(body, block, null, true); } SymTabAST elseBody = (SymTabAST) body.getNextSibling(); //handle Checkstyle grammar while ((elseBody != null) && (elseBody.getType() != TokenTypes.LITERAL_ELSE)) { elseBody = (SymTabAST) elseBody.getNextSibling(); } /* if (elseBody != null && elseBody.getType() == TokenTypes.SLIST) { handleSList(elseBody, block); }else{ resolveExpression(elseBody, block, null, true); } */ if (elseBody != null) { elseBody = (SymTabAST) elseBody.getFirstChild(); } if (elseBody != null) { resolveExpression(elseBody, block.getParentScope(), null, true); } } }
Example 16
Source File: Resolver.java From contribution with GNU Lesser General Public License v2.1 | 4 votes |
private IClass resolveTypecast( SymTabAST node, Scope location, IClass context, boolean referencePhase) { SymTabAST typeNode = (SymTabAST) node.getFirstChild(); SymTabAST exprNode = (SymTabAST) typeNode.getNextSibling(); //handle Checkstyle grammar if (exprNode.getType() == TokenTypes.RPAREN) { exprNode = (SymTabAST) exprNode.getNextSibling(); } IClass type = null; final SymTabAST child = (SymTabAST) typeNode.getFirstChild(); // TODO: Checkstyle change. // Do not create references from typecast. // Original transmogrify code is equivalent to // final boolean createReference = referencePhase; // which creates non-existant references for variables. final boolean createReference = false; if (child.getType() == TokenTypes.ARRAY_DECLARATOR) { type = new ArrayDef( resolveType( (SymTabAST) typeNode.getFirstChild(), location, context, createReference)); } else { type = resolveType(typeNode, location, context, createReference); } resolveExpression(exprNode, location, context, referencePhase); //TODO: Checkstyle change. Can this be ignored? if (type != null) { ((SymTabAST) typeNode.getFirstChild()).setDefinition( type, location, referencePhase); } return type; }