def get_filters(self, search_global=False, until_position=None,
                    origin_scope=None, is_instance=False):
        metaclasses = self.get_metaclasses()
        if metaclasses:
            for f in self.get_metaclass_filters(metaclasses):
                yield f

        if search_global:
            yield self.get_global_filter(until_position, origin_scope)
        else:
            for cls in self.py__mro__():
                if isinstance(cls, compiled.CompiledObject):
                    for filter in cls.get_filters(is_instance=is_instance):
                        yield filter
                else:
                    yield ClassFilter(
                        self.evaluator, self, node_context=cls,
                        origin_scope=origin_scope,
                        is_instance=is_instance
                    )
        if not is_instance:
            from jedi.evaluate.compiled import builtin_from_name
            type_ = builtin_from_name(self.evaluator, u'type')
            assert isinstance(type_, ClassContext)
            if type_ != self:
                for instance in type_.py__call__(ValuesArguments([])):
                    instance_filters = instance.get_filters()
                    # Filter out self filters
                    next(instance_filters)
                    next(instance_filters)
                    yield next(instance_filters)
예제 #2
0
 def py__call__(self, arguments=None):
     from jedi.evaluate.context import TreeInstance
     if arguments is None:
         arguments = ValuesArguments([])
     return ContextSet([
         TreeInstance(self.evaluator, self.parent_context, self, arguments)
     ])
예제 #3
0
 def execute_evaluated(self, *value_list):
     """
     Execute a function with already executed arguments.
     """
     from jedi.evaluate.arguments import ValuesArguments
     arguments = ValuesArguments([ContextSet(value) for value in value_list])
     return self.execute(arguments)
예제 #4
0
파일: stdlib.py 프로젝트: luojinrong/jedi
def builtins_property(objects, types, obj, arguments):
    property_args = obj.instance.var_args.unpack()
    key, lazy_context = next(property_args, (None, None))
    if key is not None or lazy_context is None:
        debug.warning('property expected a first param, not %s', arguments)
        return NO_CONTEXTS

    return lazy_context.infer().py__call__(arguments=ValuesArguments([objects]))
예제 #5
0
def execute_evaluated(context, *value_list):
    """
    Execute a function with already executed arguments.
    """
    # TODO move this out of here to the evaluator.
    from jedi.evaluate.arguments import ValuesArguments
    from jedi.evaluate.base_context import ContextSet
    arguments = ValuesArguments([ContextSet([value]) for value in value_list])
    return context.evaluator.execute(context, arguments)
예제 #6
0
    def py__getitem__(self, index_context_set, contextualized_node):
        names = self.get_function_slot_names(u'__getitem__')
        if not names:
            return super(AbstractInstanceContext, self).py__getitem__(
                index_context_set,
                contextualized_node,
            )

        args = ValuesArguments([index_context_set])
        return ContextSet.from_sets(name.infer().execute(args) for name in names)
예제 #7
0
파일: stdlib.py 프로젝트: Igorshu90/Hal1.1
def builtins_reversed(evaluator, sequences, obj, arguments):
    # While we could do without this variable (just by using sequences), we
    # want static analysis to work well. Therefore we need to generated the
    # values again.
    key, lazy_context = next(arguments.unpack())
    cn = None
    if isinstance(lazy_context, LazyTreeContext):
        # TODO access private
        cn = ContextualizedNode(lazy_context._context, lazy_context.data)
    ordered = list(sequences.iterate(cn))

    rev = list(reversed(ordered))
    # 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.
    seq = iterable.FakeSequence(evaluator, u'list', rev)
    arguments = ValuesArguments([ContextSet(seq)])
    return ContextSet(CompiledInstance(evaluator, evaluator.builtins_module, obj, arguments))
 def execute_evaluated(self, *value_list):
     from jedi.evaluate.arguments import ValuesArguments
     arguments = ValuesArguments([ContextSet([value]) for value in value_list])
     return self.evaluator.execute(self, arguments)