Metals: Cannot "watch" expression when debugging

Created on 16 Jan 2020  路  3Comments  路  Source: scalameta/metals

_WATCH_ section does not display values for variables available in the scope.

To Reproduce Steps to reproduce the behavior:

  1. Create simple Scala program with some values defined
  2. Put a breakpoint
  3. Start simple scala program in _DEBUG_ mode
  4. When breakpoint reached try to add some variables from the scope to _WATCH_

Variables added in the _WATCH_ section should have values.

Screenshots

watch-not-working

The same program in Intellij IDEA

idea-works

Installation:

  • Operating system: macOS
  • VSCode version: 1.41.1
  • VSCode extension version: 1.7.2
  • Metals version: (found in VSCode settings, under metals.serverVersion) 0.8.0

Additional context

Maybe it is related to App usage in program.

Search terms

metals, debug, watch

debug

Most helpful comment

To summarize: "watch" functionality is not yet implemented so the watch expressions won't be evaluated, hence the an implementation is missing log. What we probably should do is to provide more informative information like evaluation of expression is not implemented.

As to the other part:

Value from the object can be seen inside the this value, but it should also be outside, which I believe is a bug.

It is not a bug, but rather a reflection of how the App is implemented. We can see the same behavior in IntelliJ on the screenshot above: only this variable is in scope (and two watches but they are not related) - we could probably provide some custom handling to "extract" the variables to the outer scope for Apps but I don't think it is worth the effort. Once we have expression evaluation, user will be able to "watch" the fields of interest.

All 3 comments

@vadeg watch is currently not implemented and is connected to the DAP extension here: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Evaluate

Value from the object can be seen inside the this value, but it should also be outside, which I believe is a bug.

To summarize: "watch" functionality is not yet implemented so the watch expressions won't be evaluated, hence the an implementation is missing log. What we probably should do is to provide more informative information like evaluation of expression is not implemented.

As to the other part:

Value from the object can be seen inside the this value, but it should also be outside, which I believe is a bug.

It is not a bug, but rather a reflection of how the App is implemented. We can see the same behavior in IntelliJ on the screenshot above: only this variable is in scope (and two watches but they are not related) - we could probably provide some custom handling to "extract" the variables to the outer scope for Apps but I don't think it is worth the effort. Once we have expression evaluation, user will be able to "watch" the fields of interest.

Thanks @marek1840 ! I will close it since it's working as intended.

Was this page helpful?
0 / 5 - 0 ratings