void () { final LanguageLevelProjectExtension projectExtension = LanguageLevelProjectExtension.getInstance(getProject()); final LanguageLevel oldLevel = projectExtension.getLanguageLevel(); try { projectExtension.setLanguageLevel(LanguageLevel.HIGHEST); doTest(); } finally { projectExtension.setLanguageLevel(oldLevel); } }