@Override
  public void deleteElement(@NotNull DataContext dataContext) {
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null) return;

    List<PsiElement> validElements = new ArrayList<>();
    for (PsiElement psiElement : getElementsToDelete(project, dataContext)) {
      if (psiElement != null && psiElement.isValid()) {
        validElements.add(psiElement);
      }
    }

    PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements);
    LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
    try {
      DeleteHandler.deletePsiElement(elements, project);
    }
    finally {
      a.finish();
    }
  }
@Override
  public void deleteElement(@NotNull DataContext dataContext)