From faf95cced484c76a6b7d9ceaae04dd6e685254f8 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Thu, 25 Apr 2024 10:33:24 +0200 Subject: [PATCH] [editor] add several explicit threading annotations GitOrigin-RevId: ae09ce9de205dfaf03693846c3754c38dbd58198 --- .../analysis/problemsView/toolWindow/HighlightingPanel.kt | 5 +++++ .../openapi/editor/markup/ErrorStripeRenderer.java | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/analysis/problemsView/toolWindow/HighlightingPanel.kt b/platform/lang-impl/src/com/intellij/analysis/problemsView/toolWindow/HighlightingPanel.kt index e4c6caa11f6b..e2e49fd53e6b 100644 --- a/platform/lang-impl/src/com/intellij/analysis/problemsView/toolWindow/HighlightingPanel.kt +++ b/platform/lang-impl/src/com/intellij/analysis/problemsView/toolWindow/HighlightingPanel.kt @@ -21,6 +21,8 @@ import com.intellij.util.Alarm.ThreadToUse import com.intellij.util.SingleAlarm import com.intellij.util.concurrency.AppExecutorUtil import com.intellij.util.concurrency.ThreadingAssertions +import com.intellij.util.concurrency.annotations.RequiresBackgroundThread +import com.intellij.util.concurrency.annotations.RequiresReadLock import com.intellij.util.ui.tree.TreeUtil import org.jetbrains.annotations.Nls import org.jetbrains.concurrency.CancellablePromise @@ -146,6 +148,7 @@ class HighlightingPanel(project: Project, state: ProblemsViewState) return null } + @RequiresBackgroundThread private fun updateStatus() { ApplicationManager.getApplication().assertIsNonDispatchThread() val status = ClientId.withClientId(session.clientId) { ReadAction.compute(ThrowableComputable { getCurrentStatus() })} @@ -163,6 +166,8 @@ class HighlightingPanel(project: Project, state: ProblemsViewState) } } + @RequiresBackgroundThread + @RequiresReadLock private fun getCurrentStatus(): Status { ApplicationManager.getApplication().assertIsNonDispatchThread() val file = getCurrentFile() ?: return Status(ProblemsViewBundle.message("problems.view.highlighting.no.selected.file")) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java b/platform/platform-impl/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java index 41f2307c9589..1ddd054c8105 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java @@ -15,8 +15,13 @@ */ package com.intellij.openapi.editor.markup; +import com.intellij.util.concurrency.annotations.RequiresBackgroundThread; +import com.intellij.util.concurrency.annotations.RequiresReadLock; import org.jetbrains.annotations.NotNull; public interface ErrorStripeRenderer { - @NotNull AnalyzerStatus getStatus(); + @RequiresReadLock + @RequiresBackgroundThread + @NotNull + AnalyzerStatus getStatus(); }