From 70e68abc9f15310db1e8581a8d8c38ea6022eaf2 Mon Sep 17 00:00:00 2001 From: Andrew Kozlov Date: Thu, 5 Mar 2026 18:00:37 +0100 Subject: [PATCH 1/2] ALT-10995 cleanFileLevelHighlights moved to EDT --- .../academy/python/learning/PyEduUtils.kt | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/intellij-plugin/hs-Python/src/org/hyperskill/academy/python/learning/PyEduUtils.kt b/intellij-plugin/hs-Python/src/org/hyperskill/academy/python/learning/PyEduUtils.kt index 6f30d4a9a..003c34fb0 100644 --- a/intellij-plugin/hs-Python/src/org/hyperskill/academy/python/learning/PyEduUtils.kt +++ b/intellij-plugin/hs-Python/src/org/hyperskill/academy/python/learning/PyEduUtils.kt @@ -6,6 +6,7 @@ import com.intellij.codeHighlighting.Pass import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx import com.intellij.execution.configurations.GeneralCommandLine import com.intellij.execution.util.ExecUtil +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.runReadAction import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.fileEditor.FileEditorManager @@ -151,18 +152,20 @@ fun installRequiredPackages(project: Project, sdk: Sdk) { indicator.fraction = 1.0 indicator.text = "Installation completed" - // Clear file-level warning that might linger while skeletons are updating - val editorManager = FileEditorManager.getInstance(project) - for (module in ModuleManager.getInstance(project).modules) { - val analyzer = DaemonCodeAnalyzerEx.getInstanceEx(module.project) - if (editorManager.hasOpenFiles()) { - editorManager.openFiles.forEach { file -> - file.findPsiFile(project)?.let { psiFile -> - analyzer.cleanFileLevelHighlights(Pass.LOCAL_INSPECTIONS, psiFile) + ApplicationManager.getApplication().invokeLater({ + // Clear file-level warning that might linger while skeletons are updating + val editorManager = FileEditorManager.getInstance(project) + for (module in ModuleManager.getInstance(project).modules) { + val analyzer = DaemonCodeAnalyzerEx.getInstanceEx(module.project) + if (editorManager.hasOpenFiles()) { + editorManager.openFiles.forEach { file -> + file.findPsiFile(project)?.let { psiFile -> + analyzer.cleanFileLevelHighlights(Pass.LOCAL_INSPECTIONS, psiFile) + } } } } - } + }, project.disposed) // Installation completed successfully LOG.warn("PyEduUtils: Installation finished successfully") From 629ac0ef858462c79e128b34eb867f4ac3d21508 Mon Sep 17 00:00:00 2001 From: Andrew Kozlov Date: Thu, 5 Mar 2026 18:05:11 +0100 Subject: [PATCH 2/2] ALT-10995 unnecessary for loop removed --- .../academy/python/learning/PyEduUtils.kt | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/intellij-plugin/hs-Python/src/org/hyperskill/academy/python/learning/PyEduUtils.kt b/intellij-plugin/hs-Python/src/org/hyperskill/academy/python/learning/PyEduUtils.kt index 003c34fb0..a9b9c4183 100644 --- a/intellij-plugin/hs-Python/src/org/hyperskill/academy/python/learning/PyEduUtils.kt +++ b/intellij-plugin/hs-Python/src/org/hyperskill/academy/python/learning/PyEduUtils.kt @@ -155,16 +155,12 @@ fun installRequiredPackages(project: Project, sdk: Sdk) { ApplicationManager.getApplication().invokeLater({ // Clear file-level warning that might linger while skeletons are updating val editorManager = FileEditorManager.getInstance(project) - for (module in ModuleManager.getInstance(project).modules) { - val analyzer = DaemonCodeAnalyzerEx.getInstanceEx(module.project) - if (editorManager.hasOpenFiles()) { - editorManager.openFiles.forEach { file -> - file.findPsiFile(project)?.let { psiFile -> - analyzer.cleanFileLevelHighlights(Pass.LOCAL_INSPECTIONS, psiFile) - } - } - } - } + + val analyzer = DaemonCodeAnalyzerEx.getInstanceEx(project) + editorManager.openFiles + .asSequence() + .mapNotNull { it.findPsiFile(project) } + .forEach { analyzer.cleanFileLevelHighlights(Pass.LOCAL_INSPECTIONS, it) } }, project.disposed) // Installation completed successfully