Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Nov 9, 2023
1 parent f64429e commit 7e18b77
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ class BspConnector(
possibleBuildServerConn match {
case None => Future.successful(None)
case Some(buildServerConn)
if buildServerConn.isBloop && buildTools.isSbt =>
if buildServerConn.isBloop && buildTool.exists(
_.isInstanceOf[SbtBuildTool]
) =>
// NOTE: (ckipp01) we special case this here since sbt bsp server
// doesn't yet support metabuilds. So in the future when that
// changes, re-work this and move the creation of this out above
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import scala.meta.internal.builds.BuildServerProvider
import scala.meta.internal.builds.BuildTool
import scala.meta.internal.builds.BuildToolSelector
import scala.meta.internal.builds.BuildTools
import scala.meta.internal.builds.Digest
import scala.meta.internal.builds.SbtBuildTool
import scala.meta.internal.builds.ScalaCliBuildTool
import scala.meta.internal.builds.ShellRunner
Expand Down Expand Up @@ -911,17 +912,22 @@ class MetalsLspService(
def fullConnect(): Future[Unit] =
for {
found <- supportedBuildTool()
_ = found match {
chosenBuildServer = found match {
case Some(BuildTool.Found(buildServer, _))
if buildServer.forcesBuildServer =>
tables.buildServers.chooseServer(buildServer.executableName)
case _ =>
Some(buildServer.executableName)
case _ => tables.buildServers.selectedServer()
}
_ <- Future
.sequence(
List(
quickConnectToBuildServer(),
slowConnectToBuildServer(forceImport = false, found),
slowConnectToBuildServer(
forceImport = false,
found,
chosenBuildServer,
),
)
)
} yield ()
Expand Down Expand Up @@ -2058,14 +2064,19 @@ class MetalsLspService(
forceImport: Boolean
): Future[BuildChange] = for {
buildTool <- supportedBuildTool()
buildChange <- slowConnectToBuildServer(forceImport, buildTool)
chosenBuildServer = tables.buildServers.selectedServer()
buildChange <- slowConnectToBuildServer(
forceImport,
buildTool,
chosenBuildServer,
)
} yield buildChange

def slowConnectToBuildServer(
forceImport: Boolean,
buildTool: Option[BuildTool.Found],
chosenBuildServer: Option[String],
): Future[BuildChange] = {
val chosenBuildServer = tables.buildServers.selectedServer()
val isBloopOrEmpty = chosenBuildServer.isEmpty || chosenBuildServer.exists(
_ == BloopServers.name
)
Expand Down Expand Up @@ -2323,10 +2334,16 @@ class MetalsLspService(
s"Connected to Build server: ${session.main.name} v${session.version}"
)
cancelables.add(session)
buildTool.foreach(
workspaceReload.persistChecksumStatus(Digest.Status.Started, _)
)
bspSession = Some(session)
for {
_ <- importBuild(session)
_ <- indexer.profiledIndexWorkspace(runDoctorCheck)
_ = buildTool.foreach(
workspaceReload.persistChecksumStatus(Digest.Status.Installed, _)
)
_ = if (session.main.isBloop) checkRunningBloopVersion(session.version)
} yield {
BuildChange.Reconnected
Expand Down

0 comments on commit 7e18b77

Please sign in to comment.