mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
list comprehensions should be completeable.
This commit is contained in:
@@ -152,7 +152,19 @@ class Comprehension(IterableWrapper):
|
||||
return "<e%s of %s>" % (type(self).__name__, self._atom)
|
||||
|
||||
|
||||
class ListComprehension(Comprehension):
|
||||
class ArrayMixin(object):
|
||||
@memoize_default()
|
||||
def names_dicts(self, search_global=False): # Always False.
|
||||
# `array.type` is a string with the type, e.g. 'list'.
|
||||
scope = self._evaluator.find_types(compiled.builtin, self.type)[0]
|
||||
# builtins only have one class -> [0]
|
||||
scope = self._evaluator.execute(scope, (AlreadyEvaluated((self,)),))[0]
|
||||
return scope.names_dicts(search_global)
|
||||
|
||||
|
||||
class ListComprehension(Comprehension, ArrayMixin):
|
||||
type = 'list'
|
||||
|
||||
def get_index_types(self, evaluator, index):
|
||||
return self.iter_content()
|
||||
|
||||
@@ -169,7 +181,7 @@ class GeneratorComprehension(Comprehension, GeneratorMixin):
|
||||
return self._evaluator.eval_element(self.eval_node())
|
||||
|
||||
|
||||
class Array(IterableWrapper):
|
||||
class Array(IterableWrapper, ArrayMixin):
|
||||
mapping = {'(': 'tuple',
|
||||
'[': 'list',
|
||||
'{': 'dict'}
|
||||
@@ -242,14 +254,6 @@ class Array(IterableWrapper):
|
||||
def iter_content(self):
|
||||
return self.values()
|
||||
|
||||
@memoize_default()
|
||||
def names_dicts(self, search_global=False): # Always False.
|
||||
# `array.type` is a string with the type, e.g. 'list'.
|
||||
scope = self._evaluator.find_types(compiled.builtin, self.type)[0]
|
||||
# builtins only have one class -> [0]
|
||||
scope = self._evaluator.execute(scope, (AlreadyEvaluated((self,)),))[0]
|
||||
return scope.names_dicts(search_global)
|
||||
|
||||
@common.safe_property
|
||||
def parent(self):
|
||||
return compiled.builtin
|
||||
|
||||
@@ -128,6 +128,8 @@ for i in range(10):
|
||||
a = ['' for a in [1]]
|
||||
#? str()
|
||||
a[0]
|
||||
#? ['insert']
|
||||
a.insert
|
||||
|
||||
a = [a for a in [1]]
|
||||
#? int()
|
||||
|
||||
Reference in New Issue
Block a user