Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate expression using scalameta in the debugger #9

Closed
adpi2 opened this issue Nov 15, 2022 · 0 comments · Fixed by scalacenter/scala-debug-adapter#405
Closed

Evaluate expression using scalameta in the debugger #9

adpi2 opened this issue Nov 15, 2022 · 0 comments · Fixed by scalacenter/scala-debug-adapter#405

Comments

@adpi2
Copy link
Member

adpi2 commented Nov 15, 2022

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:

  • 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

Prerequisites

  • Some experience with Scala
  • Some knowledge about Java reflection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants