use of org.eclipse.ceylon.langtools.tools.javac.code.Symbol.MethodSymbol in project ceylon by eclipse.
the class JavacTrees method searchMethod.
/**
* @see com.sun.tools.javadoc.ClassDocImpl#searchMethod
*/
private MethodSymbol searchMethod(ClassSymbol tsym, Name methodName, List<Type> paramTypes, Set<ClassSymbol> searched) {
// do not match constructors
if (methodName == names.init)
return null;
if (searched.contains(tsym))
return null;
searched.add(tsym);
// search current class
org.eclipse.ceylon.langtools.tools.javac.code.Scope.Entry e = tsym.members().lookup(methodName);
if (paramTypes == null) {
// If no parameters specified, we are allowed to return
// any method with a matching name. In practice, the old
// code returned the first method, which is now the last!
// In order to provide textually identical results, we
// attempt to emulate the old behavior.
MethodSymbol lastFound = null;
for (; e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.MTH) {
if (e.sym.name == methodName) {
lastFound = (MethodSymbol) e.sym;
}
}
}
if (lastFound != null) {
return lastFound;
}
} else {
for (; e.scope != null; e = e.next()) {
if (e.sym != null && e.sym.kind == Kinds.MTH) {
if (hasParameterTypes((MethodSymbol) e.sym, paramTypes)) {
return (MethodSymbol) e.sym;
}
}
}
}
// ### If we found a MethodSymbol above, but which did not pass
// ### the modifier filter, we should return failure here!
// search superclass
Type superclass = tsym.getSuperclass();
if (superclass.tsym != null) {
MethodSymbol msym = searchMethod((ClassSymbol) superclass.tsym, methodName, paramTypes, searched);
if (msym != null) {
return msym;
}
}
// search interfaces
List<Type> intfs = tsym.getInterfaces();
for (List<Type> l = intfs; l.nonEmpty(); l = l.tail) {
Type intf = l.head;
if (intf.isErroneous())
continue;
MethodSymbol msym = searchMethod((ClassSymbol) intf.tsym, methodName, paramTypes, searched);
if (msym != null) {
return msym;
}
}
// search enclosing class
ClassSymbol encl = tsym.owner.enclClass();
if (encl != null) {
MethodSymbol msym = searchMethod(encl, methodName, paramTypes, searched);
if (msym != null) {
return msym;
}
}
return null;
}
Aggregations