1
0
forked from VimPlug/jedi

make array slicing work again

This commit is contained in:
David Halter
2013-02-08 15:50:35 +01:00
parent 942c620cde
commit d6257fffc8
2 changed files with 12 additions and 5 deletions

View File

@@ -771,14 +771,14 @@ class Array(use_metaclass(cache.CachedMetaClass, pr.Base)):
def __init__(self, array): def __init__(self, array):
self._array = array self._array = array
def get_index_types(self, index_call_list=None): def get_index_types(self, index_arr=None):
""" Get the types of a specific index or all, if not given """ """ Get the types of a specific index or all, if not given """
# array slicing if index_arr is not None:
if index_call_list is not None: if index_arr and [x for x in index_arr if ':' in x.get_assignment_calls()]:
if index_call_list and [x for x in index_call_list if ':' in x.token_list]: # array slicing
return [self] return [self]
index_possibilities = self._follow_values(index_call_list) index_possibilities = self._follow_values(index_arr)
if len(index_possibilities) == 1: if len(index_possibilities) == 1:
# This is indexing only one element, with a fixed index number, # This is indexing only one element, with a fixed index number,
# otherwise it just ignores the index (e.g. [1+1]). # otherwise it just ignores the index (e.g. [1+1]).

View File

@@ -730,6 +730,13 @@ class Statement(Simple):
# first keyword of the first token is global -> must be a global # first keyword of the first token is global -> must be a global
return str(self.token_list[0]) == "global" return str(self.token_list[0]) == "global"
def get_command(self, index):
commands = self.get_assignment_calls()
try:
return commands[index]
except IndexError:
return None
@property @property
def assignment_details(self): def assignment_details(self):
if self._assignment_calls is None: if self._assignment_calls is None: