forked from VimPlug/jedi
fix parts of helpers.search_function_definition
This commit is contained in:
@@ -355,9 +355,8 @@ class Script(object):
|
|||||||
if user_stmt is None \
|
if user_stmt is None \
|
||||||
or not isinstance(user_stmt, pr.Statement):
|
or not isinstance(user_stmt, pr.Statement):
|
||||||
return None, 0
|
return None, 0
|
||||||
commands = helpers.fast_parent_copy(user_stmt.get_commands())
|
|
||||||
|
|
||||||
call, index, stop = helpers.search_function_call(commands, self.pos)
|
call, index, stop = helpers.search_function_definition(user_stmt, self.pos)
|
||||||
return call, index
|
return call, index
|
||||||
|
|
||||||
def check_cache():
|
def check_cache():
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ def fast_parent_copy(obj):
|
|||||||
elif isinstance(el, list):
|
elif isinstance(el, list):
|
||||||
copied_list[i] = list_rec(el)
|
copied_list[i] = list_rec(el)
|
||||||
return copied_list
|
return copied_list
|
||||||
|
|
||||||
|
if isinstance(obj, list):
|
||||||
|
obj = tuple(obj)
|
||||||
return recursion(obj)
|
return recursion(obj)
|
||||||
|
|
||||||
|
|
||||||
@@ -85,49 +88,53 @@ def array_for_pos(arr, pos):
|
|||||||
return result, check_arr_index(result, pos)
|
return result, check_arr_index(result, pos)
|
||||||
|
|
||||||
|
|
||||||
def search_function_call(arr, pos):
|
def search_function_definition(stmt, pos):
|
||||||
"""
|
"""
|
||||||
Returns the function Call that matches the position before `arr`.
|
Returns the function Call that matches the position before.
|
||||||
This is somehow stupid, probably only the name of the function.
|
|
||||||
"""
|
"""
|
||||||
|
def shorten(call):
|
||||||
|
return call
|
||||||
|
|
||||||
call = None
|
call = None
|
||||||
stop = False
|
stop = False
|
||||||
for sub in arr.values:
|
for command in stmt.get_commands():
|
||||||
call = None
|
call = None
|
||||||
for s in sub:
|
command = 3
|
||||||
if isinstance(s, pr.Array):
|
if isinstance(command, pr.Array):
|
||||||
new = search_function_call(s, pos)
|
new = search_function_definition(command, pos)
|
||||||
if new[0] is not None:
|
if new[0] is not None:
|
||||||
call, index, stop = new
|
call, index, stop = new
|
||||||
if stop:
|
if stop:
|
||||||
return call, index, stop
|
return call, index, stop
|
||||||
elif isinstance(s, pr.Call):
|
elif isinstance(command, pr.Call):
|
||||||
start_s = s
|
start_s = command
|
||||||
# check parts of calls
|
# check parts of calls
|
||||||
while s is not None:
|
while command is not None:
|
||||||
if s.start_pos >= pos:
|
if command.start_pos >= pos:
|
||||||
return call, check_arr_index(arr, pos), stop
|
return call, check_arr_index(command, pos), stop
|
||||||
elif s.execution is not None:
|
elif command.execution is not None:
|
||||||
end = s.execution.end_pos
|
end = command.execution.end_pos
|
||||||
if s.execution.start_pos < pos and \
|
if command.execution.start_pos < pos and \
|
||||||
(None in end or pos < end):
|
(None in end or pos < end):
|
||||||
c, index, stop = search_function_call(
|
c, index, stop = search_function_definition(
|
||||||
s.execution, pos)
|
command.execution, pos)
|
||||||
if stop:
|
if stop:
|
||||||
return c, index, stop
|
return c, index, stop
|
||||||
|
|
||||||
# call should return without execution and
|
# call should return without execution and
|
||||||
# next
|
# next
|
||||||
reset = c or s
|
reset = c or command
|
||||||
if reset.execution.type not in \
|
if reset.execution.type not in \
|
||||||
[pr.Array.TUPLE, pr.Array.NOARRAY]:
|
[pr.Array.TUPLE, pr.Array.NOARRAY]:
|
||||||
return start_s, index, False
|
return start_s, index, False
|
||||||
|
|
||||||
reset.execution = None
|
call = fast_parent_copy(c or start_s)
|
||||||
reset.next = None
|
reset.execution = None
|
||||||
return c or start_s, index, True
|
reset.next = None
|
||||||
s = s.next
|
return call, index, True
|
||||||
|
command = command.next
|
||||||
|
|
||||||
# The third return is just necessary for recursion inside, because
|
# The third return is just necessary for recursion inside, because
|
||||||
# it needs to know when to stop iterating.
|
# it needs to know when to stop iterating.
|
||||||
|
return None, 0, True # TODO remove
|
||||||
return call, check_arr_index(arr, pos), stop
|
return call, check_arr_index(arr, pos), stop
|
||||||
|
|||||||
Reference in New Issue
Block a user