RenameHandler (@NotNull DataContext dataContext) { List<? extends RenameHandler> availableHandlers = getRenameHandlers(dataContext); if (availableHandlers.isEmpty()) { return null; } else if (availableHandlers.size() == 1) { return availableHandlers.get(0); } else if (ApplicationManager.getApplication().isUnitTestMode()) { return myRenameHandlerSelectorInTests.apply(availableHandlers); } else { Map<String, ? extends List<? extends RenameHandler>> title2Handlers = availableHandlers.stream().collect( Collectors.groupingBy(it -> getHandlerTitle(it)) ); final String[] strings = ArrayUtilRt.toStringArray(title2Handlers.keySet()); final HandlersChooser chooser = new HandlersChooser(CommonDataKeys.PROJECT.getData(dataContext), strings); if (chooser.showAndGet()) { return ContainerUtil.getLastItem(title2Handlers.get(chooser.getSelection())); } throw new ProcessCanceledException(); } }