public static void removeTask(final @NotNull Project project, @NotNull LocalTask task, @NotNull TaskManager manager) {
    if (task.isDefault()) {
      Messages.showInfoMessage(project, TaskBundle.message("dialog.message.default.task.cannot.be.removed"),
                               TaskBundle.message("dialog.title.cannot.remove"));
    }
    else {

      List<ChangeListInfo> infos = task.getChangeLists();
      List<LocalChangeList> lists = ContainerUtil.mapNotNull(infos, (NullableFunction<ChangeListInfo, LocalChangeList>)changeListInfo -> {
        LocalChangeList changeList = ChangeListManager.getInstance(project).getChangeList(changeListInfo.id);
        return changeList != null && !changeList.isDefault() ? changeList : null;
      });

      boolean removeIt = true;
      l:
      for (LocalChangeList list : lists) {
        if (!list.getChanges().isEmpty()) {
          int result = Messages.showYesNoCancelDialog(project,
                                                      TaskBundle.message("dialog.message.changelist.associated.with.not.empty", task.getSummary()),
                                                      TaskBundle.message("dialog.title.changelist.not.empty"), Messages.getWarningIcon());
          switch (result) {
            case Messages.YES:
              break l;
            case Messages.NO:
              removeIt = false;
              break;
            default:
              return;
          }
        }
      }
      if (removeIt) {
        for (LocalChangeList list : lists) {
          ChangeListManager.getInstance(project).removeChangeList(list);
        }
      }
      manager.removeTask(task);
    }
  }
public static void removeTask(final @NotNull Project project, @NotNull LocalTask task, @NotNull TaskManager manager)