From fa240427fa40cfee472e29bd732d7b1b7cc42964 Mon Sep 17 00:00:00 2001 From: Daniil Kalinin Date: Mon, 14 Oct 2024 15:10:43 +0200 Subject: [PATCH] [python] PyParameterInfoHandler - do not store reference to PyArgumentList to avoid project leak GitOrigin-RevId: 60dad81303c261cefc611e2f66fcc18316916ba6 --- .../python/PyParameterInfoHandler.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/python/src/com/jetbrains/python/PyParameterInfoHandler.java b/python/src/com/jetbrains/python/PyParameterInfoHandler.java index 8e4833982ac0..2899fbc7cfd7 100644 --- a/python/src/com/jetbrains/python/PyParameterInfoHandler.java +++ b/python/src/com/jetbrains/python/PyParameterInfoHandler.java @@ -5,6 +5,8 @@ import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.codeInsight.parameterInfo.ParameterFlag; import com.intellij.lang.parameterInfo.*; import com.intellij.openapi.actionSystem.IdeActions; +import com.intellij.openapi.application.ModalityState; +import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.util.Pair; @@ -12,6 +14,7 @@ import com.intellij.openapi.util.registry.Registry; import com.intellij.psi.PsiFile; import com.intellij.ui.ExperimentalUI; import com.intellij.ui.components.ActionLink; +import com.intellij.util.concurrency.AppExecutorUtil; import com.intellij.util.ui.JBUI; import com.jetbrains.python.codeInsight.parameterInfo.ParameterHints; import com.jetbrains.python.codeInsight.parameterInfo.PyParameterInfoUtils; @@ -34,10 +37,10 @@ public final class PyParameterInfoHandler implements ParameterInfoHandler PARAM_FLAG_TO_UI_FLAG = new EnumMap<>(Map.of( ParameterFlag.HIGHLIGHT, ParameterInfoUIContextEx.Flag.HIGHLIGHT, @@ -78,6 +81,7 @@ public final class PyParameterInfoHandler implements ParameterInfoHandler { - if (myArgumentList != null && myCreateContext != null) { - showParameterInfo(myArgumentList, myCreateContext); + if (myCreateContext != null) { + ReadAction + .nonBlocking(() -> { + return findElementForParameterInfo(myCreateContext); + }) + .finishOnUiThread(ModalityState.defaultModalityState(), argumentList -> { + if (argumentList != null) { + showParameterInfo(argumentList, myCreateContext); + } + }) + .coalesceBy(myCreateContext, this) + .expireWhen(() -> isDisposed) + .submit(AppExecutorUtil.getAppExecutorService()); } }); @@ -216,7 +230,7 @@ public final class PyParameterInfoHandler implements ParameterInfoHandler