Simplify varargs detection

- Make use of our Java knowledge when analyzing Java code
This commit is contained in:
Juan Martín Sotuyo Dodero
2016-10-13 17:47:27 -03:00
parent 382699b766
commit d8344b0672

View File

@ -22,13 +22,13 @@ public class MethodNameDeclaration extends AbstractNameDeclaration {
public boolean isVarargs() {
ASTFormalParameters params = (ASTFormalParameters) node.jjtGetChild(0);
for (int i = 0; i < ((ASTMethodDeclarator) node).getParameterCount(); i++) {
ASTFormalParameter p = (ASTFormalParameter) params.jjtGetChild(i);
if (p.isVarargs()) {
return true;
}
if (params.getParameterCount() == 0) {
return false;
}
return false;
// If it's a varargs, it HAS to be the last parameter
ASTFormalParameter p = (ASTFormalParameter) params.jjtGetChild(params.getParameterCount() - 1);
return p.isVarargs();
}
public ASTMethodDeclarator getMethodNameDeclaratorNode() {