PsiClass (@NotNull final String qualifiedName, @NotNull GlobalSearchScope scope) { final Ref<PsiClass> result = Ref.create(); processDirectories(StringUtil.getPackageName(qualifiedName), scope, dir -> { VirtualFile virtualFile = findChild(dir, StringUtil.getShortName(qualifiedName), myFileExtensions); final PsiFile file = virtualFile == null ? null : myManager.findFile(virtualFile); if (file instanceof PsiClassOwner) { final PsiClass[] classes = ((PsiClassOwner)file).getClasses(); if (classes.length == 1) { result.set(classes[0]); return false; } } return true; }); return result.get(); }