From 58827440416159ec9170af5b2730f861cd3543ed Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Mon, 27 May 2024 13:13:06 +0200 Subject: [PATCH] bugfix: Use actual method arguments from DAP server interface Previously we would use LaunchRequestArguments, but those are actually not used and what is actually returned is a Map. This become a problem after the fix that deserialized arguments to correct params. Now, we use Map instead. Raised the issue here https://github.com/eclipse-lsp4j/lsp4j/issues/842 Also fixed tests to use newest toolkit instead. --- .../scala/meta/internal/metals/Compilers.scala | 1 - .../internal/metals/debug/DebugProtocol.scala | 16 ++++++++++------ .../scala/tests/scalacli/ScalaCliSuite.scala | 12 ++++++++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/metals/Compilers.scala b/metals/src/main/scala/scala/meta/internal/metals/Compilers.scala index 071b2170aae..ae4fb2a44ee 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Compilers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Compilers.scala @@ -104,7 +104,6 @@ class Compilers( mtagsResolver, sourceMapper, ) - import compilerConfiguration._ private val outlineFilesProvider = diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProtocol.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProtocol.scala index ad1397bfd93..ce9399b1ed9 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProtocol.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProtocol.scala @@ -12,7 +12,6 @@ import com.google.gson.JsonElement import org.eclipse.lsp4j.debug.CompletionsArguments import org.eclipse.lsp4j.debug.DisconnectArguments import org.eclipse.lsp4j.debug.InitializeRequestArguments -import org.eclipse.lsp4j.debug.LaunchRequestArguments import org.eclipse.lsp4j.debug.OutputEventArguments import org.eclipse.lsp4j.debug.SetBreakpointsArguments import org.eclipse.lsp4j.debug.SetBreakpointsResponse @@ -137,11 +136,16 @@ object DebugProtocol { object LaunchRequest { def unapply(request: DebugRequestMessage): Option[DebugMode] = { if (request.getMethod != "launch") None - else - parse[LaunchRequestArguments](request.getParams).toOption.map { - case args if args.getNoDebug => DebugMode.Disabled - case _ => DebugMode.Enabled - } + else { + parse[java.util.Map[String, Object]](request.getParams).toOption + .map { map => + map.asScala.get("noDebug") match { + case Some(value: java.lang.Boolean) if value => DebugMode.Disabled + case Some(value: java.lang.Boolean) if !value => DebugMode.Enabled + case _ => DebugMode.Enabled + } + } + } } } diff --git a/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala b/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala index 2a40cefda0f..958bd0076e6 100644 --- a/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala +++ b/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala @@ -12,6 +12,7 @@ import scala.meta.internal.metals.ServerCommands import scala.meta.internal.metals.debug.TestDebugger import scala.meta.internal.metals.scalacli.ScalaCli import scala.meta.internal.metals.{BuildInfo => V} +import scala.meta.internal.mtags.CoursierComplete import org.eclipse.{lsp4j => l} import tests.FileLayout @@ -472,14 +473,21 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) { } yield () } + val coursierComplete = new CoursierComplete(scalaVersion) + val newestToolkit: String = coursierComplete + .complete("org.scala-lang::toolkit:") + .headOption + .map(_.split(":").last) + .getOrElse("default") + test("properly-reindex") { cleanWorkspace() server.client.importBuild = Messages.ImportBuild.yes for { _ <- scalaCliInitialize(useBsp = true)( s"""|/Main.scala - |//> using scala 2.13.11 - |// > using toolkit default + |//> using scala ${scalaVersion} + |// > using toolkit ${newestToolkit} | |object Main { | println(os.pwd)