void (PsiDirectory srcDirectory) { final PsiClass empty = JavaPsiFacade.getInstance(getProject()).findClass(FOO, GlobalSearchScope.projectScope(getProject())); assert empty != null; ApplicationManager.getApplication().runWriteAction(empty::delete); }