Skip to content

Commit

Permalink
3.3.4-RC2 2.12.20 (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochala authored Sep 11, 2024
1 parent 81af081 commit 12c72c0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ lazy val metalsRunner = project
maintainer := "scalacenter",
scalaVersion := ScalaVersions.stableLTS,
libraryDependencies ++= Seq(
"org.scalameta" % "metals" % "1.3.3" cross (CrossVersion.for3Use2_13),
"org.scalameta" % "metals" % "1.3.5" cross (CrossVersion.for3Use2_13),
"org.eclipse.lsp4j" % "org.eclipse.lsp4j" % "0.21.1",
"org.http4s" %% "http4s-ember-server" % "0.23.24",
"org.http4s" %% "http4s-ember-client" % "0.23.24",
Expand Down
43 changes: 20 additions & 23 deletions metals-runner/src/main/scala/scastie/metals/MetalsDispatcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.olegych.scastie.api.ScalaTarget._
import com.typesafe.config.ConfigFactory
import coursierapi.{Dependency, Fetch}
import org.slf4j.LoggerFactory
import scala.concurrent.ExecutionContext

/*
* MetalsDispatcher is responsible for managing the lifecycle of presentation compilers.
Expand Down Expand Up @@ -51,6 +52,16 @@ class MetalsDispatcher[F[_]: Async](cache: Cache[F, ScastieMetalsOptions, Scasti
private val presentationCompilers = PresentationCompilers[F](metalsWorkingDirectory)
private val supportedVersions = Set("2.12", "2.13", "3")

def getMtags(scalaVersion: String)=
for
given ExecutionContext <- Sync[F].executionContext
mtags <- Sync[F].blocking(
mtagsResolver
.resolve(scalaVersion)
.toRight(PresentationCompilerFailure(s"Mtags couldn't be resolved for target: ${scalaVersion}."))
).recover { case err: MatchError => PresentationCompilerFailure(err.getMessage).asLeft }
yield mtags

/*
* If `configuration` is supported returns either `FailureType` in case of error during its initialization
* or fetches the `ScastiePresentationCompiler` from guava cache.
Expand All @@ -75,29 +86,15 @@ class MetalsDispatcher[F[_]: Async](cache: Cache[F, ScastieMetalsOptions, Scasti
.get(configuration)
.map(_.toRight(PresentationCompilerFailure("Can't extract presentation compiler from cache.")))
else
val mtags = Sync[F]
.delay(
mtagsResolver
.resolve(configuration.scalaTarget.scalaVersion)
.toRight(
PresentationCompilerFailure(
s"Mtags couldn't be resolved for target: ${configuration.scalaTarget.scalaVersion}."
)
)
)
.recover { case err: MatchError => PresentationCompilerFailure(err.getMessage).asLeft }

mtags
.flatMap(
_.traverse(mtags =>
cache.getOrUpdateReleasable(configuration) {
initializeCompiler(configuration, mtags).map { newPC =>
Releasable(newPC, Sync[F].delay(newPC.underlyingPC.shutdown()))
}
}
)
)
.recover { case NonFatal(err) => PresentationCompilerFailure(err.getMessage).asLeft }
for
mtags <- EitherT(getMtags(configuration.scalaTarget.scalaVersion))
compiler <- EitherT.right(
cache.getOrUpdateReleasable(configuration) {
initializeCompiler(configuration, mtags).map: newPC =>
Releasable(newPC, Sync[F].delay(newPC.underlyingPC.shutdown()))
})
yield compiler
.value

/*
* Checks if given configuration is supported. Currently it is based on scala binary version.
Expand Down
4 changes: 2 additions & 2 deletions project/SbtShared.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ object SbtShared {
object ScalaVersions {
val latest210 = "2.10.7"
val latest211 = "2.11.12"
val latest212 = "2.12.19"
val latest212 = "2.12.20"
val latest213 = "2.13.14"
val old3 = "3.0.2"
val stableLTS = "3.3.3"
val stableNext = "3.5.0"
val latestLTS = "3.3.4-RC1"
val latestLTS = "3.3.4-RC2"
val latestNext = "3.5.1-RC2"
val js = latest213
val sbt = latest212
Expand Down

0 comments on commit 12c72c0

Please sign in to comment.