From 84aa2ae4a4a89af3890cf2d5e9c3aa1cdddd3a0e Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 30 Jun 2025 14:09:27 +0200 Subject: [PATCH] [ui dispatcher] IJPL-189392 cleanup GitOrigin-RevId: 96ce6f7f50a291cc47429886c9c181ba61c09228 --- .../intellij/ui/EditorNotificationsImpl.kt | 44 +++++++++---------- .../src/META-INF/LangExtensions.xml | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.kt b/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.kt index 3fee22eaea4c..58c19774e16c 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.kt +++ b/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.kt @@ -33,6 +33,7 @@ import com.intellij.psi.PsiFile import com.intellij.refactoring.listeners.RefactoringElementAdapter import com.intellij.refactoring.listeners.RefactoringElementListener import com.intellij.refactoring.listeners.RefactoringElementListenerProvider +import com.intellij.ui.EditorNotifications.getInstance import com.intellij.util.concurrency.annotations.RequiresEdt import com.intellij.util.containers.CollectionFactory import com.intellij.util.ui.UIUtil @@ -62,7 +63,7 @@ class EditorNotificationsImpl(private val project: Project, coroutineScope: Coro * for example, in [com.intellij.httpClient.http.request.utils.prepareEditorNotifications]. * Since it's canceled in [dispose], we have to create a child. */ - private val coroutineScope: CoroutineScope = coroutineScope.childScope("EditorNotificationsImpl") + private val coroutineScope = coroutineScope.childScope("EditorNotificationsImpl") private val updateAllRequests = MutableSharedFlow(replay=1, onBufferOverflow = BufferOverflow.DROP_OLDEST) private val fileToUpdateNotificationJob = CollectionFactory.createConcurrentWeakMap() @@ -97,15 +98,16 @@ class EditorNotificationsImpl(private val project: Project, coroutineScope: Coro }) connection.subscribe(AdditionalLibraryRootsListener.TOPIC, AdditionalLibraryRootsListener { _, _, _, _ -> updateAllNotifications() }) EditorNotificationProvider.EP_NAME.getPoint(project) - .addExtensionPointListener(object : ExtensionPointListener { + .addExtensionPointListener(coroutineScope, false, object : ExtensionPointListener { override fun extensionAdded(extension: EditorNotificationProvider, pluginDescriptor: PluginDescriptor) { updateAllNotifications() } override fun extensionRemoved(extension: EditorNotificationProvider, pluginDescriptor: PluginDescriptor) { + @Suppress("DEPRECATION") updateNotifications(extension) } - }, false, null) + }) updateAllRequestFlowJob = coroutineScope.launch { updateAllRequests @@ -170,10 +172,8 @@ class EditorNotificationsImpl(private val project: Project, coroutineScope: Coro override fun updateNotifications(file: VirtualFile) { coroutineScope.launch(Dispatchers.EDT + ModalityState.any().asContextElement()) { - writeIntentReadAction { - if (file.isValid) { - doUpdateNotifications(file) - } + if (file.isValid) { + doUpdateNotifications(file) } } } @@ -344,24 +344,24 @@ class EditorNotificationsImpl(private val project: Project, coroutineScope: Coro doUpdateNotifications(file) } } +} - internal class RefactoringListenerProvider : RefactoringElementListenerProvider { - override fun getListener(element: PsiElement): RefactoringElementListener? { - if (element !is PsiFile) { - return null +private class RefactoringListenerProvider : RefactoringElementListenerProvider { + override fun getListener(element: PsiElement): RefactoringElementListener? { + if (element !is PsiFile) { + return null + } + + return object : RefactoringElementAdapter() { + override fun elementRenamedOrMoved(newElement: PsiElement) { + if (newElement is PsiFile) { + val vFile = newElement.getContainingFile().virtualFile ?: return + getInstance(element.getProject()).updateNotifications(vFile) + } } - return object : RefactoringElementAdapter() { - override fun elementRenamedOrMoved(newElement: PsiElement) { - if (newElement is PsiFile) { - val vFile = newElement.getContainingFile().virtualFile ?: return - getInstance(element.getProject()).updateNotifications(vFile) - } - } - - override fun undoElementMovedOrRenamed(newElement: PsiElement, oldQualifiedName: String) { - elementRenamedOrMoved(newElement) - } + override fun undoElementMovedOrRenamed(newElement: PsiElement, oldQualifiedName: String) { + elementRenamedOrMoved(newElement) } } } diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 0a25c53cdb27..d3a5654dc064 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -1171,7 +1171,7 @@ - +