Skip to content

Commit

Permalink
Disable UpdatingEditionProvider when running Enso CLI (#10408)
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach authored Jul 3, 2024
1 parent 48fb999 commit 5e3a5b7
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ abstract class BaseServerTest
val editionProvider =
EditionManager.makeEditionProvider(
distributionManager,
Some(languageHome)
Some(languageHome),
true
)
val editionResolver = EditionResolver(editionProvider)
val editionReferenceResolver = new EditionReferenceResolver(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ object DependencyPreinstaller {

val editionProvider = EditionManager.makeEditionProvider(
distributionManager,
Some(languageHome)
Some(languageHome),
true
)
val editionResolver = EditionResolver(editionProvider)
val edition = editionResolver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import java.nio.file.Path
import scala.util.Try

/** A helper class for resolving editions. */
class EditionManager private (editionProvider: UpdatingEditionProvider) {
class EditionManager private (
editionProvider: editions.provider.EditionProvider
) {
private val editionResolver = EditionResolver(editionProvider)
private val engineVersionResolver =
editions.EngineVersionResolver(editionProvider)
Expand Down Expand Up @@ -46,18 +48,26 @@ class EditionManager private (editionProvider: UpdatingEditionProvider) {
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. */
Expand All @@ -77,6 +87,6 @@ object EditionManager {
distributionManager: DistributionManager,
languageHome: Option[LanguageHome] = None
): EditionManager = new EditionManager(
makeEditionProvider(distributionManager, languageHome)
makeEditionProvider(distributionManager, languageHome, false)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ class UpdatingEditionProvider(
case Right(value) => Right(value)
}

/** Finds all editions available on the [[searchPaths]]. */
override def findAvailableEditions(): Seq[String] =
provider.findAvailableEditions()

/** Finds all available editions, performing an update if asked to. */
def findAvailableEditions(update: Boolean): Seq[String] = {
override def findAvailableEditions(update: Boolean): Seq[String] = {
if (update) {
updater.updateEditions()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ trait EditionProvider {
): Either[EditionLoadingError, Editions.Raw.Edition]

/** Finds all editions that are currently available. */
def findAvailableEditions(): Seq[String]
def findAvailableEditions(update: Boolean = false): Seq[String]
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class FileSystemEditionProvider(searchPaths: List[Path])
}

/** Finds all editions available on the [[searchPaths]]. */
override def findAvailableEditions(): Seq[String] =
override def findAvailableEditions(
ignoreUpdateRequest: Boolean
): Seq[String] =
searchPaths.flatMap(findEditionsAt).distinct

private def findEditionName(path: Path): Option[String] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class EditionResolverSpec
): Either[EditionLoadingError, Editions.Raw.Edition] =
editions.get(name).toRight(EditionNotFound(name))

override def findAvailableEditions(): Seq[String] = editions.keys.toSeq
override def findAvailableEditions(update: Boolean): Seq[String] =
editions.keys.toSeq
}

val resolver = EditionResolver(FakeEditionProvider)
Expand Down

0 comments on commit 5e3a5b7

Please sign in to comment.