void (@NotNull Project project, @NotNull PsiFile file, @Nullable Editor editor, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { if (editor == null) return; if (mySameNamedKeys.size() == 2) { final Iterator<SmartPsiElementPointer<PsiElement>> iterator = mySameNamedKeys.iterator(); final PsiElement next = iterator.next().getElement(); PsiElement toNavigate = next != startElement ? next : iterator.next().getElement(); if (toNavigate == null) return; navigateTo(editor, toNavigate); } else { final List<PsiElement> allElements = mySameNamedKeys.stream().map(k -> k.getElement()).filter(k -> k != startElement).collect(Collectors.toList()); JBPopupFactory.getInstance().createListPopup( new BaseListPopupStep<>(JsonBundle.message("navigate.to.duplicates.header", myEntryKey), allElements) { @Override public @NotNull Icon getIconFor(PsiElement aValue) { return IconManager.getInstance().getPlatformIcon(PlatformIcons.Property); } @Override public @NotNull String getTextFor(PsiElement value) { return JsonBundle .message("navigate.to.duplicates.desc", myEntryKey, editor.getDocument().getLineNumber(value.getTextOffset())); } @Override public int getDefaultOptionIndex() { return 0; } @Override public @Nullable PopupStep<?> onChosen(PsiElement selectedValue, boolean finalChoice) { navigateTo(editor, selectedValue); return PopupStep.FINAL_CHOICE; } @Override public boolean isSpeedSearchEnabled() { return true; } }).showInBestPositionFor(editor); } }