From f1ad21b09c481bdb5f6f72d62cf48e4f740ccd45 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Fri, 28 Jun 2024 19:44:36 +0200 Subject: [PATCH] Don't use UpdatingEditionManager in regular execution --- .../enso/languageserver/boot/MainModule.scala | 6 +++- .../enso/runner/DependencyPreinstaller.scala | 3 +- .../editions/updater/EditionManager.scala | 30 ++++++++++++------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala b/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala index cb1b298228ba..441e64614801 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala @@ -158,7 +158,11 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: Level) { val distributionManager = new DistributionManager(environment) val editionProvider = - EditionManager.makeEditionProvider(distributionManager, Some(languageHome)) + EditionManager.makeEditionProvider( + distributionManager, + Some(languageHome), + false + ) val editionResolver = EditionResolver(editionProvider) val editionReferenceResolver = new EditionReferenceResolver( contentRoot.file, diff --git a/engine/runner/src/main/scala/org/enso/runner/DependencyPreinstaller.scala b/engine/runner/src/main/scala/org/enso/runner/DependencyPreinstaller.scala index f99b954afa7a..f42b2c54134d 100644 --- a/engine/runner/src/main/scala/org/enso/runner/DependencyPreinstaller.scala +++ b/engine/runner/src/main/scala/org/enso/runner/DependencyPreinstaller.scala @@ -43,7 +43,8 @@ object DependencyPreinstaller { val editionProvider = EditionManager.makeEditionProvider( distributionManager, - Some(languageHome) + Some(languageHome), + true ) val editionResolver = EditionResolver(editionProvider) val edition = editionResolver diff --git a/lib/scala/edition-updater/src/main/scala/org/enso/editions/updater/EditionManager.scala b/lib/scala/edition-updater/src/main/scala/org/enso/editions/updater/EditionManager.scala index 1f63c151c41a..ce82bca919e6 100644 --- a/lib/scala/edition-updater/src/main/scala/org/enso/editions/updater/EditionManager.scala +++ b/lib/scala/edition-updater/src/main/scala/org/enso/editions/updater/EditionManager.scala @@ -48,18 +48,26 @@ class EditionManager private ( object EditionManager { /** Create an [[EditionProvider]] that can locate editions from the - * distribution and the language home. + * distribution (if updating) and the language home. */ - def makeEditionProvider( + final def makeEditionProvider( distributionManager: DistributionManager, - languageHome: Option[LanguageHome] - ): UpdatingEditionProvider = { - val config = new GlobalConfigurationManager(distributionManager).getConfig - new UpdatingEditionProvider( - getSearchPaths(distributionManager, languageHome), - distributionManager.paths.cachedEditions, - config.editionProviders - ) + languageHome: Option[LanguageHome], + updating: Boolean + ): editions.provider.EditionProvider = { + val config = new GlobalConfigurationManager(distributionManager).getConfig + val searchPaths = getSearchPaths(distributionManager, languageHome) + val cachePath = distributionManager.paths.cachedEditions + if (updating) { + new UpdatingEditionProvider( + searchPaths, + cachePath, + config.editionProviders + ) + } else { + val actualSearchPaths = (searchPaths ++ List(cachePath)).distinct + new editions.provider.FileSystemEditionProvider(actualSearchPaths) + } } /** Get search paths associated with the distribution and language home. */ @@ -79,6 +87,6 @@ object EditionManager { distributionManager: DistributionManager, languageHome: Option[LanguageHome] = None ): EditionManager = new EditionManager( - makeEditionProvider(distributionManager, languageHome) + makeEditionProvider(distributionManager, languageHome, false) ) }