PsiClass (@NotNull String indexName, @NotNull final PsiClass containingClass, final boolean jvmCompatible) { String prefix = getDigitPrefix(indexName); final int idx = !prefix.isEmpty() ? Integer.parseInt(prefix) : -1; final String name = prefix.length() < indexName.length() ? indexName.substring(prefix.length()) : null; final PsiClass[] result = new PsiClass[1]; containingClass.accept(new JavaRecursiveElementVisitor() { private int myCurrentIdx; @Override public void visitElement(@NotNull PsiElement element) { if (result[0] == null) { super.visitElement(element); } } @Override public void visitClass(@NotNull PsiClass aClass) { if (!jvmCompatible) { super.visitClass(aClass); if (aClass.getQualifiedName() == null) { myCurrentIdx++; if (myCurrentIdx == idx && Comparing.strEqual(name, aClass.getName())) { result[0] = aClass; } } return; } if (aClass == containingClass) { super.visitClass(aClass); return; } if (Comparing.strEqual(name, aClass.getName())) { myCurrentIdx++; if (myCurrentIdx == idx || idx == -1) { result[0] = aClass; } } } @Override public void visitTypeParameter(final @NotNull PsiTypeParameter classParameter) { if (!jvmCompatible) { super.visitTypeParameter(classParameter); } else { visitElement(classParameter); } } }); return result[0]; }