PsiClass (@NotNull String qName, @NotNull VirtualFile root, @NotNull PsiManager psiManager, @NotNull GlobalSearchScope scope) { String pathRest = qName; VirtualFile cur = root; while (true) { int dot = pathRest.indexOf('.'); if (dot < 0) break; String pathComponent = pathRest.substring(0, dot); VirtualFile child = cur.findChild(pathComponent); if (child == null) break; pathRest = pathRest.substring(dot + 1); cur = child; } String classNameWithInnerClasses = pathRest; String topLevelClassName = substringBeforeFirstDot(classNameWithInnerClasses); VirtualFile vFile = cur.findChild(topLevelClassName + ".class"); if (vFile == null) vFile = cur.findChild(topLevelClassName + ".java"); if (vFile == null) { return null; } if (!vFile.isValid()) { LOG.error("Invalid child of valid parent: " + vFile.getPath() + "; " + root.isValid() + " path=" + root.getPath()); return null; } if (!scope.contains(vFile)) { return null; } final PsiFile file = psiManager.findFile(vFile); if (!(file instanceof PsiClassOwner)) { return null; } return findClassInPsiFile(classNameWithInnerClasses, (PsiClassOwner)file); }