Module info has to be read under readAction in scriptDefinitionsFromDependencies

#EA-220355 Fixed
This commit is contained in:
Vladimir Dolzhenko
2020-01-06 13:42:02 +01:00
parent aefad5cf5e
commit 93ce4c003f
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.idea.script package org.jetbrains.kotlin.idea.script
import com.intellij.ProjectTopics import com.intellij.ProjectTopics
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ModuleRootEvent import com.intellij.openapi.roots.ModuleRootEvent
import com.intellij.openapi.roots.ModuleRootListener import com.intellij.openapi.roots.ModuleRootListener
@@ -96,6 +97,8 @@ private fun scriptDefinitionsFromDependencies(project: Project): TemplatesWithCp
return templatesFound return templatesFound
} }
runReadAction {
if (project.isDisposed) return@runReadAction
// processing source roots from the same project first since the resources are copied to the classes roots only on compilation // processing source roots from the same project first since the resources are copied to the classes roots only on compilation
project.allModules().forEach { module -> project.allModules().forEach { module ->
OrderEnumerator.orderEntries(module).withoutDepModules().withoutLibraries().withoutSdk().sourceRoots.forEach { root -> OrderEnumerator.orderEntries(module).withoutDepModules().withoutLibraries().withoutSdk().sourceRoots.forEach { root ->
@@ -121,6 +124,7 @@ private fun scriptDefinitionsFromDependencies(project: Project): TemplatesWithCp
} }
} }
} }
}
return TemplatesWithCp(templates.toList(), classpath.toList()) return TemplatesWithCp(templates.toList(), classpath.toList())
} }