void (@NotNull AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final PsiElement element = getContextElement(dataContext); if (element == null) return; // it's calculated in advance because `NavigationUtil.collectRelatedItems` might be // calculated under a cancellable progress, and we can't use the data context anymore, // since it can't be reused between swing events RelativePoint popupLocation = JBPopupFactory.getInstance().guessBestPopupLocation(dataContext); List<GotoRelatedItem> items = NavigationUtil.collectRelatedItems(element, dataContext); if (items.isEmpty()) { Object component = PlatformCoreDataKeys.CONTEXT_COMPONENT.getData(dataContext); if (component instanceof EditorComponentImpl editor) { Point point = popupLocation.getPoint(); point.translate(0, -editor.getEditor().getLineHeight()); popupLocation = new RelativePoint(popupLocation.getComponent(), point); } JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(LangBundle.message("hint.text.no.related.symbols"), MessageType.ERROR, null) .setFadeoutTime(3000) .createBalloon() .show(popupLocation, Balloon.Position.above); return; } if (items.size() == 1) { items.get(0).navigate(); return; } NavigationUtil.getRelatedItemsPopup(items, LangBundle.message("popup.title.choose.target")).show(popupLocation); }