From 7d215f05e1e68e7caffc806cab8078753a25bbda Mon Sep 17 00:00:00 2001 From: Dmitry Kozhevnikov Date: Fri, 11 May 2018 16:35:29 +0300 Subject: [PATCH] CPP-7168: Add a progress bar on searching for the associated file --- .../intellij/ide/actions/GotoRelatedSymbolAction.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/GotoRelatedSymbolAction.java b/platform/lang-impl/src/com/intellij/ide/actions/GotoRelatedSymbolAction.java index 1ec30d4b065a..3247c06128c6 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/GotoRelatedSymbolAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/GotoRelatedSymbolAction.java @@ -27,6 +27,7 @@ import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; +import com.intellij.ui.awt.RelativePoint; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -53,6 +54,11 @@ public class GotoRelatedSymbolAction extends AnAction { 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 items = NavigationUtil.collectRelatedItems(element, dataContext); if (items.isEmpty()) { final JComponent label = HintUtil.createErrorLabel("No related symbols"); @@ -61,7 +67,7 @@ public class GotoRelatedSymbolAction extends AnAction { .setFadeoutTime(3000) .setFillColor(HintUtil.getErrorColor()) .createBalloon() - .show(JBPopupFactory.getInstance().guessBestPopupLocation(dataContext), Balloon.Position.above); + .show(popupLocation, Balloon.Position.above); return; } @@ -69,7 +75,7 @@ public class GotoRelatedSymbolAction extends AnAction { items.get(0).navigate(); return; } - NavigationUtil.getRelatedItemsPopup(items, "Choose Target").showInBestPositionFor(dataContext); + NavigationUtil.getRelatedItemsPopup(items, "Choose Target").show(popupLocation); } @TestOnly