public static void replaceDuplicate(final Project project, final Map<PsiMember, List<Match>> duplicates, final Set<? extends PsiMember> methods) {
    final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
    if (progressIndicator != null && progressIndicator.isCanceled()) return;

    final Runnable replaceRunnable = () -> {
      LocalHistoryAction a = LocalHistory.getInstance().startAction(getRefactoringName());
      try {
        for (final PsiMember member : methods) {
          final List<Match> matches = duplicates.get(member);
          if (matches == null) continue;
          final int duplicatesNo = matches.size();
          WindowManager.getInstance().getStatusBar(project).setInfo(getStatusMessage(duplicatesNo));
          CommandProcessor.getInstance().executeCommand(project,
                                                        () -> PostprocessReformattingAspect.getInstance(project).postponeFormattingInside(() -> {
                                                          final MatchProvider matchProvider =
                                                            member instanceof PsiMethod ? new MethodDuplicatesMatchProvider((PsiMethod)member, matches)
                                                                                        : new ConstantMatchProvider(member, project, matches);
                                                          DuplicatesImpl.invoke(project, matchProvider, true);
                                                        }), getRefactoringName(), getRefactoringName());

          WindowManager.getInstance().getStatusBar(project).setInfo("");
        }
      }
      finally {
        a.finish();
      }
    };
    ApplicationManager.getApplication().invokeLater(replaceRunnable, project.getDisposed());
  }
public static void replaceDuplicate(final Project project, final Map<PsiMember, List<Match>> duplicates, final Set<? extends PsiMember> methods)