add method getOverriden()

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3395 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2009-03-31 19:16:05 +00:00
parent 38167c0abd
commit b6b5f56ac2
1 changed files with 22 additions and 0 deletions

View File

@ -41,4 +41,26 @@ public class ClassHierarchyUtil {
}
}
/**
* Return the method that m overrides, or null if none
*/
public static IMethod getOverriden(IMethod m) {
try {
IClass c = m.getDeclaringClass();
IClass parent = c.getSuperclass();
if (parent == null) {
return null;
} else {
MethodReference ref = MethodReference.findOrCreate(parent.getReference(), m.getSelector());
IMethod m2 = m.getClassHierarchy().resolveMethod(ref);
if (m2 != null && !m2.equals(m)) {
return m2;
}
return null;
}
} catch (ClassHierarchyException e) {
return null;
}
}
}