forked from VimPlug/jedi
lo and behold - reversed is implemented - the force is strong with this one. fixes #24
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
Implementations of standard library functions, because it's not possible to
|
||||
understand them with Jedi.
|
||||
"""
|
||||
|
||||
from jedi._compatibility import unicode
|
||||
from jedi.evaluate import compiled
|
||||
from jedi.evaluate import representation as er
|
||||
from jedi.evaluate import iterable
|
||||
from jedi.evaluate.helpers import FakeArray, FakeStatement
|
||||
from jedi.parser import representation as pr
|
||||
from jedi import debug
|
||||
|
||||
@@ -82,10 +82,26 @@ def builtins_super(evaluator, obj, params):
|
||||
return []
|
||||
|
||||
|
||||
def builtins_reversed(evaluator, obj, params):
|
||||
objects = _follow_param(evaluator, params, 0)
|
||||
if objects:
|
||||
# unpack the iterator values
|
||||
objects = iterable.get_iterator_types(objects)
|
||||
rev = reversed(objects)
|
||||
# Repack iterator values and then run it the normal way. This is necessary,
|
||||
# because `reversed` is a function and autocompletion would fail in certain
|
||||
# cases like `reversed(x).__iter__` if we just returned the result
|
||||
# directly.
|
||||
stmts = [FakeStatement([r]) for r in rev]
|
||||
objects = (FakeArray(stmts, objects[0].parent),)
|
||||
return [er.Instance(evaluator, obj, objects)]
|
||||
|
||||
|
||||
_implemented = {
|
||||
'builtins': {
|
||||
'getattr': builtins_getattr,
|
||||
'type': builtins_type,
|
||||
'super': builtins_super,
|
||||
'reversed': builtins_reversed,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user