public boolean isVarargs() { ASTVariableDeclaratorId astVariableDeclaratorId = (ASTVariableDeclaratorId) node; ASTFormalParameter parameter = astVariableDeclaratorId.getFirstParentOfType(ASTFormalParameter.class); return parameter != null && parameter.isVarargs(); }
private boolean indexStartsAtZero(VariableNameDeclaration index) { ASTVariableDeclaratorId name = (ASTVariableDeclaratorId) index.getNode(); ASTVariableDeclarator declarator = name.getFirstParentOfType(ASTVariableDeclarator.class); if (declarator == null) { return false; } try { List<Node> zeroLiteral = declarator.findChildNodesWithXPath( "./VariableInitializer/Expression/PrimaryExpression/PrimaryPrefix/Literal[@Image='0' and " + "@StringLiteral='false']"); if (!zeroLiteral.isEmpty()) { return true; } } catch (JaxenException je) { throw new RuntimeException(je); } return false; }
ASTBlockStatement parentBlock = id.getFirstParentOfType(ASTBlockStatement.class);
public boolean isVarargs() { ASTVariableDeclaratorId astVariableDeclaratorId = (ASTVariableDeclaratorId) node; ASTFormalParameter parameter = astVariableDeclaratorId.getFirstParentOfType(ASTFormalParameter.class); return parameter != null && parameter.isVarargs(); }
private boolean indexStartsAtZero(VariableNameDeclaration index) { ASTVariableDeclaratorId name = (ASTVariableDeclaratorId) index.getNode(); ASTVariableDeclarator declarator = name.getFirstParentOfType(ASTVariableDeclarator.class); if (declarator == null) { return false; } try { List<Node> zeroLiteral = declarator.findChildNodesWithXPath( "./VariableInitializer/Expression/PrimaryExpression/PrimaryPrefix/Literal[@Image='0' and " + "@StringLiteral='false']"); if (!zeroLiteral.isEmpty()) { return true; } } catch (JaxenException je) { throw new RuntimeException(je); } return false; }
@Override public Object visit(final ASTVariableDeclaratorId node, Object data) { // Constant named does not apply to this rule ASTTypeDeclaration typeDeclaration = node.getFirstParentOfType(ASTTypeDeclaration.class); Node jjtGetChild = typeDeclaration.jjtGetChild(0); if (jjtGetChild instanceof ASTAnnotationTypeDeclaration) { return super.visit(node, data); } ASTFieldDeclaration astFieldDeclaration = node.getFirstParentOfType(ASTFieldDeclaration.class); boolean isNotCheck = astFieldDeclaration != null && (astFieldDeclaration.isFinal() || astFieldDeclaration .isStatic()); if (isNotCheck) { return super.visit(node, data); } // variable naming violate lowerCamelCase if (!(pattern.matcher(node.getImage()).matches())) { ViolationUtils.addViolationWithPrecisePosition(this, node, data, I18nResources.getMessage(MESSAGE_KEY_PREFIX + ".variable", node.getImage())); } return super.visit(node, data); }
.getFirstParentOfType(ASTLocalVariableDeclaration.class);
ASTBlock blockNode = variableName.getFirstParentOfType(ASTBlock.class); if (blockNode == null || valName == null) { continue;
ASTBlockStatement parentBlock = id.getFirstParentOfType(ASTBlockStatement.class);