From 7e18b776b3175fe87f393164b7b04cbedc24ad61 Mon Sep 17 00:00:00 2001 From: Katarzyna Marek Date: Thu, 9 Nov 2023 11:22:36 +0100 Subject: [PATCH] test fixes --- .../meta/internal/bsp/BspConnector.scala | 4 ++- .../internal/metals/MetalsLspService.scala | 27 +++++++++++++++---- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala b/metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala index 103a69407ea..439aa19c85a 100644 --- a/metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala +++ b/metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala @@ -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 diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala index 67c3c228086..49c7988ee85 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala @@ -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 @@ -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 () @@ -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 ) @@ -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