private static void deleteInCommand(Project project, PsiElement[] elements) {
    CommandProcessor.getInstance().executeCommand(project, () -> NonProjectFileWritingAccessProvider.disableChecksDuring(() -> {
      SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(project);
      List<SmartPsiElementPointer<?>> pointers = ContainerUtil.map(elements, smartPointerManager::createSmartPsiElementPointer);

      if (!makeWritable(project, elements)) return;

      // deleted from project view or something like that.
      @SuppressWarnings("deprecation") DataContext context = DataManager.getInstance().getDataContext();
      if (CommonDataKeys.EDITOR.getData(context) == null) {
        CommandProcessor.getInstance().markCurrentCommandAsGlobal(project);
      }

      if (ContainerUtil.and(elements, DeleteHandler::isLocalFile)) {
        doDeleteFiles(project, elements);
      }
      else {
        for (SmartPsiElementPointer<?> pointer : pointers) {
          PsiElement elementToDelete = pointer.getElement();
          if (elementToDelete == null) continue; //was already deleted
          doDelete(project, elementToDelete);
        }
      }
    }), RefactoringBundle.message("safe.delete.command", RefactoringUIUtil.calculatePsiElementDescriptionList(elements)), null);
  }
private static void deleteInCommand(Project project, PsiElement[] elements)