String (final PsiClass aClass) { final String qName = aClass.getQualifiedName(); if (qName != null) { return qName; } final PsiClass parent = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true); if (parent == null) { return null; } final String name = aClass.getName(); if (name != null) { return calcClassDisplayName(parent) + "$" + name; } final Ref<Integer> classIndex = new Ref<>(0); try { parent.accept(new JavaRecursiveElementVisitor() { @Override public void visitAnonymousClass(@NotNull PsiAnonymousClass cls) { classIndex.set(classIndex.get() + 1); if (aClass.equals(cls)) { throw new ProcessCanceledException(); } } }); } catch (ProcessCanceledException ignored) { } return calcClassDisplayName(parent) + "$" + classIndex.get(); }