@Override public List<ASTAnnotation> getDeclaredAnnotations() { return this.jjtGetParent().findChildrenOfType(ASTAnnotation.class); }
/** * Checks whether the given node contains a qualified name, consisting of * one ASTPrimaryPrefix and one or more ASTPrimarySuffix nodes. * * @param node * the node * @return <code>true</code> if it is a qualified name */ private boolean isPartOfQualifiedName(Node node) { return node.jjtGetChild(0) instanceof ASTPrimaryPrefix && !node.findChildrenOfType(ASTPrimarySuffix.class).isEmpty(); } }
private Object checkVariableDeclarators(List<String> prefixes, List<String> suffixes, Node root, boolean isStatic, boolean isFinal, Object data) { for (ASTVariableDeclarator variableDeclarator : root.findChildrenOfType(ASTVariableDeclarator.class)) { for (ASTVariableDeclaratorId variableDeclaratorId : variableDeclarator .findChildrenOfType(ASTVariableDeclaratorId.class)) { checkVariableDeclaratorId(prefixes, suffixes, isStatic, isFinal, variableDeclaratorId, data); } } return data; }
@Override public Object visit(final ASTElseIfStatement node, final Object data) { // verify that this elseif doesn't have any siblings if (node.jjtGetParent().findChildrenOfType(ASTElseIfStatement.class).size() == 1) { handleIfElseIf(node, data); } return super.visit(node, data); }
boolean result = false; Node parent = node.jjtGetParent(); List<ASTAnnotation> annotations = parent.findChildrenOfType(ASTAnnotation.class); for (ASTAnnotation annotation : annotations) { ASTName name = annotation.getFirstDescendantOfType(ASTName.class);
@Override public Object visit(ASTPrimaryPrefix pp, Object ctx) { List<ASTPrimarySuffix> primarySuffixes = pp.jjtGetParent().findChildrenOfType(ASTPrimarySuffix.class); ASTPrimarySuffix firstSuffix = null; if (!primarySuffixes.isEmpty()) { firstSuffix = primarySuffixes.get(0); } if (firstSuffix == null || firstSuffix.getImage() == null || !firstSuffix.getImage().endsWith("finalize")) { return super.visit(pp, ctx); } if (!checkForViolation(pp)) { return super.visit(pp, ctx); } addViolation(ctx, pp); return super.visit(pp, ctx); }
List<ASTStatement> allStatements = node.jjtGetParent().findChildrenOfType(ASTStatement.class); if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("ElseClause has " + allStatements.size() + " Statements ");
@Override public Object visit(ASTMethodDeclaration methodDeclaration, Object o) { if (junitImported && isAllowedMethod(methodDeclaration)) { return super.visit(methodDeclaration, o); } if (methodDeclaration.getMethodName().startsWith("test")) { return super.visit(methodDeclaration, o); } // Ignore overridden methods, the issue should be marked on the method definition final List<ASTAnnotation> methodAnnotations = methodDeclaration.jjtGetParent().findChildrenOfType(ASTAnnotation.class); for (final ASTAnnotation annotation : methodAnnotations) { final ASTName annotationName = annotation.getFirstDescendantOfType(ASTName.class); if (annotationName.hasImageEqualTo("Override") || annotationName.hasImageEqualTo("java.lang.Override")) { return super.visit(methodDeclaration, o); } } checkExceptions(methodDeclaration, o); return super.visit(methodDeclaration, o); }
List<ASTBlockStatement> blocks = parentBlock.jjtGetParent().findChildrenOfType(ASTBlockStatement.class); int parentBlockIndex = blocks.indexOf(parentBlock); int tryBlockIndex = blocks.indexOf(tryBlock);
@Override public Object visit(ASTCatchStatement catchStmt, Object data) { String target = catchStmt.jjtGetChild(0).findChildrenOfType(ASTVariableDeclaratorId.class).get(0).getImage();
/** * Checks whether the given node contains a qualified name, consisting of * one ASTPrimaryPrefix and one or more ASTPrimarySuffix nodes. * * @param node * the node * @return <code>true</code> if it is a qualified name */ private boolean isPartOfQualifiedName(Node node) { return node.jjtGetChild(0) instanceof ASTPrimaryPrefix && !node.findChildrenOfType(ASTPrimarySuffix.class).isEmpty(); } }
@Override public List<ASTAnnotation> getDeclaredAnnotations() { return this.jjtGetParent().findChildrenOfType(ASTAnnotation.class); }
private Object checkVariableDeclarators(List<String> prefixes, List<String> suffixes, Node root, boolean isStatic, boolean isFinal, Object data) { for (ASTVariableDeclarator variableDeclarator : root.findChildrenOfType(ASTVariableDeclarator.class)) { for (ASTVariableDeclaratorId variableDeclaratorId : variableDeclarator .findChildrenOfType(ASTVariableDeclaratorId.class)) { checkVariableDeclaratorId(prefixes, suffixes, isStatic, isFinal, variableDeclaratorId, data); } } return data; }
boolean result = false; Node parent = node.jjtGetParent(); List<ASTAnnotation> annotations = parent.findChildrenOfType(ASTAnnotation.class); for (ASTAnnotation annotation : annotations) { ASTName name = annotation.getFirstDescendantOfType(ASTName.class);
@Override public Object visit(ASTPrimaryPrefix pp, Object ctx) { List<ASTPrimarySuffix> primarySuffixes = pp.jjtGetParent().findChildrenOfType(ASTPrimarySuffix.class); ASTPrimarySuffix firstSuffix = null; if (!primarySuffixes.isEmpty()) { firstSuffix = primarySuffixes.get(0); } if (firstSuffix == null || firstSuffix.getImage() == null || !firstSuffix.getImage().endsWith("finalize")) { return super.visit(pp, ctx); } if (!checkForViolation(pp)) { return super.visit(pp, ctx); } addViolation(ctx, pp); return super.visit(pp, ctx); }
@Override public Object visit(ASTMethodDeclaration methodDeclaration, Object o) { if (junitImported && isAllowedMethod(methodDeclaration)) { return super.visit(methodDeclaration, o); } if (methodDeclaration.getMethodName().startsWith("test")) { return super.visit(methodDeclaration, o); } // Ignore overridden methods, the issue should be marked on the method definition final List<ASTAnnotation> methodAnnotations = methodDeclaration.jjtGetParent().findChildrenOfType(ASTAnnotation.class); for (final ASTAnnotation annotation : methodAnnotations) { final ASTName annotationName = annotation.getFirstDescendantOfType(ASTName.class); if (annotationName.hasImageEqualTo("Override") || annotationName.hasImageEqualTo("java.lang.Override")) { return super.visit(methodDeclaration, o); } } checkExceptions(methodDeclaration, o); return super.visit(methodDeclaration, o); }
List<ASTBlockStatement> blocks = parentBlock.jjtGetParent().findChildrenOfType(ASTBlockStatement.class); int parentBlockIndex = blocks.indexOf(parentBlock); int tryBlockIndex = blocks.indexOf(tryBlock);
@Override public Object visit(ASTCatchStatement catchStmt, Object data) { String target = catchStmt.jjtGetChild(0).findChildrenOfType(ASTVariableDeclaratorId.class).get(0).getImage();