forked from VimPlug/jedi
Fix one of the really hard issues: deep_ast_copy didn't copy the newly created _names_dict.
This commit is contained in:
@@ -51,6 +51,8 @@ def deep_ast_copy(obj, new_elements_default=None):
|
|||||||
# because there are several references that don't walk the whole
|
# because there are several references that don't walk the whole
|
||||||
# tree in there.
|
# tree in there.
|
||||||
items = sorted(items, key=sort_stmt)
|
items = sorted(items, key=sort_stmt)
|
||||||
|
else:
|
||||||
|
items = sorted(items, key=lambda x: x[0] == '_names_dict')
|
||||||
|
|
||||||
# Actually copy and set attributes.
|
# Actually copy and set attributes.
|
||||||
new_obj = copy.copy(obj)
|
new_obj = copy.copy(obj)
|
||||||
@@ -68,13 +70,17 @@ def deep_ast_copy(obj, new_elements_default=None):
|
|||||||
pass
|
pass
|
||||||
elif key in ['parent_function', 'use_as_parent', '_sub_module']:
|
elif key in ['parent_function', 'use_as_parent', '_sub_module']:
|
||||||
continue
|
continue
|
||||||
|
elif key == '_names_dict':
|
||||||
|
d = dict((k, sequence_recursion(v)) for k, v in value.items())
|
||||||
|
setattr(new_obj, key, d)
|
||||||
elif isinstance(value, (list, tuple)):
|
elif isinstance(value, (list, tuple)):
|
||||||
setattr(new_obj, key, list_or_tuple_rec(value))
|
setattr(new_obj, key, sequence_recursion(value))
|
||||||
elif isinstance(value, accept):
|
elif isinstance(value, accept):
|
||||||
setattr(new_obj, key, recursion(value))
|
setattr(new_obj, key, recursion(value))
|
||||||
|
|
||||||
return new_obj
|
return new_obj
|
||||||
|
|
||||||
def list_or_tuple_rec(array_obj):
|
def sequence_recursion(array_obj):
|
||||||
if isinstance(array_obj, tuple):
|
if isinstance(array_obj, tuple):
|
||||||
copied_array = list(array_obj)
|
copied_array = list(array_obj)
|
||||||
else:
|
else:
|
||||||
@@ -83,7 +89,7 @@ def deep_ast_copy(obj, new_elements_default=None):
|
|||||||
if isinstance(el, accept):
|
if isinstance(el, accept):
|
||||||
copied_array[i] = recursion(el)
|
copied_array[i] = recursion(el)
|
||||||
elif isinstance(el, (tuple, list)):
|
elif isinstance(el, (tuple, list)):
|
||||||
copied_array[i] = list_or_tuple_rec(el)
|
copied_array[i] = sequence_recursion(el)
|
||||||
|
|
||||||
if isinstance(array_obj, tuple):
|
if isinstance(array_obj, tuple):
|
||||||
return tuple(copied_array)
|
return tuple(copied_array)
|
||||||
|
|||||||
Reference in New Issue
Block a user