int (MethodSignature o1, MethodSignature o2) { if (o1 instanceof MethodSignatureBackedByPsiMethod && o2 instanceof MethodSignatureBackedByPsiMethod) { PsiMethod m1 = ((MethodSignatureBackedByPsiMethod)o1).getMethod(); PsiMethod m2 = ((MethodSignatureBackedByPsiMethod)o2).getMethod(); PsiClass c1 = m1.getContainingClass(); PsiClass c2 = m2.getContainingClass(); if (c1 != null && c2 != null) { if (c1 == c2) { final List<PsiMethod> methods = Arrays.asList(c1.getMethods()); return methods.indexOf(m1) - methods.indexOf(m2); } if (c1.isInheritor(c2, true)) return -1; if (c2.isInheritor(c1, true)) return 1; return StringUtil.notNullize(c1.getQualifiedName()).compareTo(StringUtil.notNullize(c2.getQualifiedName())); } return m1.getTextOffset() - m2.getTextOffset(); } return 0; }