void (@NotNull MatchProvider provider, @NotNull Project project, @NotNull Editor editor) { Boolean hasDuplicates = provider.hasDuplicates(); if (hasDuplicates == null || hasDuplicates.booleanValue()) { List<Match> duplicates = provider.getDuplicates(); ArrayList<RangeHighlighter> highlighters = null; if (duplicates.size() == 1) { highlighters = previewMatch(project, editor, duplicates.get(0).getTextRange()); } final int answer = ApplicationManager.getApplication().isUnitTestMode() || hasDuplicates == null ? Messages.YES : Messages.showYesNoDialog(project, RefactoringBundle.message("0.has.detected.1.code.fragments.in.this.file.that.can.be.replaced.with.a.call.to.extracted.method", ApplicationNamesInfo.getInstance().getProductName(), duplicates.size()), JavaRefactoringBundle .message( "process.duplicates.title"), Messages.getQuestionIcon()); if (answer == Messages.YES) { PsiDocumentManager.getInstance(project).commitAllDocuments(); invoke(project, editor, provider, hasDuplicates != null); } else if (highlighters != null) { final HighlightManager highlightManager = HighlightManager.getInstance(project); for (RangeHighlighter highlighter : highlighters) { highlightManager.removeSegmentHighlighter(editor, highlighter); } } } }