boolean (@NotNull PsiClass aClass, @Nullable LanguageLevel targetLevel) { if (targetLevel == null) return true; final Project project = aClass.getProject(); final VirtualFile vFile = PsiUtilCore.getVirtualFile(aClass); if (vFile == null) return true; Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vFile); if (module == null) { final OrderEntry entry = LibraryUtil.findLibraryEntry(vFile, project); if (entry != null) { module = entry.getOwnerModule(); } } Sdk jdk = module != null ? ModuleRootManager.getInstance(module).getSdk() : null; if (jdk == null) { jdk = ProjectRootManager.getInstance(project).getProjectSdk(); } if (jdk == null) return true; final JavaSdkVersion jdkVersion = JavaSdkVersionUtil.getJavaSdkVersion(jdk); if (jdkVersion != null) { return targetLevel.isAtLeast(jdkVersion.getMaxLanguageLevel()); } return true; }