private int getAmountOfExpectedArguments(final String variableName, final List<ASTVariableDeclarator> variables) { for (final ASTVariableDeclarator astVariableDeclarator : variables) { if (astVariableDeclarator.getFirstChildOfType(ASTVariableDeclaratorId.class).getImage() .equals(variableName)) { ASTVariableInitializer variableInitializer = astVariableDeclarator .getFirstDescendantOfType(ASTVariableInitializer.class); ASTExpression expression = null; if (variableInitializer != null) { expression = variableInitializer.getFirstChildOfType(ASTExpression.class); } if (expression != null) { return countPlaceholders(expression); } } } return 0; }
@Override public Object visit(ASTLocalVariableDeclaration node, Object data) { ASTClassOrInterfaceType type = null; if (!node.isTypeInferred()) { type = node.getFirstChildOfType(ASTType.class).getFirstDescendantOfType(ASTClassOrInterfaceType.class); } if (type != null && (type.getType() != null && "java.sql.ResultSet".equals(type.getType().getName()) || "ResultSet".equals(type.getImage()))) { ASTVariableDeclarator declarator = node.getFirstChildOfType(ASTVariableDeclarator.class); if (declarator != null) { ASTName name = declarator.getFirstDescendantOfType(ASTName.class); if (type.getType() != null || name != null && name.getImage().endsWith("executeQuery")) { ASTVariableDeclaratorId id = declarator.getFirstChildOfType(ASTVariableDeclaratorId.class); resultSetVariables.put(id.getImage(), node); } } } return super.visit(node, data); }
.getFirstDescendantOfType(ASTAllocationExpression.class) != null; boolean iterator = isIterator() || isFactory(declarator); boolean forLoop = isForLoop(declarator);
private boolean checkThreadLocalWithInitalValue(ASTFieldDeclaration fieldDeclaration) { ASTVariableDeclarator variableDeclarator = fieldDeclaration.getFirstDescendantOfType( ASTVariableDeclarator.class); if (variableDeclarator == null) { return false; } ASTMethodDeclarator initialValueMethod = variableDeclarator.getFirstDescendantOfType(ASTMethodDeclarator.class); if (initialValueMethod != null && METHOD_INITIAL_VALUE.equals(initialValueMethod.getImage())) { return true; } ASTName name = variableDeclarator.getFirstDescendantOfType(ASTName.class); return name != null && WITH_INITIAL.equals(name.getImage()); }
private int getAmountOfExpectedArguments(final String variableName, final List<ASTVariableDeclarator> variables) { for (final ASTVariableDeclarator astVariableDeclarator : variables) { if (astVariableDeclarator.getFirstChildOfType(ASTVariableDeclaratorId.class).getImage() .equals(variableName)) { ASTVariableInitializer variableInitializer = astVariableDeclarator .getFirstDescendantOfType(ASTVariableInitializer.class); ASTExpression expression = null; if (variableInitializer != null) { expression = variableInitializer.getFirstChildOfType(ASTExpression.class); } if (expression != null) { return countPlaceholders(expression); } } } return 0; }
@Override public Object visit(ASTLocalVariableDeclaration node, Object data) { ASTClassOrInterfaceType type = null; if (!node.isTypeInferred()) { type = node.getFirstChildOfType(ASTType.class).getFirstDescendantOfType(ASTClassOrInterfaceType.class); } if (type != null && (type.getType() != null && "java.sql.ResultSet".equals(type.getType().getName()) || "ResultSet".equals(type.getImage()))) { ASTVariableDeclarator declarator = node.getFirstChildOfType(ASTVariableDeclarator.class); if (declarator != null) { ASTName name = declarator.getFirstDescendantOfType(ASTName.class); if (type.getType() != null || name != null && name.getImage().endsWith("executeQuery")) { ASTVariableDeclaratorId id = declarator.getFirstChildOfType(ASTVariableDeclaratorId.class); resultSetVariables.put(id.getImage(), node); } } } return super.visit(node, data); }
.getFirstDescendantOfType(ASTAllocationExpression.class) != null; boolean iterator = isIterator() || isFactory(declarator); boolean forLoop = isForLoop(declarator);