(The Scala Center team is dedicated to providing regular and transparent community updates about project plans & progress. In this forum we created a new topic category to allow quicker orientation going forward: “Scala Center Updates”. Even though all feedback is welcome, we keep the right to make executive decisions about projects we lead. Overview of all our activities can always be found at Scala Center Public Records)
A good debugging experience makes programming more approachable. It guides programmers through the internals of a program and helps them find bugs.
How can we bring support for debugging Scala in the many code editors of the modern days?
The Debug Adapter Protocol (DAP) is here to help. It is one of those protocols, like LSP and BSP, that abstracts over a feature, in our case debugging, to reduce the integration effort.
The goal of this project is to provide a common implementation of the DAP server for Scala on the JVM.
A first implementation of the DAP server for Scala was made in Bloop, based on the Microsoft Java Debugger project. It is since used by Metals to start a debug session, when the user clicks the run, test or debug button.
We decided to extract this implementation out of Bloop so that it can be reused by other build tools of the ecosystem. This new library is called the scala-debug-adpater and it was first released in February 2021.
It is not a standalone tool because it must be hosted by a build tool that is able to configure the classpath and link each source to its class files.
Integration in sbt
The sbt-debug-adapter is an sbt plugin that augments the sbt server with the DAP capability by using the scala-debug-adapter library. It is compatible with sbt 1.4.x and greater.
Concretely, it makes it possible to debug an sbt project inside Metals using the sbt server.
It is added automatically by Metals, so you do not need to install it manually. Just open Metals, switch to sbt build server and click the debug button.
Special thanks to @er1c who motivated this project and contributed to it.
The integration of the scala-debug-adapter in Mill is a Google Summer of Code project for this year.
Scala 3 support should come out-of-the-box but we will add more tests and identify bugs or limitations.
Any comment, feedback or suggestion is welcomed. The scala-debug-adpater is also open for contributions.
Would it be desirable to support Scala.js? How to implement it? If you have an idea on these questions, please share with us.