void () { final PsiElement psiElement = TargetElementUtil .findTargetElement(myEditor, TargetElementUtil.ELEMENT_NAME_ACCEPTED | TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED); assertNotNull("No element found in text:\n" + getFile().getText(), psiElement); SafeDeleteHandler.invoke(getProject(), new PsiElement[]{psiElement}, true); }