1
0
forked from VimPlug/jedi

Only 125 fails left in the integration tests.

This commit is contained in:
Dave Halter
2016-11-26 00:25:31 +01:00
parent bad1f85f8f
commit fe54285311
3 changed files with 19 additions and 16 deletions
+1 -2
View File
@@ -484,8 +484,7 @@ class Evaluator(object):
)) ))
if tree.is_node(par, 'trailer') and par.children[0] == '.': if tree.is_node(par, 'trailer') and par.children[0] == '.':
call = helpers.call_of_leaf(name, cut_own_trailer=True) values = helpers.evaluate_call_of_leaf(context, name, cut_own_trailer=True)
values = self.eval_element(context, call)
return unite( return unite(
self.find_types(value, name, is_goto=True) for value in values self.find_types(value, name, is_goto=True) for value in values
) )
+10 -6
View File
@@ -47,6 +47,10 @@ class Context(object):
def eval_trailer(self, types, trailer): def eval_trailer(self, types, trailer):
return self.evaluator.eval_trailer(self, types, trailer) return self.evaluator.eval_trailer(self, types, trailer)
def py__getattribute__(self, name_or_str, position=None,
search_global=False, is_goto=False):
return self.evaluator.find_types(self, name_or_str, position, search_global, is_goto)
class TreeContext(Context): class TreeContext(Context):
def __init__(self, evaluator, parent_context=None): def __init__(self, evaluator, parent_context=None):
@@ -62,10 +66,10 @@ class FlowContext(TreeContext):
class AbstractLazyContext(object): class AbstractLazyContext(object):
def __init__(self, data): def __init__(self, data):
self._data = data self.data = data
def __repr__(self): def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self._data) return '<%s: %s>' % (self.__class__.__name__, self.data)
def infer(self): def infer(self):
raise NotImplementedError raise NotImplementedError
@@ -74,13 +78,13 @@ class AbstractLazyContext(object):
class LazyKnownContext(AbstractLazyContext): class LazyKnownContext(AbstractLazyContext):
"""data is a context.""" """data is a context."""
def infer(self): def infer(self):
yield self._data yield self.data
class LazyKnownContexts(AbstractLazyContext): class LazyKnownContexts(AbstractLazyContext):
"""data is a set of contexts.""" """data is a set of contexts."""
def infer(self): def infer(self):
return self._data return self.data
class LazyUnknownContext(AbstractLazyContext): class LazyUnknownContext(AbstractLazyContext):
@@ -97,7 +101,7 @@ class LazyTreeContext(AbstractLazyContext):
self._context = context self._context = context
def infer(self): def infer(self):
return self._context.eval_node(self._data) return self._context.eval_node(self.data)
def get_merged_lazy_context(lazy_contexts): def get_merged_lazy_context(lazy_contexts):
@@ -110,4 +114,4 @@ def get_merged_lazy_context(lazy_contexts):
class MergedLazyContexts(AbstractLazyContext): class MergedLazyContexts(AbstractLazyContext):
"""data is a list of lazy contexts.""" """data is a list of lazy contexts."""
def infer(self): def infer(self):
return unite(l.infer() for l in self._data) return unite(l.infer() for l in self.data)
+8 -8
View File
@@ -16,7 +16,8 @@ from jedi._compatibility import unicode
from jedi.common import unite from jedi.common import unite
from jedi.evaluate import compiled from jedi.evaluate import compiled
from jedi.evaluate import representation as er from jedi.evaluate import representation as er
from jedi.evaluate.instance import InstanceFunctionExecution, AbstractInstanceContext from jedi.evaluate.instance import InstanceFunctionExecution, \
AbstractInstanceContext, CompiledInstance
from jedi.evaluate import iterable from jedi.evaluate import iterable
from jedi.parser import ParserWithRecovery from jedi.parser import ParserWithRecovery
from jedi import debug from jedi import debug
@@ -148,18 +149,17 @@ def builtins_reversed(evaluator, sequences, obj, arguments):
# While we could do without this variable (just by using sequences), we # While we could do without this variable (just by using sequences), we
# want static analysis to work well. Therefore we need to generated the # want static analysis to work well. Therefore we need to generated the
# values again. # values again.
first_arg = next(arguments.as_tuple())[0] key, lazy_context = next(arguments.unpack())
ordered = list(iterable.py__iter__(evaluator, sequences, first_arg)) ordered = list(iterable.py__iter__(evaluator, sequences, lazy_context.data))
rev = [iterable.AlreadyEvaluated(o) for o in reversed(ordered)] rev = list(reversed(ordered))
# Repack iterator values and then run it the normal way. This is # Repack iterator values and then run it the normal way. This is
# necessary, because `reversed` is a function and autocompletion # necessary, because `reversed` is a function and autocompletion
# would fail in certain cases like `reversed(x).__iter__` if we # would fail in certain cases like `reversed(x).__iter__` if we
# just returned the result directly. # just returned the result directly.
rev = iterable.AlreadyEvaluated( seq = iterable.FakeSequence(evaluator, 'list', rev)
[iterable.FakeSequence(evaluator, rev, 'list')] arguments = param.ValuesArguments([[seq]])
) return set([CompiledInstance(evaluator, evaluator.BUILTINS, obj, arguments)])
return set([er.Instance(evaluator, obj, param.Arguments(evaluator, [rev]))])
@argument_clinic('obj, type, /', want_arguments=True) @argument_clinic('obj, type, /', want_arguments=True)