private static void performActions(@NotNull Collection<? extends UndoableAction> actions, boolean isUndo, boolean useBulkMode)
    throws UnexpectedUndoException {
    Set<DocumentEx> bulkDocuments = new HashSet<>();
    try {
      for (UndoableAction action : actions) {
        if (useBulkMode) {
          DocumentEx newDocument = getDocumentToSetBulkMode(action);
          if (newDocument == null) {
            for (DocumentEx document : bulkDocuments) {
              document.setInBulkUpdate(false);
            }
            bulkDocuments.clear();
          }
          else if (bulkDocuments.add(newDocument)) {
            newDocument.setInBulkUpdate(true);
          }
        }
        if (isUndo) {
          action.undo();
        }
        else {
          action.redo();
        }
      }
    }
    finally {
      for (DocumentEx bulkDocument : bulkDocuments) {
        bulkDocument.setInBulkUpdate(false);
      }
    }
  }
private static void performActions(@NotNull Collection<? extends UndoableAction> actions, boolean isUndo, boolean useBulkMode)