mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[ui dispatcher] IJPL-189392 cleanup
GitOrigin-RevId: 96ce6f7f50a291cc47429886c9c181ba61c09228
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d1c73b2a72
commit
84aa2ae4a4
@@ -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<Unit>(replay=1, onBufferOverflow = BufferOverflow.DROP_OLDEST)
|
||||
|
||||
private val fileToUpdateNotificationJob = CollectionFactory.createConcurrentWeakMap<VirtualFile, Job>()
|
||||
@@ -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<EditorNotificationProvider> {
|
||||
.addExtensionPointListener(coroutineScope, false, object : ExtensionPointListener<EditorNotificationProvider> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1171,7 +1171,7 @@
|
||||
<statistics.counterUsagesCollector implementationClass="com.intellij.ui.codeFloatingToolbar.CodeFloatingToolbarCollector" />
|
||||
<textEditorCustomizer implementation="com.intellij.ui.codeFloatingToolbar.FloatingCodeToolbarEditorCustomizer" />
|
||||
<customizableActionGroupProvider implementation="com.intellij.ui.codeFloatingToolbar.FloatingCodeToolbarGroupCustomizer"/>
|
||||
<refactoring.elementListenerProvider implementation="com.intellij.ui.EditorNotificationsImpl$RefactoringListenerProvider"/>
|
||||
<refactoring.elementListenerProvider implementation="com.intellij.ui.RefactoringListenerProvider"/>
|
||||
|
||||
<keymapExtension implementation="com.intellij.tools.ToolKeymapExtension"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user