Skip to content

Commit

Permalink
bugfix: Use actual method arguments from DAP server interface
Browse files Browse the repository at this point in the history
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 eclipse-lsp4j/lsp4j#842

Also fixed tests to use newest toolkit instead.
  • Loading branch information
tgodzik committed May 27, 2024
1 parent 5b582c6 commit 5882744
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class Compilers(
mtagsResolver,
sourceMapper,
)

import compilerConfiguration._

private val outlineFilesProvider =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5882744

Please sign in to comment.