decl.typeParameters = typeParams;
methodDeclaration = decl;
} else {
MethodDeclaration decl = type.isAnnotation() ? new AnnotationMethodDeclaration(this.compilationResult) : new MethodDeclaration(this.compilationResult);
/* convert return type */
TypeReference typeReference = createTypeReference(method.getReturnType());
if (typeReference == null) return null;
decl.returnType = typeReference;
decl.typeParameters = typeParams;
methodDeclaration = decl;
}
methodDeclaration.selector = method.getElementName().toCharArray();
int flags = method.getFlags();
boolean isVarargs = Flags.isVarargs(flags);
methodDeclaration.modifiers = flags & ~Flags.AccVarargs;
/* convert arguments */
String[] argumentTypeNames = method.getParameterTypes();
String[] argumentNames = method.getParameterNames();
int argumentCount = argumentTypeNames == null ? 0 : argumentTypeNames.length;
// Ignore synthetic arguments (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=212224)
int startIndex = (method.isConstructor() && type.isMember() && !Flags.isStatic(type.getFlags())) ? 1 : 0;
argumentCount -= startIndex;
methodDeclaration.arguments = new Argument[argumentCount];
for (int i = 0; i < argumentCount; i++) {
String argumentTypeName = argumentTypeNames[startIndex+i];
TypeReference typeReference = createTypeReference(argumentTypeName);
if (typeReference == null) return null;
if (isVarargs && i == argumentCount-1) {
typeReference.bits |= ASTNode.IsVarArgs;
}
methodDeclaration.arguments[i] = new Argument(
argumentNames[i].toCharArray(),
0,
typeReference,
ClassFileConstants.AccDefault);
// do not care whether was final or not
}
/* convert thrown exceptions */
String[] exceptionTypeNames = method.getExceptionTypes();
int exceptionCount = exceptionTypeNames == null ? 0 : exceptionTypeNames.length;
if(exceptionCount > 0) {
methodDeclaration.thrownExceptions = new TypeReference[exceptionCount];
for (int i = 0; i < exceptionCount; i++) {
TypeReference typeReference = createTypeReference(exceptionTypeNames[i]);
if (typeReference == null) return null;
methodDeclaration.thrownExceptions[i] = typeReference;
}
}
return methodDeclaration;