private static boolean replaceMatch(final Project project,
                                      final MatchProvider provider,
                                      final Match match,
                                      @NotNull final Editor editor,
                                      final int idx,
                                      final int size,
                                      Ref<Boolean> showAll,
                                      final String confirmDuplicatePrompt,
                                      boolean skipPromptWhenOne) {
    final ArrayList<RangeHighlighter> highlighters = previewMatch(project, editor, match.getTextRange());
    try {
      if (!ApplicationManager.getApplication().isUnitTestMode()) {
        if ((!skipPromptWhenOne || size > 1) && (showAll.get() == null || !showAll.get())) {
          final String prompt = provider.getConfirmDuplicatePrompt(match);
          final ReplacePromptDialog promptDialog = new ReplacePromptDialog(false, provider.getReplaceDuplicatesTitle(idx, size), project) {
            @Override
            protected String getMessage() {
              final String message = super.getMessage();
              return prompt != null ? message + " " + prompt : message;
            }
          };
          promptDialog.show();
          final boolean allChosen = promptDialog.getExitCode() == FindManager.PromptResult.ALL;
          showAll.set(allChosen);
          if (allChosen && confirmDuplicatePrompt != null && prompt == null) {
            if (Messages.showOkCancelDialog(project, JavaRefactoringBundle.message("process.duplicates.change.signature.promt"),
                                            JavaRefactoringBundle.message("change.method.signature.action.name"), CommonBundle.getContinueButtonText(), CommonBundle.getCancelButtonText(), Messages.getWarningIcon()) !=
                Messages.OK) return true;
          }
          if (promptDialog.getExitCode() == FindManager.PromptResult.SKIP) return false;
          if (promptDialog.getExitCode() == FindManager.PromptResult.CANCEL) return true;
        }
      }
    }
    finally {
      HighlightManager.getInstance(project).removeSegmentHighlighter(editor, highlighters.get(0));
    }

    // call change signature when needed
    provider.prepareSignature(match);

    WriteCommandAction.writeCommandAction(project).withName(MethodDuplicatesHandler.getRefactoringName())
                      .withGroupId(MethodDuplicatesHandler.getRefactoringName()).run(() -> {
      try {
        provider.processMatch(match);
      }
      catch (IncorrectOperationException e) {
        LOG.error(e);
      }
    });

    return false;
  }
private static boolean replaceMatch(final Project project,
                                      final MatchProvider provider,
                                      final Match match,
                                      @NotNull final Editor editor,
                                      final int idx,
                                      final int size,
                                      Ref<Boolean> showAll,
                                      final String confirmDuplicatePrompt,
                                      boolean skipPromptWhenOne)