final public void Block() throws ParseException { ASTBlock jjtn000 = new ASTBlock(this, JJTBLOCK); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1));Token t; try { jj_consume_token(LBRACE); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.jjtSetLastToken(getToken(0)); if (isPrecededByComment(t)) { jjtn000.setContainsComment(); } } catch (Throwable jjte000) { if (jjtc000) { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0));
if (((ASTBlock) node).containsComment()) { extras.add("contains comment");
private ASTIfStatement findIfStatement(ASTBlock enclosingBlock, Node node) { ASTIfStatement ifStatement = node.getFirstParentOfType(ASTIfStatement.class); List<ASTIfStatement> allIfStatements = enclosingBlock.findDescendantsOfType(ASTIfStatement.class); if (ifStatement != null && allIfStatements.contains(ifStatement)) { return ifStatement; } return null; }
for (int i = 0; i < block.jjtGetNumChildren(); i++) { final Node statement = block.jjtGetChild(i);
if (block.jjtGetNumChildren() != 1 || block.findDescendantsOfType(ASTStatement.class).size() != 1) { return super.visit(node, data); Node statement = block.jjtGetChild(0).jjtGetChild(0); if (statement.jjtGetChild(0).jjtGetNumChildren() == 0) { return data; // skips empty return statements
@Override public Object visit(ASTBlock node, Object data) { // top-level blocks for methods should have the same scope as parameters, just skip them // same applies to catch statements defining exceptions + the catch block, and for-blocks if (node.jjtGetParent() instanceof ASTMethodDeclaration || node.jjtGetParent() instanceof ASTConstructorDeclaration || node.jjtGetParent() instanceof ASTLambdaExpression || node.jjtGetParent() instanceof ASTCatchStatement || node.jjtGetParent() instanceof ASTForStatement) { super.visit(node, null); } else { createLocalScope(node); cont(node); } return data; }
if (cStatement != null) { ASTBlock block = (ASTBlock) cStatement.jjtGetChild(1); if (block.jjtGetNumChildren() != 0) { continue;
continue; List<Node> blockNodes = blockNode.findChildNodesWithXPath(CHILD_XPATH);
private void checkForExtend(ASTClassOrInterfaceDeclaration node, Object data) { /* * The super.toString method should be called in front of the whole implementation * if the current class extends another POJO class * -> this part not checked */ ASTExtendsList extendsList = node.getFirstChildOfType(ASTExtendsList.class); if (extendsList == null) { return; } String baseName = extendsList.getFirstChildOfType(ASTClassOrInterfaceType.class).getImage(); if (!PojoUtils.isPojo(baseName)) { return; } try { // toString() definition ASTMethodDeclaration toStringMethod = (ASTMethodDeclaration)node.findChildNodesWithXPath(XPATH).get(0); ASTBlock block = toStringMethod.getBlock(); if (block.hasDescendantMatchingXPath(TOSTRING_XPATH)) { addViolationWithMessage(data, block, MESSAGE_KEY_PREFIX + ".usesuper"); } } catch (JaxenException e) { throw new RuntimeException("XPath expression " + XPATH + " failed: " + e.getLocalizedMessage(), e); } }
if (block.jjtGetNumChildren() != 1 || block.findDescendantsOfType(ASTStatement.class).size() != 1) { return super.visit(node, data); Node statement = block.jjtGetChild(0).jjtGetChild(0); if (statement.jjtGetChild(0).jjtGetNumChildren() == 0) { return data; // skips empty return statements
for (int i = 0; i < block.jjtGetNumChildren(); i++) { final Node statement = block.jjtGetChild(i);
@Override public Object visit(ASTBlock node, Object data) { // top-level blocks for methods should have the same scope as parameters, just skip them // same applies to catch statements defining exceptions + the catch block, and for-blocks if (node.jjtGetParent() instanceof ASTMethodDeclaration || node.jjtGetParent() instanceof ASTConstructorDeclaration || node.jjtGetParent() instanceof ASTLambdaExpression || node.jjtGetParent() instanceof ASTCatchStatement || node.jjtGetParent() instanceof ASTForStatement) { super.visit(node, null); } else { createLocalScope(node); cont(node); } return data; }
if (cStatement != null) { ASTBlock block = (ASTBlock) cStatement.jjtGetChild(1); if (block.jjtGetNumChildren() != 0) { continue;
continue; List<Node> blockNodes = blockNode.findChildNodesWithXPath(CHILD_XPATH);
final public void Block() throws ParseException { ASTBlock jjtn000 = new ASTBlock(this, JJTBLOCK); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1));Token t; try { jj_consume_token(LBRACE); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.jjtSetLastToken(getToken(0)); if (isPrecededByComment(t)) { jjtn000.setContainsComment(); } } catch (Throwable jjte000) { if (jjtc000) { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0));
.getFirstChildOfType(ASTBlock.class); List<ASTVariableDeclarator> variableDeclarators = block.findDescendantsOfType(ASTVariableDeclarator.class); for (ASTVariableDeclarator declarator : variableDeclarators) { ASTVariableDeclaratorId variableDeclaratorId = declarator List<ASTAssignmentOperator> assignmentStmts = block.findDescendantsOfType(ASTAssignmentOperator.class); for (ASTAssignmentOperator stmt : assignmentStmts) {
if (((ASTBlock) node).containsComment()) { extras.add("contains comment");
List<ASTName> names = f.findDescendantsOfType(ASTName.class); for (ASTName oName : names) { String name = oName.getImage(); f.findDescendantsOfType(ASTStatementExpression.class, exprs, true); for (ASTStatementExpression stmt : exprs) { ASTPrimaryExpression expr = stmt.getFirstChildOfType(ASTPrimaryExpression.class);
private ASTIfStatement findIfStatement(ASTBlock enclosingBlock, Node node) { ASTIfStatement ifStatement = node.getFirstParentOfType(ASTIfStatement.class); List<ASTIfStatement> allIfStatements = enclosingBlock.findDescendantsOfType(ASTIfStatement.class); if (ifStatement != null && allIfStatements.contains(ifStatement)) { return ifStatement; } return null; }
.getFirstChildOfType(ASTBlock.class); List<ASTVariableDeclarator> variableDeclarators = block.findDescendantsOfType(ASTVariableDeclarator.class); for (ASTVariableDeclarator declarator : variableDeclarators) { ASTVariableDeclaratorId variableDeclaratorId = declarator List<ASTAssignmentOperator> assignmentStmts = block.findDescendantsOfType(ASTAssignmentOperator.class); for (ASTAssignmentOperator stmt : assignmentStmts) {