From 0ca3b164b0dec5109667ba4078c740efc2d8b1e7 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Tue, 28 Jan 2020 16:41:01 +0300 Subject: [PATCH] IDEA-228916 IntentionAction.isAvailable() shouldn't be called in EDT on F2 / Shift+F2 execute 'calcTooltipAction' in read action (fixes IDEA-231613) GitOrigin-RevId: 318f92a5299919965bee0832d11bca525384a06f --- .../editor/EditorMouseHoverPopupManager.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/editor/EditorMouseHoverPopupManager.java b/platform/lang-impl/src/com/intellij/openapi/editor/EditorMouseHoverPopupManager.java index 6611d77d766e..992dbe472dd2 100644 --- a/platform/lang-impl/src/com/intellij/openapi/editor/EditorMouseHoverPopupManager.java +++ b/platform/lang-impl/src/com/intellij/openapi/editor/EditorMouseHoverPopupManager.java @@ -479,10 +479,19 @@ public final class EditorMouseHoverPopupManager implements Disposable { @Nullable private Info calcInfo(@NotNull Editor editor) { HighlightInfo info = getHighlightInfo(); - if (info != null && (info.getDescription() == null || info.getToolTip() == null)) { - info = null; + HighlightInfo infoToUse = null; + TooltipAction tooltipAction = null; + if (info != null && info.getDescription() != null && info.getToolTip() != null) { + infoToUse = info; + try { + tooltipAction = ReadAction.nonBlocking(() -> TooltipActionProvider.calcTooltipAction(info, editor)).executeSynchronously(); + } + catch (IndexNotReadyException ignored) { + } + catch (Exception e) { + LOG.warn(e); + } } - TooltipAction tooltipAction = info == null ? null : TooltipActionProvider.calcTooltipAction(info, editor); String quickDocMessage = null; PsiElement targetElement = null; @@ -517,7 +526,7 @@ public final class EditorMouseHoverPopupManager implements Disposable { LOG.warn(e); } } - return info == null && quickDocMessage == null ? null : new Info(info, tooltipAction, quickDocMessage, targetElement); + return infoToUse == null && quickDocMessage == null ? null : new Info(infoToUse, tooltipAction, quickDocMessage, targetElement); } private enum Relation {