try {
methods = type.getMethods();
for (int i = 0; i < methods.length; i++) {
if (methods[i].getElementName().equals(name)
&& methods[i].getParameterTypes().length == parameterTypeNames.length) {
IMethod method = methods[i];
if (uniqueKey != null) {
ResolvedSourceMethod resolvedMethod = new ResolvedSourceMethod(
(JavaElement)method.getParent(),
method.getElementName(),
method.getParameterTypes(),
new String(uniqueKey));
resolvedMethod.occurrenceCount = method.getOccurrenceCount();
method = resolvedMethod;
}
addElement(method);
}
}
} catch (JavaModelException e) {
return;
}
// if no matches, nothing to report
if (this.elementIndex == -1) {
// no match was actually found, but a method was originally given -> default constructor
addElement(type);
if(SelectionEngine.DEBUG){
System.out.print("SELECTION - accept type("); //$NON-NLS-1$
System.out.print(type.toString());
System.out.println(")"); //$NON-NLS-1$
}
return;
}
// if there is only one match, we've got it
if (this.elementIndex == 0) {
if(SelectionEngine.DEBUG){
System.out.print("SELECTION - accept method("); //$NON-NLS-1$
System.out.print(this.elements[0].toString());
System.out.println(")"); //$NON-NLS-1$
}
return;
}
// more than one match - must match simple parameter types
IJavaElement[] matches = this.elements;
int matchesIndex = this.elementIndex;
this.elements = JavaElement.NO_ELEMENTS;
this.elementIndex = -1;
for (int i = 0; i <= matchesIndex; i++) {
IMethod method= (IMethod)matches[i];
String[] signatures = method.getParameterTypes();
boolean match= true;
for (int p = 0; p < signatures.length; p++) {
String simpleName= Signature.getSimpleName(Signature.toString(Signature.getTypeErasure(signatures[p])));
char[] simpleParameterName = CharOperation.lastSegment(parameterTypeNames[p], '.');
if (!simpleName.equals(new String(simpleParameterName))) {
match = false;
break;
}
}
if (match && !areTypeParametersCompatible(method, typeParameterNames, typeParameterBoundNames)) {
match = false;
}
if (match) {
addElement(method);
if(SelectionEngine.DEBUG){
System.out.print("SELECTION - accept method("); //$NON-NLS-1$
System.out.print(method.toString());
System.out.println(")"); //$NON-NLS-1$
}
}
}