use of com.jopdesign.common.graphutils.ClassHierarchyTraverser in project jop by jop-devel.
the class MethodInfo method getOverriders.
/**
* Find all methods which override/implement this method.
* Instance method are overridden by other instance methods and hidden by static methods.
*
* @param checkAccess if false, find methods with the same signature in subclasses even if they
* do not override this method (i.e. private or static methods).
* @return a list of all overriding methods.
*/
public Collection<MethodInfo> getOverriders(final boolean checkAccess) {
final List<MethodInfo> overriders = new LinkedList<MethodInfo>();
if (checkAccess && (isPrivate() || isStatic())) {
return overriders;
}
ClassVisitor visitor = new ClassVisitor() {
public boolean visitClass(ClassInfo classInfo) {
MethodInfo overrider = classInfo.getMethodInfo(getMethodSignature());
if (overrider != null) {
if (overrider.isPrivate()) {
// found an overriding method which is private .. this is interesting..
logger.error("Found private method " + overrider.getMethodSignature() + " in " + classInfo.getClassName() + " overriding non-private method in " + getClassInfo().getClassName());
}
// signature, but is in a different package, it does NOT override this method.
if (!checkAccess || overrider.overrides(MethodInfo.this, false)) {
overriders.add(overrider);
}
}
return true;
}
public void finishClass(ClassInfo classInfo) {
}
};
new ClassHierarchyTraverser(visitor).traverseDown(getClassInfo());
return overriders;
}
use of com.jopdesign.common.graphutils.ClassHierarchyTraverser in project jop by jop-devel.
the class ClassInfo method finishRemoveFromHierarchy.
protected void finishRemoveFromHierarchy() {
// all extensions and inner classes of this class will now be incomplete
if (fullyKnown == Ternary.TRUE) {
ClassVisitor visitor = new ClassVisitor() {
@SuppressWarnings({ "AccessingNonPublicFieldOfAnotherObject" })
public boolean visitClass(ClassInfo classInfo) {
classInfo.fullyKnown = Ternary.FALSE;
return true;
}
public void finishClass(ClassInfo classInfo) {
}
};
ClassHierarchyTraverser traverser = new ClassHierarchyTraverser(visitor);
traverser.setVisitSubclasses(true, false);
// we do not support nested classes without enclosing class, so no need to visit them
// as they are removed too
traverser.setVisitInnerClasses(false);
traverser.traverseDown(this);
}
}
Aggregations