PsiClass (@NotNull PsiFile file, @NotNull PsiMember member) { String className = FileUtilRt.getNameWithoutExtension(file.getName()); if (!StringUtil.isJavaIdentifier(className)) return null; PsiJavaFile javaFile = ObjectUtils.tryCast(file, PsiJavaFile.class); if (javaFile == null) return null; PsiClass psiClass = ContainerUtil.find(javaFile.getClasses(), c -> className.equals(c.getName())); if (psiClass != null) return psiClass; PsiElementFactory factory = JavaPsiFacade.getElementFactory(file.getProject()); return createClass(factory, className, member); }