forked from VimPlug/jedi
simple function tests pass now
This commit is contained in:
@@ -372,8 +372,8 @@ def find_name(scope, name_str, position=None, search_global=False,
|
|||||||
if not result and isinstance(nscope, er.Instance):
|
if not result and isinstance(nscope, er.Instance):
|
||||||
# __getattr__ / __getattribute__
|
# __getattr__ / __getattribute__
|
||||||
result += check_getattr(nscope, name_str)
|
result += check_getattr(nscope, name_str)
|
||||||
debug.dbg('sfn filter "%s" in (%s-%s): %s@%s' % (name_str, nscope,
|
debug.dbg('sfn filter "%s" in (%s-%s): %s@%s' % (name_str, scope,
|
||||||
scope, result, position))
|
nscope, result, position))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def descriptor_check(result):
|
def descriptor_check(result):
|
||||||
@@ -632,7 +632,7 @@ def follow_call_list(call_list, follow_array=False):
|
|||||||
def follow_call(call):
|
def follow_call(call):
|
||||||
"""Follow a call is following a function, variable, string, etc."""
|
"""Follow a call is following a function, variable, string, etc."""
|
||||||
path = call.generate_call_path()
|
path = call.generate_call_path()
|
||||||
scope = call.get_parent_until(pr.Scope)
|
scope = call.get_parent_until((pr.Scope, er.Execution))
|
||||||
return follow_call_path(path, scope, call.start_pos)
|
return follow_call_path(path, scope, call.start_pos)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -501,14 +501,16 @@ class Execution(Executable):
|
|||||||
else:
|
else:
|
||||||
parent = self.base
|
parent = self.base
|
||||||
start_pos = None
|
start_pos = None
|
||||||
calls = pr.Array(start_pos, pr.Array.NOARRAY, parent)
|
# create an Array (-> container for the statement)
|
||||||
calls.values = values
|
arr = pr.Array(self.module, start_pos, pr.Array.NOARRAY, parent)
|
||||||
calls.keys = keys
|
arr.values = values
|
||||||
calls.type = array_type
|
arr.keys = keys
|
||||||
|
arr.type = array_type
|
||||||
|
|
||||||
new_param = copy.copy(param)
|
new_param = copy.copy(param)
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
new_param.parent = parent
|
new_param.parent = parent
|
||||||
new_param._commands = calls
|
new_param._commands = [arr]
|
||||||
new_param.is_generated = True
|
new_param.is_generated = True
|
||||||
name = copy.copy(param.get_name())
|
name = copy.copy(param.get_name())
|
||||||
name.parent = new_param
|
name.parent = new_param
|
||||||
@@ -610,7 +612,7 @@ class Execution(Executable):
|
|||||||
if not isinstance(stmt, pr.Statement):
|
if not isinstance(stmt, pr.Statement):
|
||||||
yield None, stmt
|
yield None, stmt
|
||||||
# *args
|
# *args
|
||||||
elif stmt.token_list[0] == '*':
|
elif stmt.get_commands()[0] == '*':
|
||||||
arrays = evaluate.follow_call_list([stmt.token_list[1:]])
|
arrays = evaluate.follow_call_list([stmt.token_list[1:]])
|
||||||
# *args must be some sort of an array, otherwise -> ignore
|
# *args must be some sort of an array, otherwise -> ignore
|
||||||
for array in arrays:
|
for array in arrays:
|
||||||
@@ -618,7 +620,7 @@ class Execution(Executable):
|
|||||||
for field in array.get_contents():
|
for field in array.get_contents():
|
||||||
yield None, field
|
yield None, field
|
||||||
# **kwargs
|
# **kwargs
|
||||||
elif stmt[0] == '**':
|
elif stmt.get_commands()[0] == '**':
|
||||||
arrays = evaluate.follow_call_list([stmt.token_list[1:]])
|
arrays = evaluate.follow_call_list([stmt.token_list[1:]])
|
||||||
for array in arrays:
|
for array in arrays:
|
||||||
if hasattr(array, 'get_contents'):
|
if hasattr(array, 'get_contents'):
|
||||||
@@ -632,8 +634,8 @@ class Execution(Executable):
|
|||||||
yield name, field
|
yield name, field
|
||||||
# Normal arguments (including key arguments).
|
# Normal arguments (including key arguments).
|
||||||
else:
|
else:
|
||||||
if stmt.assignment_detail:
|
if stmt.assignment_details:
|
||||||
key_arr, op = stmt.assignment_detail[0]
|
key_arr, op = stmt.assignment_details[0]
|
||||||
# named parameter
|
# named parameter
|
||||||
if key_arr and isinstance(key_arr[0], pr.Call):
|
if key_arr and isinstance(key_arr[0], pr.Call):
|
||||||
yield op[0].name, stmt
|
yield op[0].name, stmt
|
||||||
@@ -677,7 +679,7 @@ class Execution(Executable):
|
|||||||
raise common.MultiLevelAttributeError(sys.exc_info())
|
raise common.MultiLevelAttributeError(sys.exc_info())
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
if name not in ['start_pos', 'end_pos', 'imports']:
|
if name not in ['start_pos', 'end_pos', 'imports', 'module']:
|
||||||
raise AttributeError('Tried to access %s: %s. Why?' % (name, self))
|
raise AttributeError('Tried to access %s: %s. Why?' % (name, self))
|
||||||
return getattr(self.base, name)
|
return getattr(self.base, name)
|
||||||
|
|
||||||
@@ -701,7 +703,6 @@ class Execution(Executable):
|
|||||||
@property
|
@property
|
||||||
@cache.memoize_default()
|
@cache.memoize_default()
|
||||||
def returns(self):
|
def returns(self):
|
||||||
print self.copy_properties('returns')[0].parent
|
|
||||||
return self.copy_properties('returns')
|
return self.copy_properties('returns')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ def fast_parent_copy(obj):
|
|||||||
|
|
||||||
for key, value in items:
|
for key, value in items:
|
||||||
# replace parent (first try _parent and then parent)
|
# replace parent (first try _parent and then parent)
|
||||||
if key in ['parent', '_parent', '_parent_stmt'] \
|
if key in ['parent', '_parent'] and value is not None:
|
||||||
and value is not None:
|
|
||||||
if key == 'parent' and '_parent' in items:
|
if key == 'parent' and '_parent' in items:
|
||||||
# parent can be a property
|
# parent can be a property
|
||||||
continue
|
continue
|
||||||
@@ -40,8 +39,7 @@ def fast_parent_copy(obj):
|
|||||||
setattr(new_obj, key, new_elements[value])
|
setattr(new_obj, key, new_elements[value])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
elif key in ['parent_stmt', 'parent_function', 'use_as_parent',
|
elif key in ['parent_function', 'use_as_parent', 'module']:
|
||||||
'module']:
|
|
||||||
continue
|
continue
|
||||||
elif isinstance(value, list):
|
elif isinstance(value, list):
|
||||||
setattr(new_obj, key, list_rec(value))
|
setattr(new_obj, key, list_rec(value))
|
||||||
|
|||||||
@@ -711,7 +711,7 @@ class Statement(Simple):
|
|||||||
|
|
||||||
def get_code(self, new_line=True):
|
def get_code(self, new_line=True):
|
||||||
def assemble(command_list, assignment=None):
|
def assemble(command_list, assignment=None):
|
||||||
pieces = [c.get_code() if isinstance(c, Call) else c
|
pieces = [c.get_code() if isinstance(c, Simple) else c
|
||||||
for c in command_list]
|
for c in command_list]
|
||||||
if assignment is None:
|
if assignment is None:
|
||||||
return ''.join(pieces)
|
return ''.join(pieces)
|
||||||
@@ -1036,7 +1036,7 @@ class Array(Call):
|
|||||||
|
|
||||||
def __init__(self, module, start_pos, arr_type=NOARRAY, parent=None, values=None):
|
def __init__(self, module, start_pos, arr_type=NOARRAY, parent=None, values=None):
|
||||||
super(Array, self).__init__(module, None, arr_type, start_pos, parent)
|
super(Array, self).__init__(module, None, arr_type, start_pos, parent)
|
||||||
self.values = values if values else []
|
self.values = values or []
|
||||||
self.keys = []
|
self.keys = []
|
||||||
self.end_pos = None, None
|
self.end_pos = None, None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user