* the member (field/method) then grabbing the annotations.
*
* @return an array of (eclipse form) annotations on this member
*/
private Annotation[] getEclipseAnnotations() {
TypeDeclaration tDecl = getTypeDeclaration();
// two possible reasons for it being null:
// 1. code is broken
// 2. this resolvedmember is an EclipseResolvedMember created up front to represent a privileged'd accessed member
if (tDecl != null) {
if (realBinding instanceof MethodBinding) {
MethodBinding methodBinding = (MethodBinding) realBinding;
AbstractMethodDeclaration methodDecl = tDecl.declarationOf(methodBinding);
if (methodDecl == null) {
// pr284862
// bindings may have been trashed by InterTypeMemberFinder.addInterTypeMethod() - and so we need to take
// a better look. Really this EclipseResolvedMember is broken...
// Grab the set of bindings with matching selector
MethodBinding[] mb = ((MethodBinding) realBinding).declaringClass.getMethods(methodBinding.selector);
if (mb != null) {
for (int m = 0, max = mb.length; m < max; m++) {
MethodBinding candidate = mb[m];
if (candidate instanceof InterTypeMethodBinding) {
if (InterTypeMemberFinder.matches(mb[m], methodBinding)) {
InterTypeMethodBinding intertypeMethodBinding = (InterTypeMethodBinding) candidate;
Annotation[] annos = intertypeMethodBinding.sourceMethod.annotations;
return annos;
}
}
}
}
return null; // give up! kind of assuming here that the code has other problems (and they will be reported)
}
return methodDecl.annotations;
} else if (realBinding instanceof FieldBinding) {
FieldDeclaration fieldDecl = tDecl.declarationOf((FieldBinding) realBinding);
return fieldDecl.annotations;
}
}
return null;
}