PsiClass (@NotNull PsiManager manager, @NotNull JavaPsiFacade facade, @NotNull String refText, PsiElement context) { PsiClass aClass = facade.getResolveHelper().resolveReferencedClass(refText, context); GlobalSearchScope projectScope = GlobalSearchScope.projectScope(manager.getProject()); if (aClass == null) aClass = facade.findClass(refText, projectScope); if (aClass == null && refText.indexOf('.') == -1 && context != null) { // find short-named class in the same package (maybe in the different module) PsiFile file = context.getContainingFile(); PsiDirectory directory = file == null ? null : file.getContainingDirectory(); PsiPackage aPackage = directory == null ? null : JavaDirectoryService.getInstance().getPackage(directory); aClass = aPackage == null ? null : ArrayUtil.getFirstElement(aPackage.findClassByShortName(refText, projectScope)); } return aClass; }