Skip to content

Commit

Permalink
Implement library/preinstall (Without Dependencies Yet) (#1972)
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd authored and iamrecursion committed Sep 2, 2021
1 parent 6de511e commit 5751386
Show file tree
Hide file tree
Showing 56 changed files with 1,739 additions and 642 deletions.
5 changes: 5 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Enso Next

- Implement `library/preinstall` endpoint, allowing the IDE to request a library
to be installed asynchronously before importing it, so that adding the import
does not seem to freeze the compiler
([#1972](https://github.com/enso-org/enso/pull/1972)).

# Enso 0.2.27 (2021-08-23)

## Libraries
Expand Down
22 changes: 21 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ lazy val enso = (project in file("."))
`edition-uploader`,
`library-manager`,
`library-manager-test`,
`connected-lock-manager`,
`stdlib-version-updater`,
syntax.jvm,
testkit
Expand Down Expand Up @@ -1011,6 +1012,7 @@ lazy val `language-server` = (project in file("engine/language-server"))
.dependsOn(`json-rpc-server`)
.dependsOn(`task-progress-notifications`)
.dependsOn(`library-manager`)
.dependsOn(`connected-lock-manager`)
.dependsOn(`edition-updater`)
.dependsOn(`logging-service`)
.dependsOn(`polyglot-api`)
Expand Down Expand Up @@ -1100,7 +1102,7 @@ lazy val runtime = (project in file("engine/runtime"))
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.graalvm.truffle" % "truffle-api" % graalVersion % Benchmark,
"org.typelevel" %% "cats-core" % catsVersion,
"eu.timepit" %% "refined" % refinedVersion,
"eu.timepit" %% "refined" % refinedVersion
),
// Note [Unmanaged Classpath]
Compile / unmanagedClasspath += (`core-definition` / Compile / packageBin).value,
Expand Down Expand Up @@ -1186,6 +1188,9 @@ lazy val runtime = (project in file("engine/runtime"))
.dependsOn(graph)
.dependsOn(pkg)
.dependsOn(searcher)
.dependsOn(`edition-updater`)
.dependsOn(`library-manager`)
.dependsOn(`connected-lock-manager`)
.dependsOn(syntax.jvm)
.dependsOn(testkit % Test)

Expand Down Expand Up @@ -1424,6 +1429,21 @@ lazy val `library-manager-test` = project
.dependsOn(testkit)
.dependsOn(`logging-service`)

lazy val `connected-lock-manager` = project
.in(file("lib/scala/connected-lock-manager"))
.configs(Test)
.settings(
libraryDependencies ++= Seq(
"com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion,
akkaActor,
akkaTestkit % Test,
"org.scalatest" %% "scalatest" % scalatestVersion % Test
)
)
.dependsOn(`distribution-manager`)
.dependsOn(`polyglot-api`)
.dependsOn(testkit % Test)

lazy val `stdlib-version-updater` = project
.in(file("lib/scala/stdlib-version-updater"))
.configs(Test)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.enso.languageserver.boot

import akka.actor.ActorSystem
import org.enso.distribution.locking.{
ResourceManager,
ThreadSafeFileLockManager
}
import org.enso.distribution.{DistributionManager, Environment, LanguageHome}
import org.enso.editions.EditionResolver
import org.enso.editions.updater.EditionManager
Expand All @@ -15,6 +19,7 @@ import org.enso.languageserver.io._
import org.enso.languageserver.libraries.{
EditionReferenceResolver,
LibraryConfig,
LibraryInstallerConfig,
LocalLibraryManager,
ProjectSettingsManager
}
Expand All @@ -40,6 +45,7 @@ import org.enso.languageserver.util.binary.BinaryEncoder
import org.enso.librarymanager.LibraryLocations
import org.enso.librarymanager.local.DefaultLocalLibraryProvider
import org.enso.librarymanager.published.PublishedLibraryCache
import org.enso.lockmanager.server.LockManagerService
import org.enso.loggingservice.{JavaLoggingLogHandler, LogLevel}
import org.enso.polyglot.{RuntimeOptions, RuntimeServerInfo}
import org.enso.searcher.sql.{SqlDatabase, SqlSuggestionsRepo, SqlVersionsRepo}
Expand Down Expand Up @@ -120,8 +126,34 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) {
lazy val sessionRouter =
system.actorOf(SessionRouter.props(), "session-router")

val environment = new Environment {}
val languageHome = LanguageHome.detectFromExecutableLocation(environment)
val distributionManager = new DistributionManager(environment)

val editionProvider =
EditionManager.makeEditionProvider(distributionManager, Some(languageHome))
val editionResolver = EditionResolver(editionProvider)
val editionReferenceResolver = new EditionReferenceResolver(
contentRoot.file,
editionProvider,
editionResolver
)
val editionManager = EditionManager(distributionManager, Some(languageHome))
val lockManager = new ThreadSafeFileLockManager(
distributionManager.paths.locks
)
val resourceManager = new ResourceManager(lockManager)

val lockManagerService = system.actorOf(
LockManagerService.props(lockManager),
"lock-manager-service"
)

lazy val runtimeConnector =
system.actorOf(RuntimeConnector.props, "runtime-connector")
system.actorOf(
RuntimeConnector.props(lockManagerService),
"runtime-connector"
)

lazy val contentRootManagerActor =
system.actorOf(
Expand Down Expand Up @@ -272,20 +304,6 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) {
context
)(system.dispatcher)

val environment = new Environment {}
val languageHome = LanguageHome.detectFromExecutableLocation(environment)
val distributionManager = new DistributionManager(environment)

val editionProvider =
EditionManager.makeEditionProvider(distributionManager, Some(languageHome))
val editionResolver = EditionResolver(editionProvider)
val editionReferenceResolver = new EditionReferenceResolver(
contentRoot.file,
editionProvider,
editionResolver
)
val editionManager = EditionManager(distributionManager, Some(languageHome))

val projectSettingsManager = system.actorOf(
ProjectSettingsManager.props(contentRoot.file, editionResolver),
"project-settings-manager"
Expand All @@ -305,7 +323,12 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) {
editionManager = editionManager,
localLibraryProvider = DefaultLocalLibraryProvider.make(libraryLocations),
publishedLibraryCache =
PublishedLibraryCache.makeReadOnlyCache(libraryLocations)
PublishedLibraryCache.makeReadOnlyCache(libraryLocations),
installerConfig = LibraryInstallerConfig(
distributionManager,
resourceManager,
Some(languageHome)
)
)

val jsonRpcControllerFactory = new JsonConnectionControllerFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.enso.languageserver.libraries
import org.enso.editions.provider.EditionProvider
import org.enso.editions.{DefaultEdition, EditionResolver, Editions}
import org.enso.languageserver.libraries.EditionReference.NamedEdition
import org.enso.pkg.PackageManager
import org.enso.pkg.{Config, PackageManager}

import java.io.File
import scala.util.Try
Expand All @@ -24,14 +24,15 @@ class EditionReferenceResolver(
case EditionReference.NamedEdition(editionName) =>
editionProvider.findEditionForName(editionName).toTry
case EditionReference.CurrentProjectEdition =>
Try {
projectPackage.config.edition.getOrElse {
// TODO [RW] default edition from config (#1864)
DefaultEdition.getDefaultEdition
}
}
getCurrentProjectConfig.map(_.edition.getOrElse {
// TODO [RW] default edition from config (#1864)
DefaultEdition.getDefaultEdition
})
}

/** Returns the configuration of the current project. */
def getCurrentProjectConfig: Try[Config] = Try { projectPackage.config }

/** Resolves all edition dependencies of an edition identified by
* [[EditionReference]].
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import org.enso.librarymanager.published.PublishedLibraryCache
* @param editionManager an instance of edition manager
* @param localLibraryProvider an instance of local library provider
* @param publishedLibraryCache an instance of published library cache
* @param installerConfig configuration for the library installer
*/
case class LibraryConfig(
localLibraryManager: ActorRef,
editionReferenceResolver: EditionReferenceResolver,
editionManager: EditionManager,
localLibraryProvider: LocalLibraryProvider,
publishedLibraryCache: PublishedLibraryCache
publishedLibraryCache: PublishedLibraryCache,
installerConfig: LibraryInstallerConfig
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.enso.languageserver.libraries

import org.enso.distribution.{DistributionManager, LanguageHome}
import org.enso.distribution.locking.ResourceManager

/** Gathers configuration needed by the library installer used in the
* `library/preinstall` endpoint.
*
* @param distributionManager the distribution manager
* @param resourceManager a resource manager instance
* @param languageHome language home, if detected / applicable
*/
case class LibraryInstallerConfig(
distributionManager: DistributionManager,
resourceManager: ResourceManager,
languageHome: Option[LanguageHome]
)
Loading

0 comments on commit 5751386

Please sign in to comment.