From d6257fffc8289c8d026e673772a7e977fc18c4b9 Mon Sep 17 00:00:00 2001 From: David Halter Date: Fri, 8 Feb 2013 15:50:35 +0100 Subject: [PATCH] make array slicing work again --- jedi/evaluate_representation.py | 10 +++++----- jedi/parsing_representation.py | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/jedi/evaluate_representation.py b/jedi/evaluate_representation.py index 172b91e6..c9ec3284 100644 --- a/jedi/evaluate_representation.py +++ b/jedi/evaluate_representation.py @@ -771,14 +771,14 @@ class Array(use_metaclass(cache.CachedMetaClass, pr.Base)): def __init__(self, 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 """ - # array slicing - if index_call_list is not None: - if index_call_list and [x for x in index_call_list if ':' in x.token_list]: + if index_arr is not None: + if index_arr and [x for x in index_arr if ':' in x.get_assignment_calls()]: + # array slicing return [self] - index_possibilities = self._follow_values(index_call_list) + index_possibilities = self._follow_values(index_arr) if len(index_possibilities) == 1: # This is indexing only one element, with a fixed index number, # otherwise it just ignores the index (e.g. [1+1]). diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index cc229c3d..81012f2f 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -730,6 +730,13 @@ class Statement(Simple): # first keyword of the first token is global -> must be a 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 def assignment_details(self): if self._assignment_calls is None: