1
0
forked from VimPlug/jedi

better support for get_in_function_call - fixes #57

This commit is contained in:
David Halter
2012-11-11 02:48:33 +01:00
parent fcc6a1e401
commit 3d1f67b8a0
3 changed files with 15 additions and 9 deletions

View File

@@ -348,8 +348,6 @@ class Script(object):
# just take entry zero, because we need just one. # just take entry zero, because we need just one.
executable = origins[0] executable = origins[0]
after = self.module.get_line(self.pos[0])[self.pos[1]:]
index -= re.search('^[ ,]*', after).group(0).count(',')
return api_classes.CallDef(executable, index, call) return api_classes.CallDef(executable, index, call)
def _get_on_import_stmt(self, is_like_search=False): def _get_on_import_stmt(self, is_like_search=False):

View File

@@ -1,7 +1,6 @@
import copy import copy
import weakref import weakref
from _compatibility import hasattr
import parsing import parsing
import evaluate import evaluate
import debug import debug
@@ -201,10 +200,16 @@ def scan_array_for_pos(arr, pos):
""" """
Returns the function Call that match search_name in an Array. Returns the function Call that match search_name in an Array.
""" """
index = 0 def check_arr_index():
positions = arr.arr_el_pos
for index, comma_pos in enumerate(positions):
if pos < comma_pos:
return index
return len(positions)
call = None call = None
stop = False stop = False
for index, sub in enumerate(arr.values): for sub in arr.values:
call = None call = None
for s in sub: for s in sub:
if isinstance(s, parsing.Array): if isinstance(s, parsing.Array):
@@ -215,9 +220,10 @@ def scan_array_for_pos(arr, pos):
return call, index, stop return call, index, stop
elif isinstance(s, parsing.Call): elif isinstance(s, parsing.Call):
start_s = s start_s = s
# check parts of calls
while s is not None: while s is not None:
if s.start_pos >= pos: if s.start_pos >= pos:
return call, index, stop return call, check_arr_index(), stop
elif s.execution is not None: elif s.execution is not None:
end = s.execution.end_pos end = s.execution.end_pos
if s.execution.start_pos < pos and \ if s.execution.start_pos < pos and \
@@ -242,4 +248,4 @@ def scan_array_for_pos(arr, pos):
# 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 call, index, stop return call, check_arr_index(), stop

View File

@@ -819,7 +819,7 @@ class Statement(Simple):
while is_call_or_close(): while is_call_or_close():
result = result.parent() result = result.parent()
close_brackets = False close_brackets = False
result.add_field() result.add_field((start_pos[0], start_pos[1] + 1))
# important - it cannot be empty anymore # important - it cannot be empty anymore
if result.type == Array.NOARRAY: if result.type == Array.NOARRAY:
result.type = Array.TUPLE result.type = Array.TUPLE
@@ -986,16 +986,18 @@ class Array(Call):
parent) parent)
self.values = values if values else [] self.values = values if values else []
self.arr_el_pos = []
self.keys = [] self.keys = []
self.end_pos = None self.end_pos = None
def add_field(self): def add_field(self, start_pos):
""" """
Just add a new field to the values. Just add a new field to the values.
Each value has a sub-array, because there may be different tokens in Each value has a sub-array, because there may be different tokens in
one array. one array.
""" """
self.arr_el_pos.append(start_pos)
self.values.append([]) self.values.append([])
def add_to_current_field(self, tok): def add_to_current_field(self, tok):