/** * Returns the declarator ID of this formal parameter. */ public ASTVariableDeclaratorId getVariableDeclaratorId() { return getFirstChildOfType(ASTVariableDeclaratorId.class); }
/** * Returns the type node of this formal parameter. * The type of that node is not necessarily the type * of the parameter itself, see {@link ASTVariableDeclaratorId#getType()}. * * <p>In particular, the type of the returned node * doesn't take into account whether this formal * parameter is varargs or not. */ public ASTType getTypeNode() { return getFirstChildOfType(ASTType.class); }
private static List<String> getMethodDeclaratorParameterTypes(Node methodOrConstructorDeclarator) { List<ASTFormalParameter> parameters = methodOrConstructorDeclarator .findDescendantsOfType(ASTFormalParameter.class); List<String> parameterTypes = new ArrayList<>(); if (parameters != null) { for (ASTFormalParameter p : parameters) { ASTType type = p.getFirstChildOfType(ASTType.class); if (type.jjtGetChild(0) instanceof ASTPrimitiveType) { parameterTypes.add(type.jjtGetChild(0).getImage()); } else if (type.jjtGetChild(0) instanceof ASTReferenceType) { parameterTypes.add("ref"); } else { parameterTypes.add("<unkown>"); } } } return parameterTypes; }
/** * Returns the declarator ID of this formal parameter. */ public ASTVariableDeclaratorId getVariableDeclaratorId() { return getFirstChildOfType(ASTVariableDeclaratorId.class); }
/** * Returns the type node of this formal parameter. * The type of that node is not necessarily the type * of the parameter itself, see {@link ASTVariableDeclaratorId#getType()}. * * <p>In particular, the type of the returned node * doesn't take into account whether this formal * parameter is varargs or not. */ public ASTType getTypeNode() { return getFirstChildOfType(ASTType.class); }
private static List<String> getMethodDeclaratorParameterTypes(Node methodOrConstructorDeclarator) { List<ASTFormalParameter> parameters = methodOrConstructorDeclarator .findDescendantsOfType(ASTFormalParameter.class); List<String> parameterTypes = new ArrayList<>(); if (parameters != null) { for (ASTFormalParameter p : parameters) { ASTType type = p.getFirstChildOfType(ASTType.class); if (type.jjtGetChild(0) instanceof ASTPrimitiveType) { parameterTypes.add(type.jjtGetChild(0).getImage()); } else if (type.jjtGetChild(0) instanceof ASTReferenceType) { parameterTypes.add("ref"); } else { parameterTypes.add("<unkown>"); } } } return parameterTypes; }
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; }