mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-11 08:11:50 +08:00
added more generator names
This commit is contained in:
11
evaluate.py
11
evaluate.py
@@ -403,7 +403,6 @@ class Execution(Executable):
|
|||||||
stmts = [Instance(self.base, self.var_args)]
|
stmts = [Instance(self.base, self.var_args)]
|
||||||
elif isinstance(self.base, Generator):
|
elif isinstance(self.base, Generator):
|
||||||
return Execution(self.base.func).get_return_types(True)
|
return Execution(self.base.func).get_return_types(True)
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
func = self.process_decorators()
|
func = self.process_decorators()
|
||||||
|
|
||||||
@@ -457,14 +456,20 @@ class Generator(object):
|
|||||||
name = parsing.Name([n], 0, 0, 0)
|
name = parsing.Name([n], 0, 0, 0)
|
||||||
name.parent = self
|
name.parent = self
|
||||||
names.append(name)
|
names.append(name)
|
||||||
|
for n in ['close', 'throw']:
|
||||||
|
# the name for the `next` function
|
||||||
|
name = parsing.Name([n], 0, 0, 0)
|
||||||
|
name.parent = None
|
||||||
|
names.append(name)
|
||||||
return names
|
return names
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def parent(self):
|
def parent(self):
|
||||||
# TODO add generator names (__next__, send, close, throw, next?)
|
|
||||||
return self.func.parent
|
return self.func.parent
|
||||||
#self.execution.get_return_types()
|
#self.execution.get_return_types()
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<%s of %s>" % (self.__class__.__name__, self.func)
|
||||||
|
|
||||||
class Array(object):
|
class Array(object):
|
||||||
"""
|
"""
|
||||||
@@ -667,7 +672,7 @@ def get_scopes_for_name(scope, name_str, position=None, search_global=False):
|
|||||||
#print name, name.parent.parent, scope
|
#print name, name.parent.parent, scope
|
||||||
# this means that a definition was found and is not e.g.
|
# this means that a definition was found and is not e.g.
|
||||||
# in if/else.
|
# in if/else.
|
||||||
if name.parent.parent == scope:
|
if not name.parent or name.parent.parent == scope:
|
||||||
break
|
break
|
||||||
# if there are results, ignore the other scopes
|
# if there are results, ignore the other scopes
|
||||||
if result:
|
if result:
|
||||||
|
|||||||
@@ -177,4 +177,4 @@ def nexti(iterator, default=list):
|
|||||||
|
|
||||||
#exe[0].
|
#exe[0].
|
||||||
#exe[4]['d']
|
#exe[4]['d']
|
||||||
next(gen_exe).
|
next(gen_exe).; gen_exe.
|
||||||
|
|||||||
Reference in New Issue
Block a user