void (Runnable runnable) { final LanguageLevelProjectExtension languageLevelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject()); final LanguageLevel oldLanguageLevel = languageLevelProjectExtension.getLanguageLevel(); languageLevelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_7); try { runnable.run(); } finally { languageLevelProjectExtension.setLanguageLevel(oldLanguageLevel); } }