[K/N][test] Sync PsiFactory creation

CoreApplicationEnvironment.registerApplicationDynamicExtensionPoint should be
guarded to ensure registration won't happen concurrently

Merge-request: KT-MR-8251
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
This commit is contained in:
Pavel Punegov
2023-01-12 10:39:43 +00:00
committed by Space Team
parent 37f3b7e816
commit a90983ca6a
@@ -823,6 +823,8 @@ private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : Te
}
companion object {
private val lock = Object()
private fun createPsiFactory(parentDisposable: Disposable): KtPsiFactory {
val configuration: CompilerConfiguration = KotlinTestUtils.newConfiguration()
configuration.put(CommonConfigurationKeys.MODULE_NAME, "native-blackbox-test-patching-module")
@@ -833,7 +835,12 @@ private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : Te
configFiles = EnvironmentConfigFiles.METADATA_CONFIG_FILES
)
CoreApplicationEnvironment.registerApplicationDynamicExtensionPoint(TreeCopyHandler.EP_NAME.name, TreeCopyHandler::class.java)
synchronized(lock) {
CoreApplicationEnvironment.registerApplicationDynamicExtensionPoint(
TreeCopyHandler.EP_NAME.name,
TreeCopyHandler::class.java
)
}
val project = environment.project as MockProject
project.registerService(PomModel::class.java, PomModelImpl::class.java)