/** Attempts to determine if the method is a setter. */ private static boolean isSetter(ASTMethodDeclaration node, Map<String, String> fieldNames) { if (node.getFirstDescendantOfType(ASTFormalParameters.class).getParameterCount() != 1 || !node.getFirstDescendantOfType(ASTResultType.class).isVoid()) { return false; } if (node.getName().startsWith("set")) { return containsIgnoreCase(fieldNames.keySet(), node.getName().substring(3)); } return fieldNames.containsKey(node.getName()); }
/** Attempts to determine if the method is a getter. */ private static boolean isGetter(ASTMethodDeclaration node, Map<String, String> fieldNames) { if (node.getFirstDescendantOfType(ASTFormalParameters.class).getParameterCount() != 0 || node.getFirstDescendantOfType(ASTResultType.class).isVoid()) { return false; } if (node.getName().startsWith("get")) { return containsIgnoreCase(fieldNames.keySet(), node.getName().substring(3)); } else if (node.getName().startsWith("is")) { return containsIgnoreCase(fieldNames.keySet(), node.getName().substring(2)); } return fieldNames.containsKey(node.getName()); }
private boolean isSerializationMethod(ASTMethodDeclaration node) { ASTMethodDeclarator declarator = node.getFirstDescendantOfType(ASTMethodDeclarator.class); List<ASTFormalParameter> parameters = declarator.findDescendantsOfType(ASTFormalParameter.class); if (node.isPrivate() && "readObject".equals(node.getMethodName()) && parameters.size() == 1 && throwsOneException(node, InvalidObjectException.class)) { ASTType type = parameters.get(0).getTypeNode(); if (type.getType() == ObjectInputStream.class || ObjectInputStream.class.getSimpleName().equals(type.getTypeImage()) || ObjectInputStream.class.getName().equals(type.getTypeImage())) { return true; } } return false; }
@Override public Object visit(ASTMethodDeclaration node, Object data) { final ASTFormalParameters params = node.getFirstDescendantOfType(ASTFormalParameters.class); ASTFormalParameter[] arrs = getArrays(params); checkAll(data, arrs, node.findDescendantsOfType(ASTBlockStatement.class)); return data; }
@Override public Object visit(ASTMethodDeclaration node, Object data) { String opname = getOperationName(node.getMethodName(), node.getFirstDescendantOfType(ASTFormalParameters.class)); node.setQualifiedName(contextOperationQName(opname, false)); return super.visit(node, data); }
/** Attempts to determine if the method is a setter. */ private static boolean isSetter(ASTMethodDeclaration node, Map<String, String> fieldNames) { if (node.getFirstDescendantOfType(ASTFormalParameters.class).getParameterCount() != 1 || !node.getFirstDescendantOfType(ASTResultType.class).isVoid()) { return false; } if (node.getName().startsWith("set")) { return containsIgnoreCase(fieldNames.keySet(), node.getName().substring(3)); } return fieldNames.containsKey(node.getName()); }
/** Attempts to determine if the method is a getter. */ private static boolean isGetter(ASTMethodDeclaration node, Map<String, String> fieldNames) { if (node.getFirstDescendantOfType(ASTFormalParameters.class).getParameterCount() != 0 || node.getFirstDescendantOfType(ASTResultType.class).isVoid()) { return false; } if (node.getName().startsWith("get")) { return containsIgnoreCase(fieldNames.keySet(), node.getName().substring(3)); } else if (node.getName().startsWith("is")) { return containsIgnoreCase(fieldNames.keySet(), node.getName().substring(2)); } return fieldNames.containsKey(node.getName()); }
@Override public Object visit(ASTMethodDeclaration node, Object data) { final ASTFormalParameters params = node.getFirstDescendantOfType(ASTFormalParameters.class); ASTFormalParameter[] arrs = getArrays(params); checkAll(data, arrs, node.findDescendantsOfType(ASTBlockStatement.class)); return data; }
private boolean isSerializationMethod(ASTMethodDeclaration node) { ASTMethodDeclarator declarator = node.getFirstDescendantOfType(ASTMethodDeclarator.class); List<ASTFormalParameter> parameters = declarator.findDescendantsOfType(ASTFormalParameter.class); if (node.isPrivate() && "readObject".equals(node.getMethodName()) && parameters.size() == 1 && throwsOneException(node, InvalidObjectException.class)) { ASTType type = parameters.get(0).getTypeNode(); if (type.getType() == ObjectInputStream.class || ObjectInputStream.class.getSimpleName().equals(type.getTypeImage()) || ObjectInputStream.class.getName().equals(type.getTypeImage())) { return true; } } return false; }
private boolean isInNewThreadMethod(ASTAllocationExpression node) { ASTMethodDeclaration methodDeclaration = node.getFirstParentOfType(ASTMethodDeclaration.class); if (methodDeclaration == null) { return false; } if (!returnThread(methodDeclaration)) { return false; } if (!METHOD_NEW_THREAD.equals(methodDeclaration.getMethodName())) { return false; } List<ASTFormalParameter> parameters = methodDeclaration.getFirstDescendantOfType(ASTFormalParameters.class) .findChildrenOfType(ASTFormalParameter.class); return parameters.size() == 1 && parameters.get(0).getFirstChildOfType(ASTType.class).getType() == Runnable.class; }
@Override public Object visit(ASTMethodDeclaration node, Object data) { String opname = getOperationName(node.getMethodName(), node.getFirstDescendantOfType(ASTFormalParameters.class)); node.setQualifiedName(contextOperationQName(opname, false)); return super.visit(node, data); }