From 0462b3c30fcf12b1107c2ed5f80ec3b85f968619 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Thu, 20 Sep 2018 20:05:19 +0300 Subject: [PATCH] vcs: cleanup - remove unnecessary parameter --- .../changes/actions/ChangeListRemoveConfirmation.kt | 2 +- .../vcs/changes/actions/RemoveChangeListAction.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ChangeListRemoveConfirmation.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ChangeListRemoveConfirmation.kt index 3741a5beb4a0..f60ede5ce61d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ChangeListRemoveConfirmation.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ChangeListRemoveConfirmation.kt @@ -67,7 +67,7 @@ abstract class ChangeListRemoveConfirmation() { toRemove.forEach { manager.removeChangeList(it.name) } - if (shouldRemoveDefault && RemoveChangeListAction.confirmActiveChangeListRemoval(project, listOf(defaultList), defaultList.getChanges().isEmpty())) { + if (shouldRemoveDefault && RemoveChangeListAction.confirmActiveChangeListRemoval(project, listOf(defaultList))) { manager.removeChangeList(defaultList.name) } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/RemoveChangeListAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/RemoveChangeListAction.java index aba2983d9ef3..57fe04e9a443 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/RemoveChangeListAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/RemoveChangeListAction.java @@ -80,7 +80,7 @@ public class RemoveChangeListAction extends AnAction implements DumbAware { boolean haveNoChanges = lists.stream().allMatch(l -> l.getChanges().isEmpty()); if (activeChangelistSelected) { - return confirmActiveChangeListRemoval(project, lists, haveNoChanges); + return confirmActiveChangeListRemoval(project, lists); } String message = lists.size() == 1 @@ -93,7 +93,9 @@ public class RemoveChangeListAction extends AnAction implements DumbAware { .showYesNoDialog(project, message, VcsBundle.message("changes.removechangelist.warning.title"), Messages.getQuestionIcon()); } - static boolean confirmActiveChangeListRemoval(@NotNull Project project, @NotNull List lists, boolean empty) { + static boolean confirmActiveChangeListRemoval(@NotNull Project project, @NotNull List lists) { + boolean haveNoChanges = lists.stream().allMatch(l -> l.getChanges().isEmpty()); + List remainingLists = ChangeListManager.getInstance(project).getChangeListsCopy(); remainingLists.removeAll(lists); @@ -104,13 +106,13 @@ public class RemoveChangeListAction extends AnAction implements DumbAware { // don't ask "Which changelist to make active" if there is only one option anyway // unless there are some changes to be moved - give user a chance to cancel deletion - if (remainingLists.size() == 1 && empty) { + if (remainingLists.size() == 1 && haveNoChanges) { ChangeListManager.getInstance(project).setDefaultChangeList(remainingLists.get(0)); return true; } String[] remainingListsNames = remainingLists.stream().map(ChangeList::getName).toArray(String[]::new); - int nameIndex = Messages.showChooseDialog(project, empty + int nameIndex = Messages.showChooseDialog(project, haveNoChanges ? VcsBundle.message("changes.remove.active.empty.prompt") : VcsBundle.message("changes.remove.active.prompt"), VcsBundle.message("changes.remove.active.title"), Messages.getQuestionIcon(),