Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Resolve #12: Arbitrary expression evaluation #42

Merged
merged 1 commit into from
Feb 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ptvsd/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,31 @@ def on_setVariable(self, request, args):
response['variablesReference'] = vsc_var
self.send_response(request, **response)

@async_handler
def on_evaluate(self, request, args):
# pydevd message format doesn't permit tabs in expressions
expr = args['expression'].replace('\t', ' ')

vsc_fid = int(args['frameId'])
pyd_tid, pyd_fid = self.frame_map.to_pydevd(vsc_fid)

cmd_args = (pyd_tid, pyd_fid, 'LOCAL', expr, '1')
_, _, resp_args = yield self.pydevd_request(
pydevd_comm.CMD_EVALUATE_EXPRESSION,
'\t'.join(str(s) for s in cmd_args))
xml = untangle.parse(resp_args).xml
xvar = xml.var

pyd_var = (pyd_tid, pyd_fid, 'EXPRESSION', expr)
vsc_var = self.var_map.to_vscode(pyd_var)
response = {
'type': unquote(xvar['type']),
'result': unquote(xvar['value']),
}
if bool(xvar['isContainer']):
response['variablesReference'] = vsc_var
self.send_response(request, **response)

@async_handler
def on_pause(self, request, args):
# TODO: docstring
Expand Down