From 18e06d5e0e4148f68b911a9b3cc44560c720c7b7 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 22 Sep 2023 14:18:22 +0200 Subject: [PATCH] [EA-910833] - AE: AbstractPopup.show GitOrigin-RevId: 25b7b42aa5eec820f647887e39c6818a0eedd670 --- .../find/actions/ShowUsagesAction.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java index 00e622c37fdb..b4089f2c8d2f 100644 --- a/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java +++ b/platform/lang-impl/src/com/intellij/find/actions/ShowUsagesAction.java @@ -30,6 +30,7 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.CustomComponentAction; import com.intellij.openapi.actionSystem.impl.ActionButton; import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl; +import com.intellij.openapi.application.AccessToken; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.application.ReadAction; @@ -200,7 +201,7 @@ public final class ShowUsagesAction extends AnAction implements PopupAction, Hin Editor editor = dataContext.getData(CommonDataKeys.EDITOR); RelativePoint popupPosition = JBPopupFactory.getInstance().guessBestPopupLocation(dataContext); SearchScope searchScope = FindUsagesOptions.findScopeByName(project, dataContext, FindSettings.getInstance().getDefaultScopeName()); - try (var ignored = SlowOperations.startSection(SlowOperations.ACTION_PERFORM)) { + try (AccessToken ignored = SlowOperations.startSection(SlowOperations.ACTION_PERFORM)) { findShowUsages( project, dataContext, targetVariants, FindBundle.message("show.usages.ambiguous.title"), createVariantHandler(project, editor, popupPosition, searchScope) @@ -429,8 +430,9 @@ public final class ShowUsagesAction extends AnAction implements PopupAction, Hin showElementUsagesWithResult(parameters, actionHandler); } - static Future> showElementUsagesWithResult(@NotNull ShowUsagesParameters parameters, - @NotNull ShowUsagesActionHandler actionHandler) { + @NotNull + private static Future> showElementUsagesWithResult(@NotNull ShowUsagesParameters parameters, + @NotNull ShowUsagesActionHandler actionHandler) { ThreadingAssertions.assertEventDispatchThread(); Span findUsageSpan = myFindUsagesTracer.spanBuilder("findUsages").startSpan(); @@ -448,8 +450,8 @@ public final class ShowUsagesAction extends AnAction implements PopupAction, Hin Ref preselectedRow = new Ref<>(); Predicate originUsageCheck = originUsageCheck(parameters.editor); - var renderer = new ShowUsagesTableCellRenderer(originUsageCheck, outOfScopeUsages, searchScope); - var table = new ShowUsagesTable(renderer, usageView); + ShowUsagesTableCellRenderer renderer = new ShowUsagesTableCellRenderer(originUsageCheck, outOfScopeUsages, searchScope); + ShowUsagesTable table = new ShowUsagesTable(renderer, usageView); addUsageNodes(usageView.getRoot(), usageView, new ArrayList<>()); @@ -465,7 +467,7 @@ public final class ShowUsagesAction extends AnAction implements PopupAction, Hin Consumer tableResizer = popup -> { if (popup != null && popup.isVisible() && !manuallyResized.get()) { PropertiesComponent properties = PropertiesComponent.getInstance(project); - var dataSize = table.getModel().getRowCount(); + int dataSize = table.getModel().getRowCount(); setPopupSize(table, popup, parameters.popupPosition, parameters.minWidth, properties.isValueSet(PREVIEW_PROPERTY_KEY), dataSize); } }; @@ -614,7 +616,7 @@ public final class ShowUsagesAction extends AnAction implements PopupAction, Hin UsageSearcher usageSearcher = actionHandler.createUsageSearcher(); long searchStarted = System.nanoTime(); - var result = new CompletableFuture>(); + CompletableFuture> result = new CompletableFuture<>(); FindUsagesManager.startProcessUsages(indicator, project, usageSearcher, collect, () -> ApplicationManager.getApplication().invokeLater( () -> { showUsagesPopupData.header.disposeProcessIcon(); @@ -717,8 +719,8 @@ public final class ShowUsagesAction extends AnAction implements PopupAction, Hin return __ -> false; } - private static boolean showPopupIfNeedTo(@NotNull JBPopup popup, @NotNull RelativePoint popupPosition, Ref popupShownTime) { - if (!popup.isDisposed() && !popup.isVisible()) { + private static boolean showPopupIfNeedTo(@NotNull JBPopup popup, @NotNull RelativePoint popupPosition, @NotNull Ref popupShownTime) { + if (!popup.isDisposed() && !popup.isVisible() && popup.canShow()) { popup.show(popupPosition); popupShownTime.set(System.currentTimeMillis()); return true;