You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Evaluate requests contains not listed context "variables" #233
Question1: Is it intentional not to list the variable context?
Question2: Why not passes variable name in expression if it means to get the result of "variable"? On Ruby language, sometimes the representation of the value becomes "#<Object:...> like above and it is not evaluate-able expression (and this is why I stop to support supportsClipboardContext).
Answer1: not including the variables context value in DAP was "somewhat intentional" but is still an omission we should fix. Here is the full story:
The variables context value is used whenever the evaluate request is used from a "variables" context, e.g. a view showing variables. Since clients typically populate a "variables view" by using the variables request, there are not many situations where an evaluate request is actually used from the "variables view": VS Code was using an evaluate(context: variables) request" only for the "Copy Value" command available for variables. When we added the "Copy Value" command we noticed that a context value variables is not really that helpful when implementing a debug adapter (DA). That's the reason why we introduced the clipboard context which eliminated the last reason for having a variables context.
However, because DAP needs to be backward compatible, we had to protect the clipboard context behind the supportsClipboardContext capability which makes it possible that a DA still sees the unspecified variables context value...
I propose to add the variables context to DAP with the following description:
/** * The context in which the evaluate request is run. * Values: * 'variables': evaluate is run in a variables view. * 'watch': evaluate is run in a watch. * 'repl': evaluate is run from REPL console. * 'hover': evaluate is run from a data hover. * 'clipboard': evaluate is run to generate the value that will be stored in * the clipboard. The attribute is only honored by a debug adapter if the capability * 'supportsClipboardContext' is true. * etc. */
context?: 'variables'|'watch'|'repl'|'hover'|'clipboard'|string;
Answer2:
The Variable.evaluateName property determines what gets passed to the evaluate request. If the property exists it is passed as the expression argument. Otherwise the variable's name will be passed .
I suggest that you always set Variable.evaluateName to something that evaluates to the variable's value.
I propose to add the variables context to DAP with the following description:
Except, now this is not backward compatible... adding a value without adding a capability (the exact reason the new 'clipboard' value was protected by a capability!). Wouldn't it be better if clients currently sending this value just ... stop sending it as there's no legitimate reason for servers to be interpreting that undocumented out of protocol value?
Since context is of type string, I do not see the "backward compatible" argument: any DA has to deal with arbitrary strings anyway. Clients do not have to do anything for adopting this "change".
Adding variables just documents what existing client(s) do anyway.
We cannot ask existing clients to stop using variables because that might be breaking.
We cannot add a supportsVariablesContext for an already used variables context value because old clients will continue to pass the variables context value without checking the capability.
The final description for the context property is:
/** The context in which the evaluate request is used.
Values:
'variables': evaluate is called from a variables view context.
'watch': evaluate is called from a watch view context.
'repl': evaluate is called from a REPL context.
'hover': evaluate is called to generate the debug hover contents.
This value should only be used if the capability 'supportsEvaluateForHovers' is true.
'clipboard': evaluate is called to generate clipboard contents.
This value should only be used if the capability 'supportsClipboardContext' is true.
etc.
*/
context?: 'variables' | 'watch' | 'repl' | 'hover' | 'clipboard' | string;
Activity
weinand commentedon Mar 8, 2022
Koichi Sasada (@ko1) thanks for the request.
Answer1: not including the
variablescontext value in DAP was "somewhat intentional" but is still an omission we should fix. Here is the full story:The
variablescontext value is used whenever theevaluaterequest is used from a "variables" context, e.g. a view showing variables. Since clients typically populate a "variables view" by using thevariablesrequest, there are not many situations where anevaluaterequest is actually used from the "variables view": VS Code was using anevaluate(context: variables)request" only for the "Copy Value" command available for variables. When we added the "Copy Value" command we noticed that a context valuevariablesis not really that helpful when implementing a debug adapter (DA). That's the reason why we introduced theclipboardcontext which eliminated the last reason for having avariablescontext.However, because DAP needs to be backward compatible, we had to protect the
clipboardcontext behind thesupportsClipboardContextcapability which makes it possible that a DA still sees the unspecifiedvariablescontext value...I propose to add the
variablescontext to DAP with the following description:Answer2:
The
Variable.evaluateNameproperty determines what gets passed to theevaluaterequest. If the property exists it is passed as theexpressionargument. Otherwise the variable's name will be passed .I suggest that you always set
Variable.evaluateNameto something that evaluates to the variable's value.puremourning commentedon Mar 8, 2022
Except, now this is not backward compatible... adding a value without adding a capability (the exact reason the new 'clipboard' value was protected by a capability!). Wouldn't it be better if clients currently sending this value just ... stop sending it as there's no legitimate reason for servers to be interpreting that undocumented out of protocol value?
weinand commentedon Mar 8, 2022
Since
contextis of type string, I do not see the "backward compatible" argument: any DA has to deal with arbitrary strings anyway. Clients do not have to do anything for adopting this "change".Adding
variablesjust documents what existing client(s) do anyway.We cannot ask existing clients to stop using
variablesbecause that might be breaking.We cannot add a
supportsVariablesContextfor an already usedvariablescontext value because old clients will continue to pass thevariablescontext value without checking the capability.weinand commentedon Mar 10, 2022
The final description for the
contextproperty is: