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; }
private Entry<VariableNameDeclaration, List<NameOccurrence>> getIterableDeclOfIteratorLoop(VariableNameDeclaration indexDecl, Scope scope) { Node initializer = indexDecl.getNode().getFirstParentOfType(ASTVariableDeclarator.class) .getFirstChildOfType(ASTVariableInitializer.class); if (initializer == null) { return null; } ASTName nameNode = initializer.getFirstDescendantOfType(ASTName.class); if (nameNode == null) { // TODO : This can happen if we are calling a local / statically imported method that returns the iterable - currently unhandled return null; } String name = nameNode.getImage(); int dotIndex = name.indexOf('.'); if (dotIndex > 0) { name = name.substring(0, dotIndex); } return findDeclaration(name, scope); }
@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); }
for (ASTVariableDeclarator declarator : variableDeclarators) { ASTVariableDeclaratorId variableDeclaratorId = declarator .getFirstChildOfType(ASTVariableDeclaratorId.class);
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; }
private Entry<VariableNameDeclaration, List<NameOccurrence>> getIterableDeclOfIteratorLoop(VariableNameDeclaration indexDecl, Scope scope) { Node initializer = indexDecl.getNode().getFirstParentOfType(ASTVariableDeclarator.class) .getFirstChildOfType(ASTVariableInitializer.class); if (initializer == null) { return null; } ASTName nameNode = initializer.getFirstDescendantOfType(ASTName.class); if (nameNode == null) { // TODO : This can happen if we are calling a local / statically imported method that returns the iterable - currently unhandled return null; } String name = nameNode.getImage(); int dotIndex = name.indexOf('.'); if (dotIndex > 0) { name = name.substring(0, dotIndex); } return findDeclaration(name, scope); }
@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); }
if (variableDeclarator.getType() == SimpleDateFormat.class) { ASTVariableDeclaratorId variableDeclaratorId = variableDeclarator.getFirstChildOfType(ASTVariableDeclaratorId.class); localSimpleDateFormatNames.add(variableDeclaratorId.getImage()); return;
declarator.getFirstChildOfType(ASTVariableDeclaratorId.class);
for (ASTVariableDeclarator declarator : variableDeclarators) { ASTVariableDeclaratorId variableDeclaratorId = declarator .getFirstChildOfType(ASTVariableDeclaratorId.class);