void (@NotNull final Editor editor, @Nullable Caret c, DataContext dataContext) { Caret caret = editor.getCaretModel().getPrimaryCaret(); SelectionModel selectionModel = editor.getSelectionModel(); boolean hasSelection = caret.hasSelection(); TextRange occurrenceAtCaret = hasSelection ? new TextRange(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()) : ShTextOccurrencesUtil.findTextRangeOfIdentifierAtCaret(editor); if (occurrenceAtCaret == null) return; CharSequence documentText = editor.getDocument().getImmutableCharSequence(); CharSequence textToFind = occurrenceAtCaret.subSequence(documentText); Collection<TextRange> occurrences = ShTextOccurrencesUtil.findAllOccurrences(documentText, textToFind, !hasSelection); Project project = editor.getProject(); assert project != null; if (occurrences.size() < getMaxInplaceRenameSegments() && documentText.length() < FileUtilRt.MEGABYTE) { ShTextRenameRefactoring rename = ShTextRenameRefactoring.create(editor, project, textToFind.toString(), occurrences, occurrenceAtCaret); if (rename != null) { rename.start(); return; } } TextOccurrencesRenamer renamer = new TextOccurrencesRenamer(editor, textToFind.toString(), occurrences, occurrenceAtCaret); if (ApplicationManager.getApplication().isUnitTestMode()) { editor.putUserData(RENAMER_KEY, renamer); } else { new ShRenameDialog(project, renamer).show(); } }