From 02be55a947e17ed91019a43ac186243f0e085e6f Mon Sep 17 00:00:00 2001 From: Vojtech Balik Date: Thu, 30 Jan 2025 23:31:06 +0100 Subject: [PATCH] [code-vision] IJPL-174861 make sure `blockingContextToIndicator` is not used in tests `blockingContextToIndicator` causes RenameAwareReferencesCodeVisionProvider test to fail, because there is no Job or indicator. IJ-MR-153718 GitOrigin-RevId: 08b0dbef38138d2a3abbadec9f0a633d2de5f6a4 --- .../intellij/codeInsight/hints/InlayHintsUtils.kt | 12 ++++++++++-- .../RenameAwareReferencesCodeVisionProvider.kt | 7 ++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayHintsUtils.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayHintsUtils.kt index 50e3ca09238c..29022c4500cd 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayHintsUtils.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/InlayHintsUtils.kt @@ -14,6 +14,7 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.markup.EffectType import com.intellij.openapi.editor.markup.TextAttributesEffectsBuilder import com.intellij.openapi.progress.ProcessCanceledException +import com.intellij.openapi.progress.blockingContextToIndicator import com.intellij.openapi.util.Key import com.intellij.openapi.util.TextRange import com.intellij.psi.* @@ -287,11 +288,18 @@ object InlayHintsUtils { return storage } - fun computeCodeVisionUnderReadAction(computable: () -> CodeVisionState): CodeVisionState { + fun computeCodeVisionUnderReadAction(expectsIndicator: Boolean = false, computable: () -> CodeVisionState): CodeVisionState { try { if (!EDT.isCurrentThreadEdt()) { return ReadAction.computeCancellable { - return@computeCancellable computable.invoke() + if (expectsIndicator) { + blockingContextToIndicator { + computable.invoke() + } + } + else { + computable.invoke() + } } } else { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/hints/codeVision/RenameAwareReferencesCodeVisionProvider.kt b/platform/lang-impl/src/com/intellij/codeInsight/hints/codeVision/RenameAwareReferencesCodeVisionProvider.kt index 0ead67e71881..157770630911 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/hints/codeVision/RenameAwareReferencesCodeVisionProvider.kt +++ b/platform/lang-impl/src/com/intellij/codeInsight/hints/codeVision/RenameAwareReferencesCodeVisionProvider.kt @@ -11,7 +11,6 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.service import com.intellij.openapi.editor.Editor import com.intellij.openapi.fileEditor.FileDocumentManager -import com.intellij.openapi.progress.blockingContextToIndicator import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project import com.intellij.openapi.roots.ProjectFileIndex @@ -49,13 +48,11 @@ abstract class RenameAwareReferencesCodeVisionProvider : CodeVisionProvider