mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-10 07:41:51 +08:00
Rename fast_parent_copy to deep_ast_copy.
This commit is contained in:
@@ -5,7 +5,7 @@ from jedi.parser import representation as pr
|
|||||||
from jedi import debug
|
from jedi import debug
|
||||||
|
|
||||||
|
|
||||||
def fast_parent_copy(obj, new_elements_default=None):
|
def deep_ast_copy(obj, new_elements_default=None):
|
||||||
"""
|
"""
|
||||||
Much, much faster than copy.deepcopy, but just for Parser elements (Doesn't
|
Much, much faster than copy.deepcopy, but just for Parser elements (Doesn't
|
||||||
copy parents).
|
copy parents).
|
||||||
@@ -132,7 +132,7 @@ def search_call_signatures(user_stmt, position):
|
|||||||
call, arr, index = None, None, 0
|
call, arr, index = None, None, 0
|
||||||
if user_stmt is not None and isinstance(user_stmt, pr.Statement):
|
if user_stmt is not None and isinstance(user_stmt, pr.Statement):
|
||||||
# some parts will of the statement will be removed
|
# some parts will of the statement will be removed
|
||||||
user_stmt = fast_parent_copy(user_stmt)
|
user_stmt = deep_ast_copy(user_stmt)
|
||||||
arr, index, call = call_signature_array_for_pos(user_stmt, position)
|
arr, index, call = call_signature_array_for_pos(user_stmt, position)
|
||||||
|
|
||||||
# Now remove the part after the call. Including the array from the
|
# Now remove the part after the call. Including the array from the
|
||||||
|
|||||||
@@ -509,7 +509,7 @@ class FunctionExecution(Executed):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, evaluator, base, *args, **kwargs):
|
def __init__(self, evaluator, base, *args, **kwargs):
|
||||||
super(FunctionExecution, self).__init__(evaluator, base, *args, **kwargs)
|
super(FunctionExecution, self).__init__(evaluator, base, *args, **kwargs)
|
||||||
# for fast_parent_copy
|
# for deep_ast_copy
|
||||||
self._copy_dict = {base.base_func: self}
|
self._copy_dict = {base.base_func: self}
|
||||||
|
|
||||||
@memoize_default(default=())
|
@memoize_default(default=())
|
||||||
@@ -579,7 +579,7 @@ class FunctionExecution(Executed):
|
|||||||
objects = []
|
objects = []
|
||||||
for element in lst:
|
for element in lst:
|
||||||
self._scope_copy(element.parent)
|
self._scope_copy(element.parent)
|
||||||
copied = helpers.fast_parent_copy(element, self._copy_dict)
|
copied = helpers.deep_ast_copy(element, self._copy_dict)
|
||||||
objects.append(copied)
|
objects.append(copied)
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
@@ -593,7 +593,7 @@ class FunctionExecution(Executed):
|
|||||||
if scope != self.base.base_func:
|
if scope != self.base.base_func:
|
||||||
# Just make sure the parents been copied.
|
# Just make sure the parents been copied.
|
||||||
self._scope_copy(scope.parent)
|
self._scope_copy(scope.parent)
|
||||||
helpers.fast_parent_copy(scope, self._copy_dict)
|
helpers.deep_ast_copy(scope, self._copy_dict)
|
||||||
|
|
||||||
@common.safe_property
|
@common.safe_property
|
||||||
@memoize_default([])
|
@memoize_default([])
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
from jedi.evaluate.helpers import fast_parent_copy
|
from jedi.evaluate.helpers import deep_ast_copy
|
||||||
from jedi.parser import representation as pr
|
from jedi.parser import representation as pr
|
||||||
|
|
||||||
|
|
||||||
def test_fast_parent_copy():
|
def test_deep_ast_copy():
|
||||||
name = pr.Name(object, [('hallo', (0, 0))], (0, 0), (0, 0))
|
name = pr.Name(object, [('hallo', (0, 0))], (0, 0), (0, 0))
|
||||||
|
|
||||||
# fast parent copy should switch parent
|
# fast parent copy should switch parent
|
||||||
new_name = fast_parent_copy(name)
|
new_name = deep_ast_copy(name)
|
||||||
assert new_name.names[0].parent == new_name
|
assert new_name.names[0].parent == new_name
|
||||||
|
|||||||
Reference in New Issue
Block a user