Example #1
0
    def get_filters(self, search_global=False):
        origin_scope = self._get_origin_scope()
        if search_global:
            position = self._position

            # For functions and classes the defaults don't belong to the
            # function and get evaluated in the context before the function. So
            # make sure to exclude the function/class name.
            if origin_scope is not None:
                ancestor = search_ancestor(origin_scope, 'funcdef', 'classdef',
                                           'lambdef')
                lambdef = None
                if ancestor == 'lambdef':
                    # For lambdas it's even more complicated since parts will
                    # be evaluated later.
                    lambdef = ancestor
                    ancestor = search_ancestor(origin_scope, 'funcdef',
                                               'classdef')
                if ancestor is not None:
                    colon = ancestor.children[-2]
                    if position is not None and position < colon.start_pos:
                        if lambdef is None or position < lambdef.children[
                                -2].start_pos:
                            position = ancestor.start_pos

            return get_global_filters(self._evaluator, self._context, position,
                                      origin_scope)
        else:
            return self._get_context_filters(origin_scope)
Example #2
0
    def get_filters(self, search_global=False):
        origin_scope = self._get_origin_scope()
        if search_global:
            position = self._position

            # For functions and classes the defaults don't belong to the
            # function and get evaluated in the context before the function. So
            # make sure to exclude the function/class name.
            if origin_scope is not None:
                ancestor = search_ancestor(origin_scope, 'funcdef', 'classdef', 'lambdef')
                lambdef = None
                if ancestor == 'lambdef':
                    # For lambdas it's even more complicated since parts will
                    # be evaluated later.
                    lambdef = ancestor
                    ancestor = search_ancestor(origin_scope, 'funcdef', 'classdef')
                if ancestor is not None:
                    colon = ancestor.children[-2]
                    if position < colon.start_pos:
                        if lambdef is None or position < lambdef.children[-2].start_pos:
                            position = ancestor.start_pos

            return get_global_filters(self._evaluator, self._context, position, origin_scope)
        else:
            return self._context.get_filters(search_global, self._position, origin_scope=origin_scope)
Example #3
0
 def get_filters(self, search_global=False):
     origin_scope = self._get_origin_scope()
     if search_global:
         return get_global_filters(self._evaluator, self._context,
                                   self._position, origin_scope)
     else:
         return self._context.get_filters(search_global,
                                          self._position,
                                          origin_scope=origin_scope)
Example #4
0
 def _global_completions(self):
     context = get_user_scope(self._module_context, self._position)
     debug.dbg('global completion scope: %s', context)
     flow_scope_node = get_flow_scope_node(self._module_node,
                                           self._position)
     filters = get_global_filters(self._evaluator,
                                  context,
                                  self._position,
                                  origin_scope=flow_scope_node)
     completion_names = []
     for filter in filters:
         completion_names += filter.values()
     return completion_names
Example #5
0
 def _global_completions(self):
     context = get_user_scope(self._module_context, self._position)
     debug.dbg('global completion scope: %s', context)
     flow_scope_node = get_flow_scope_node(self._module_node, self._position)
     filters = get_global_filters(
         self._evaluator,
         context,
         self._position,
         origin_scope=flow_scope_node
     )
     completion_names = []
     for filter in filters:
         completion_names += filter.values()
     return completion_names
Example #6
0
 def get_filters(self, search_global=False):
     origin_scope = self._get_origin_scope()
     if search_global:
         return get_global_filters(self._evaluator, self._context, self._position, origin_scope)
     else:
         return self._context.get_filters(search_global, self._position, origin_scope=origin_scope)