void (final @NotNull Module module, @NotNull LanguageLevel level, final @NotNull Runnable r) { final LanguageLevelProjectExtension projectExt = LanguageLevelProjectExtension.getInstance(module.getProject()); final LanguageLevel projectLevel = projectExt.getLanguageLevel(); final LanguageLevel moduleLevel = LanguageLevelUtil.getCustomLanguageLevel(module); try { projectExt.setLanguageLevel(level); setModuleLanguageLevel(module, level); r.run(); } finally { setModuleLanguageLevel(module, moduleLevel); projectExt.setLanguageLevel(projectLevel); } }