Skip to content

Commit

Permalink
Add source mapping to support ipython cells. Fixes microsoft#1503
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Jul 4, 2019
1 parent 27e6388 commit a04648a
Show file tree
Hide file tree
Showing 25 changed files with 1,421 additions and 287 deletions.
9 changes: 8 additions & 1 deletion src/ptvsd/_vendored/pydevd/_pydev_bundle/pydev_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ def exception(msg='', *args):


def error_once(msg, *args):
message = msg % args
try:
if args:
message = msg % args
else:
message = str(msg)
except:
message = '%s - %s' % (msg, args)

if message not in WARN_ONCE_MAP:
WARN_ONCE_MAP[message] = True
critical(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def create_classes_to_generate_structure(json_schema_data):
properties.update(definition.get('properties', {}))
required.update(_OrderedSet(definition.get('required', _OrderedSet())))

if isinstance(description, (list, tuple)):
description = '\n'.join(description)

class_to_generatees[name] = dict(
name=name,
properties=properties,
Expand Down Expand Up @@ -279,6 +282,10 @@ def update_class_to_generate_to_json(class_to_generate):
namespace = dict(prop_name=prop_name, noqa=_get_noqa_for_var(prop_name))
to_dict_body.append(' %(prop_name)s = self.%(prop_name)s%(noqa)s' % namespace)

if prop.get('type') == 'array':
to_dict_body.append(' if %(prop_name)s and hasattr(%(prop_name)s[0], "to_dict"):' % namespace)
to_dict_body.append(' %(prop_name)s = [x.to_dict() for x in %(prop_name)s]' % namespace)

if translate_prop_names:
to_dict_body.append(' if update_ids_to_dap:')
for prop_name in translate_prop_names:
Expand Down Expand Up @@ -412,6 +419,9 @@ def update_class_to_generate_init(class_to_generate):
prop_type = prop['type']
prop_description = prop.get('description', '')

if isinstance(prop_description, (list, tuple)):
prop_description = '\n '.join(prop_description)

docstring.append(':param %(prop_type)s %(prop_name)s: %(prop_description)s' % dict(
prop_type=prop_type, prop_name=prop_name, prop_description=prop_description))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,77 @@
}]
},

"SetPydevdSourceMapRequest": {
"allOf": [ { "$ref": "#/definitions/Request" }, {
"type": "object",
"description": [
"Sets multiple PydevdSourceMap for a single source and clears all previous PydevdSourceMap in that source.",
"i.e.: Maps paths and lines in a 1:N mapping (use case: map a single file in the IDE to multiple IPython cells).",
"To clear all PydevdSourceMap for a source, specify an empty array.",
"Interaction with breakpoints: When a new mapping is sent, breakpoints that match the source (or previously matched a source) are reapplied.",
"Interaction with launch pathMapping: both mappings are independent. This mapping is applied after the launch pathMapping."
],
"properties": {
"command": {
"type": "string",
"enum": [ "setPydevdSourceMap" ]
},
"arguments": {
"$ref": "#/definitions/SetPydevdSourceMapArguments"
}
},
"required": [ "command", "arguments" ]
}]
},
"SetPydevdSourceMapArguments": {
"type": "object",
"description": "Arguments for 'setPydevdSourceMap' request.",
"properties": {
"source": {
"$ref": "#/definitions/Source",
"description": "The source location of the PydevdSourceMap; 'source.path' must be specified (e.g.: for an ipython notebook this could be something as /home/notebook/note.py)."
},
"pydevdSourceMaps": {
"type": "array",
"items": {
"$ref": "#/definitions/PydevdSourceMap"
},
"description": "The PydevdSourceMaps to be set to the given source (provide an empty array to clear the source mappings for a given path)."
}
},
"required": [ "source", "pydevdSourceMap" ]
},
"SetPydevdSourceMapResponse": {
"allOf": [ { "$ref": "#/definitions/Response" }, {
"type": "object",
"description": "Response to 'setPydevdSourceMap' request. This is just an acknowledgement, so no body field is required."
}]
},

"PydevdSourceMap": {
"type": "object",
"description": "Information that allows mapping a local line to a remote source/line.",
"properties": {
"line": {
"type": "integer",
"description": "The local line to which the mapping should map to (e.g.: for an ipython notebook this would be the first line of the cell in the file)."
},
"endLine": {
"type": "integer",
"description": "The end line."
},
"runtimeSource": {
"$ref": "#/definitions/Source",
"description": "The path that the user has remotely -- 'source.path' must be specified (e.g.: for an ipython notebook this could be something as '<ipython-input-1-4561234>')"
},
"runtimeLine": {
"type": "integer",
"description": "The remote line to which the mapping should map to (e.g.: for an ipython notebook this would be always 1 as it'd map the start of the cell)."
}
},
"required": ["line", "endLine", "runtimeSource", "runtimeLine"]
},

"PydevdSystemInfoRequest": {
"allOf": [ { "$ref": "#/definitions/Request" }, {
"type": "object",
Expand Down
Loading

0 comments on commit a04648a

Please sign in to comment.