The scala-debug-adapter is an implementation of the Debug Adapter Protocol for Scala. It allows users of VSCode to debug their Scala programs, using features such as breakpoints, conditional breakpoints, debug console, log-points and more.
Some of these features depends on the ability to evaluate expression at runtime: we pause the program at some instruction and we evaluate an expression to inspect its state. At the current stage, we have an expression evaluator that depends heavily on the Scala compiler: it recompiles the entire source file in which we inserted the expression. This is very precise but slow and not very flexible.
As an alternative we would like to build an evaluator that is based on scalameta. Scalameta is a parser of scala code: it parses Scala code into syntax trees. We parse the expression, check that it is valid using runtime reflection on the current state of the program, then evaluate by calling methods and accessing fields using runtime calls.
Such evaluator would be faster and more flexible:
It can evaluate expression even if the source file is not found (shaded jar)
It can evaluate expression in Java or Kotlin file
It can access private fields and methods
It can see through abstract types without casting
However it can only evaluate simple expressions made of field accesses and method calls. It won't be able to do pattern matching or implicit resolution. We will still use the compiler-based evaluator to evaluate more high-level Scala expressions.
Supervisor
Adrien Piquerez(adrien.piquerez@epfl.ch): Tooling Engineer at the Scala Center
Description
The scala-debug-adapter is an implementation of the Debug Adapter Protocol for Scala. It allows users of VSCode to debug their Scala programs, using features such as breakpoints, conditional breakpoints, debug console, log-points and more.
Some of these features depends on the ability to evaluate expression at runtime: we pause the program at some instruction and we evaluate an expression to inspect its state. At the current stage, we have an expression evaluator that depends heavily on the Scala compiler: it recompiles the entire source file in which we inserted the expression. This is very precise but slow and not very flexible.
As an alternative we would like to build an evaluator that is based on scalameta. Scalameta is a parser of scala code: it parses Scala code into syntax trees. We parse the expression, check that it is valid using runtime reflection on the current state of the program, then evaluate by calling methods and accessing fields using runtime calls.
Such evaluator would be faster and more flexible:
However it can only evaluate simple expressions made of field accesses and method calls. It won't be able to do pattern matching or implicit resolution. We will still use the compiler-based evaluator to evaluate more high-level Scala expressions.
Supervisor
Adrien Piquerez(adrien.piquerez@epfl.ch): Tooling Engineer at the Scala Center
Prerequisites