ArrayList<PsiClass> (PsiClass subClass, boolean includeNonProject, boolean sortAlphabetically) { LinkedHashSet<PsiClass> bases = new LinkedHashSet<>(); InheritanceUtil.getSuperClasses(subClass, bases, includeNonProject); if (!subClass.isInterface()) { final PsiManager manager = subClass.getManager(); PsiClass javaLangObject = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_LANG_OBJECT, subClass.getResolveScope()); if (includeNonProject && javaLangObject != null && !manager.areElementsEquivalent(javaLangObject, subClass)) { bases.add(javaLangObject); } } ArrayList<PsiClass> basesList = new ArrayList<>(bases); if (sortAlphabetically) { basesList.sort((c1, c2) -> { final String fqn1 = c1.getQualifiedName(); final String fqn2 = c2.getQualifiedName(); if (fqn1 != null && fqn2 != null) return fqn1.compareTo(fqn2); if (fqn1 == null && fqn2 == null) { return Comparing.compare(c1.getName(), c2.getName()); } return fqn1 == null ? 1 : -1; }); } return basesList; }