-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Provide a way for debugger variables to include fields that are expensive/have side-effects and can be lazily evaluated #134450
Comments
@DanTup this feature can be easily implemented by representing an "expensive property" as a placeholder object that the user can "expand" to trigger the expensive evaluation. VS Code's built-in js-debug uses this approach for JS/TS getters. Here is an example: class Person {
name = "Danny";
get email(): string {
return "foo@example.bar";
}
get address(): Address {
return new Address();
}
}
class Address {
street = "Main Street";
city = "Zurich";
} ... and here how it looks and behaves: The screencast clearly shows that the intermediate object is a bit noisy and makes it difficult to grasp the effective data structure. But I still think that the approach is the best what a debug adapter can achieve today within DAP's constrains and existing client UIs. Proposal: Instead of inventing new DAP requests I suggest that we try to find a minimal addition (e.g. "a presentation hint") to the Some details:
@connor4312 @roblourens what do you think? |
@weinand that approach sounds good to me :-) |
|
@testforstephen thanks for your great questions:
|
The "lazy" presentationHint sounds good, and benefits from being backwards and forwards-compatible. We can also then move the |
We now have a plan how to implement this. But the implementation will is planned for an upcoming milestone. |
@roblourens I've created (and implemented) a DAP feature request microsoft/debug-adapter-protocol#246 for the new VS Code and the npm modules have been upgraded to include the "lazy" property. And I made Mock Debug return the "lazy" flag for variables that contain the word "lazy" in their name. The "🛌 click me to retrieve value..." is just a placeholder for the UI that VS Code should provide. |
@roblourens I've published a pre-release version (1.49.1) of Mock Debug to the Marketplace. It contains the "lazy flag" support. |
So the adapter sends a variable with It seems like the usage should be spelled out in the DAP more, it's not obvious that they need to return a dummy variable. What does the client do if the adapter sets |
For an |
@roblourens you raise excellent questions
yes, correct.
Agreed. Interestingly some existing debugger extensions already use exactly the proposed approach minus the "lazy" flag. So the existing "variable" request seems to suggest such an approach.
I propose that the client honours the "lazy" flag based on context: if a lazy variable shows up in a tree (e.g. in the debug console or WATCHES view), the client should use the same behavior as in the VARIABLES view. In other contexts (e.g. when copying to clipboard) the client could resolve a lazy variable immediately. |
My thinking is that if I took a specific user action to access that property - adding This means that the Actually, |
On the other hand when you send an "evaluate" request for |
yes, correct.
yes. And the same applies to non-top-level lazy properties of watch/console/hover too.
yes, a debug adapter can either return a "lazy" top-level variable from the
yes, if a "lazy" var has a (placeholder) value, we could show that. And if the value is empty we would omit the lazy var from the inline values. Alternatively we could always omit lazy vars from the inline values completely to avoid the visual noise... |
@DanTup the February release has a first cut of a "lazy variables" feature. It would be great if you could give it a try and provide feedback. What you have to do is explained here. |
@weinand nice! I'll try to take a look soon, thanks! |
Many languages have "properties" on classes that require executing code when executed. Users often want to see these in the debug views (Watch, Variables, Evaluation) but executing them can be expensive and/or produce side-effects.
In Dart, we evaluate these by default but have a setting to turn it off - however it's a little hard to discover this if you don't know where to look.
It would be nice if there was some way to return some "placeholder" variables from a variablesRequest that could require some user-action to evaluate. For example, given the code:
When evaluating
a
, I would like to be able to return a response that includes the value forname
but a lazy placeholder foremail
that the user can trigger to get the value. It should look natural in the UI (eg. not wrapping the value foremail
in some dummy object):The "click to evaluate" could perhaps just trigger evaluation of the
evaluateName
on the variable?This would also potentially allow common some well-known methods like
toString()
to be included in the list without having to execute them (but providing an easy/convenient way for the user to see them).@isidorn @weinand @jacob314
The text was updated successfully, but these errors were encountered: