EA-45164 - more TypeConversionUtil.getSuperClassSubstitutor diagnostics

This commit is contained in:
peter
2014-05-12 14:36:36 +02:00
parent 28d0e2ef64
commit c5c647100f
@@ -1065,29 +1065,42 @@ public class TypeConversionUtil {
}
if (substitutor == null) {
if (ourReportedSuperClassSubstitutorExceptions.add(derivedClass.getQualifiedName() + "/" + superClass.getQualifiedName())) {
final StringBuilder msg = new StringBuilder("Super: " + classInfo(superClass));
msg.append("visited:\n");
for (PsiClass aClass : visited) {
msg.append(" each: " + classInfo(aClass));
}
msg.append("isInheritor: " + InheritanceUtil.isInheritorOrSelf(derivedClass, superClass, true) + " " + derivedClass.isInheritor(superClass, true));
msg.append("hierarchy:\n");
InheritanceUtil.processSupers(derivedClass, true, new Processor<PsiClass>() {
@Override
public boolean process(PsiClass psiClass) {
msg.append("each: " + classInfo(psiClass));
return true;
}
});
LOG.error(msg.toString());
reportHierarchyInconsistency(superClass, derivedClass, visited);
}
return PsiSubstitutor.EMPTY;
}
return substitutor;
}
private static void reportHierarchyInconsistency(PsiClass superClass, PsiClass derivedClass, Set<PsiClass> visited) {
final StringBuilder msg = new StringBuilder("Super: " + classInfo(superClass));
msg.append("visited:\n");
for (PsiClass aClass : visited) {
msg.append(" each: " + classInfo(aClass));
}
msg.append("isInheritor: " + InheritanceUtil.isInheritorOrSelf(derivedClass, superClass, true) + " " + derivedClass.isInheritor(superClass, true));
msg.append("\nhierarchy:\n");
InheritanceUtil.processSupers(derivedClass, true, new Processor<PsiClass>() {
@Override
public boolean process(PsiClass psiClass) {
msg.append("each: " + classInfo(psiClass));
return true;
}
});
LOG.error(msg.toString());
}
private static String classInfo(PsiClass aClass) {
return aClass.getQualifiedName() + "(" + aClass.getClass().getName() + "; " + PsiUtilCore.getVirtualFile(aClass) + ");\n";
String s = aClass.getQualifiedName() + "(" + aClass.getClass().getName() + "; " + PsiUtilCore.getVirtualFile(aClass) + ");\n";
s += "extends: ";
for (PsiClassType type : aClass.getExtendsListTypes()) {
s += type + " (" + type.getClass().getName() + "; " + type.resolve() + ") ";
}
s += "\nimplements: ";
for (PsiClassType type : aClass.getImplementsListTypes()) {
s += type + " (" + type.getClass().getName() + "; " + type.resolve() + ") ";
}
return s + "\n";
}
@NotNull