From 3532216ff438c935fc366fdd3006698db0635b99 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Wed, 24 Jan 2024 21:02:46 +0100 Subject: [PATCH] use concurrent hash set IDEA-343995 GitOrigin-RevId: 9392a29a9cd7f6329ac6d3bb4a8bbf86e3cec243 --- .../problems/pass/ProjectProblemFileSelectionListener.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/problems/pass/ProjectProblemFileSelectionListener.kt b/java/java-impl/src/com/intellij/codeInsight/daemon/problems/pass/ProjectProblemFileSelectionListener.kt index 963141a9ce4f..30b33e3309fb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/problems/pass/ProjectProblemFileSelectionListener.kt +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/problems/pass/ProjectProblemFileSelectionListener.kt @@ -6,6 +6,7 @@ import com.intellij.codeInsight.daemon.problems.FileStateCache import com.intellij.codeInsight.daemon.problems.FileStateUpdater.Companion.removeState import com.intellij.codeInsight.daemon.problems.FileStateUpdater.Companion.setPreviousState import com.intellij.codeInsight.hints.InlayHintsSettings +import com.intellij.concurrency.ConcurrentCollectionFactory import com.intellij.injected.editor.VirtualFileWindow import com.intellij.lang.jvm.JvmLanguage import com.intellij.openapi.application.ApplicationManager @@ -37,6 +38,7 @@ import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.launch +import java.util.concurrent.ConcurrentHashMap import kotlin.time.Duration.Companion.seconds /** @@ -120,18 +122,19 @@ internal class ProjectProblemFileRefactoringEventListener(private val project: P @OptIn(FlowPreview::class) @Service(Service.Level.PROJECT) private class ProjectPsiChangesProcessor(private val scope: CoroutineScope) { - private val psiChanges = hashSetOf() + private val psiChanges = ConcurrentCollectionFactory.createConcurrentSet() private val psiChangesProcessor = MutableSharedFlow(replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) init { scope.launch { psiChangesProcessor.debounce(2.seconds).collect { - for (file in psiChanges) { + for (file in psiChanges.toList()) { readAction { if (file.isValid) { updateFileState(file, file.project) } } + psiChanges.remove(file) } } }