diff --git a/metals/src/main/scala/scala/meta/internal/builds/BazelBuildTool.scala b/metals/src/main/scala/scala/meta/internal/builds/BazelBuildTool.scala index 0087542dbf1..1695b3e75e3 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/BazelBuildTool.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/BazelBuildTool.scala @@ -1,5 +1,6 @@ package scala.meta.internal.builds +import scala.meta.internal.metals.BuildInfo import scala.meta.internal.metals.JavaBinary import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.internal.metals.UserConfiguration @@ -7,7 +8,6 @@ import scala.meta.io.AbsolutePath import coursierapi.Dependency import coursierapi.Fetch -import scala.meta.internal.metals.BuildInfo case class BazelBuildTool( userConfig: () => UserConfiguration, diff --git a/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala b/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala index 14db0a6943c..ee1dc909a73 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala @@ -261,11 +261,11 @@ final class Compilations( val originId = "METALS-$" + UUID.randomUUID().toString val params = new b.CompileParams(targets.asJava) params.setOriginId(originId) - if ( - userConfiguration().verboseCompilation && (connection.isBloop || connection.isScalaCLI) - ) { - params.setArguments(List("--verbose", "--best-effort").asJava) - } else { params.setArguments(List("--best-effort").asJava) } + if (connection.isBloop || connection.isScalaCLI) { + if (userConfiguration().verboseCompilation) + params.setArguments(List("--verbose", "--best-effort").asJava) + else params.setArguments(List("--best-effort").asJava) + } targets.foreach { target => isCompiling(target) = true } diff --git a/tests/slow/src/test/scala/tests/bazel/BazelLspSuite.scala b/tests/slow/src/test/scala/tests/bazel/BazelLspSuite.scala index 2f1fd0cb7f8..2d19c6253c1 100644 --- a/tests/slow/src/test/scala/tests/bazel/BazelLspSuite.scala +++ b/tests/slow/src/test/scala/tests/bazel/BazelLspSuite.scala @@ -28,6 +28,7 @@ class BazelLspSuite val buildTool: BazelBuildTool = BazelBuildTool(() => userConfig, workspace) val bazelVersion = "6.4.0" + val bazel7Version = "7.3.0" def bazelBspConfig: AbsolutePath = workspace.resolve(".bsp/bazelbsp.json") @@ -38,55 +39,57 @@ class BazelLspSuite val importMessage: String = GenerateBspAndConnect.params("bazel", "bazelbsp").getMessage() - test("basic") { - cleanWorkspace() - for { - _ <- initialize( - BazelBuildLayout(workspaceLayout, V.bazelScalaVersion, bazelVersion) - ) - _ = assertNoDiff( - client.workspaceMessageRequests, - List( - importMessage - ).mkString("\n"), - ) - _ = assert(bazelBspConfig.exists) - _ = client.messageRequests.clear() // restart - _ = assertStatus(_.isInstalled) - _ = assertNoDiff(client.workspaceDiagnostics, "") - _ <- server.didChange("WORKSPACE")(_ + "\n# comment") - _ <- server.didSave("WORKSPACE")(identity) - // Comment changes do not trigger "re-import project" request - _ = assertNoDiff(client.workspaceMessageRequests, "") - _ <- server.didChange("Hello.scala") { text => - text.replace("def hello: String", "def hello: Int") - } - _ <- server.didSave("Hello.scala")(identity) - _ = assertNoDiff( - client.workspaceDiagnostics, - """|Hello.scala:4:20: error: type mismatch; - | found : String("Hello") - | required: Int - | def hello: Int = "Hello" - | ^ - | def hello: Int = "Hello" - | ^ - |""".stripMargin, - ) - _ <- server.didChange(s"BUILD") { text => - text.replace("\"hello\"", "\"hello1\"") + for (bazelVersion <- List(bazelVersion, bazel7Version)) { + test(s"basic-$bazelVersion") { + cleanWorkspace() + for { + _ <- initialize( + BazelBuildLayout(workspaceLayout, V.bazelScalaVersion, bazelVersion) + ) + _ = assertNoDiff( + client.workspaceMessageRequests, + List( + importMessage + ).mkString("\n"), + ) + _ = assert(bazelBspConfig.exists) + _ = client.messageRequests.clear() // restart + _ = assertStatus(_.isInstalled) + _ = assertNoDiff(client.workspaceDiagnostics, "") + _ <- server.didChange("WORKSPACE")(_ + "\n# comment") + _ <- server.didSave("WORKSPACE")(identity) + // Comment changes do not trigger "re-import project" request + _ = assertNoDiff(client.workspaceMessageRequests, "") + _ <- server.didChange("Hello.scala") { text => + text.replace("def hello: String", "def hello: Int") + } + _ <- server.didSave("Hello.scala")(identity) + _ = assertNoDiff( + client.workspaceDiagnostics, + """|Hello.scala:4:20: error: type mismatch; + | found : String("Hello") + | required: Int + | def hello: Int = "Hello" + | ^ + | def hello: Int = "Hello" + | ^ + |""".stripMargin, + ) + _ <- server.didChange(s"BUILD") { text => + text.replace("\"hello\"", "\"hello1\"") + } + _ = assertNoDiff(client.workspaceMessageRequests, "") + _ = client.generateBspAndConnect = GenerateBspAndConnect.yes + _ <- server.didSave(s"BUILD")(identity) + } yield { + assertNoDiff( + client.workspaceMessageRequests, + List( + importBuildChangesMessage + ).mkString("\n"), + ) + server.assertBuildServerConnection() } - _ = assertNoDiff(client.workspaceMessageRequests, "") - _ = client.generateBspAndConnect = GenerateBspAndConnect.yes - _ <- server.didSave(s"BUILD")(identity) - } yield { - assertNoDiff( - client.workspaceMessageRequests, - List( - importBuildChangesMessage - ).mkString("\n"), - ) - server.assertBuildServerConnection() } }