use of com.jopdesign.common.graphutils.EmptyClassVisitor in project jop by jop-devel.
the class InlineHelper method makePublic.
private void makePublic(ClassMemberInfo member) {
boolean wasPrivate = member.isPrivate();
// If we need to make it public, check if we need to make the class and all enclosing classes public too
ClassInfo cls = member.getClassInfo();
while (cls != null) {
if (!cls.isPublic()) {
cls.setAccessType(AccessType.ACC_PUBLIC);
}
cls = cls.getEnclosingClassInfo();
}
if (wasPrivate && member instanceof MethodInfo) {
// we are done here. if the method was private, there are no conflicting
// methods or we needed to rename it anyway.
member.setAccessType(AccessType.ACC_PUBLIC);
return;
}
// if we make a non-private method or any field public, need to go down to find all overriding
// members and make them public too
final MemberID memberID = member.getMemberID();
ClassVisitor visitor = new EmptyClassVisitor() {
@Override
public boolean visitClass(ClassInfo classInfo) {
ClassMemberInfo m = classInfo.getMemberInfo(memberID);
if (m == null) {
return true;
}
if (m.isPublic()) {
// we do not need to go further down if we find a public member
return false;
}
m.setAccessType(AccessType.ACC_PUBLIC);
return true;
}
};
new ClassHierarchyTraverser(visitor).traverseDown(member.getClassInfo());
}
Aggregations