mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
fix some generator parents
This commit is contained in:
@@ -12,8 +12,6 @@ Changelog
|
|||||||
* REPL completion is starting to become usable.
|
* REPL completion is starting to become usable.
|
||||||
* Various small API changes. Generally this released focused on stability, though.
|
* Various small API changes. Generally this released focused on stability, though.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
0.7.0 (2013-08-09)
|
0.7.0 (2013-08-09)
|
||||||
++++++++++++++++++
|
++++++++++++++++++
|
||||||
* switched from LGPL to MIT license
|
* switched from LGPL to MIT license
|
||||||
|
|||||||
@@ -264,8 +264,14 @@ class Builtin(CompiledObject):
|
|||||||
return [d for d in super(Builtin, self).get_defined_names() if d.name != 'None']
|
return [d for d in super(Builtin, self).get_defined_names() if d.name != 'None']
|
||||||
|
|
||||||
|
|
||||||
|
def _a_generator(foo):
|
||||||
|
"""Used to have an object to return for generators."""
|
||||||
|
yield 42
|
||||||
|
yield foo
|
||||||
|
|
||||||
builtin = Builtin(_builtins)
|
builtin = Builtin(_builtins)
|
||||||
magic_function_class = CompiledObject(type(load_module), parent=builtin)
|
magic_function_class = CompiledObject(type(load_module), parent=builtin)
|
||||||
|
generator_obj = CompiledObject(_a_generator(1.0))
|
||||||
|
|
||||||
|
|
||||||
def _create_from_name(module, parent, name):
|
def _create_from_name(module, parent, name):
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from jedi.parser import representation as pr
|
|||||||
from jedi.evaluate import compiled
|
from jedi.evaluate import compiled
|
||||||
from jedi.evaluate import helpers
|
from jedi.evaluate import helpers
|
||||||
from jedi.evaluate.cache import CachedMetaClass, memoize_default
|
from jedi.evaluate.cache import CachedMetaClass, memoize_default
|
||||||
|
from jedi.cache import underscore_memoization
|
||||||
|
|
||||||
|
|
||||||
class Generator(use_metaclass(CachedMetaClass, pr.Base)):
|
class Generator(use_metaclass(CachedMetaClass, pr.Base)):
|
||||||
@@ -18,18 +19,21 @@ class Generator(use_metaclass(CachedMetaClass, pr.Base)):
|
|||||||
self.func = func
|
self.func = func
|
||||||
self.var_args = var_args
|
self.var_args = var_args
|
||||||
|
|
||||||
|
@underscore_memoization
|
||||||
def get_defined_names(self):
|
def get_defined_names(self):
|
||||||
"""
|
"""
|
||||||
Returns a list of names that define a generator, which can return the
|
Returns a list of names that define a generator, which can return the
|
||||||
content of a generator.
|
content of a generator.
|
||||||
"""
|
"""
|
||||||
names = []
|
executes_generator = '__next__', 'send', 'next'
|
||||||
executes_generator = ('__next__', 'send')
|
for name in compiled.generator_obj.get_defined_names():
|
||||||
for n in ('close', 'throw') + executes_generator:
|
if name.name in executes_generator:
|
||||||
parent = self if n in executes_generator else compiled.builtin
|
parent = self
|
||||||
names.append(helpers.FakeName(n, parent))
|
# TODO parents are fucked up
|
||||||
debug.dbg('generator names: %s', names)
|
#pr.Function(module, name, [], (0, 0), None)
|
||||||
return names
|
yield helpers.FakeName(name, parent)
|
||||||
|
else:
|
||||||
|
yield name
|
||||||
|
|
||||||
def iter_content(self):
|
def iter_content(self):
|
||||||
""" returns the content of __iter__ """
|
""" returns the content of __iter__ """
|
||||||
|
|||||||
Reference in New Issue
Block a user