From 5575a36eb2246053fcf2118b5ec0d98bf515df0c Mon Sep 17 00:00:00 2001 From: kasiaMarek Date: Wed, 11 Dec 2024 15:29:13 +0100 Subject: [PATCH] improvement: by default support `scala-cli` power options --- .../scala/meta/internal/bsp/BspServers.scala | 2 +- .../meta/internal/metals/scalacli/ScalaCli.scala | 2 +- .../test/scala/tests/scalacli/ScalaCliSuite.scala | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/bsp/BspServers.scala b/metals/src/main/scala/scala/meta/internal/bsp/BspServers.scala index 284a5923e29..f6c24faf6c8 100644 --- a/metals/src/main/scala/scala/meta/internal/bsp/BspServers.scala +++ b/metals/src/main/scala/scala/meta/internal/bsp/BspServers.scala @@ -119,7 +119,7 @@ final class BspServers( args, projectDirectory, redirectErrorOutput = false, - variables, + variables + ("SCALA_CLI_POWER" -> "true"), processOut = None, processErr = Some(l => scribe.info("BSP server: " + l)), discardInput = false, diff --git a/metals/src/main/scala/scala/meta/internal/metals/scalacli/ScalaCli.scala b/metals/src/main/scala/scala/meta/internal/metals/scalacli/ScalaCli.scala index 164c36f6508..7117e1c58b3 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/scalacli/ScalaCli.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/scalacli/ScalaCli.scala @@ -243,7 +243,7 @@ object ScalaCli { command.toList, workspace, redirectErrorOutput = false, - env = Map(), + env = Map("SCALA_CLI_POWER" -> "true"), processOut = None, processErr = Some(line => scribe.info("Scala CLI: " + line)), discardInput = false, diff --git a/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala b/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala index ce477c7ec25..f5b02a550cb 100644 --- a/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala +++ b/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala @@ -782,4 +782,19 @@ class ScalaCliSuite extends BaseScalaCliSuite("3.3.3") { _ = assertNoDiff(completion, "com.lihaoyi") } yield () } + + test("power-option") { + cleanWorkspace() + for { + _ <- scalaCliInitialize(useBsp = true)( + s"""|/MyTests.scala + |//> using scala ${scalaVersion} + |//> using packaging.dockerFrom openjdk:17 + | + |def main() = println("Hello world!") + |""".stripMargin + ) + _ <- server.didOpen("MyTests.scala") + } yield assertNoDiagnostics() + } }