def create_instance_context(self, class_context, node): if node.parent.type in ('funcdef', 'classdef'): node = node.parent scope = get_parent_scope(node) if scope == class_context.tree_node: return class_context else: parent_context = self.create_instance_context(class_context, scope) if scope.type == 'funcdef': func = FunctionContext.from_context( parent_context, scope, ) bound_method = BoundMethod(self, func) if scope.name.value == '__init__' and parent_context == class_context: return bound_method.get_function_execution(self.var_args) else: return bound_method.get_function_execution() elif scope.type == 'classdef': class_context = ClassContext(self.evaluator, parent_context, scope) return class_context elif scope.type == 'comp_for': # Comprehensions currently don't have a special scope in Jedi. return self.create_instance_context(class_context, scope) else: raise NotImplementedError return class_context
def create_instance_context(self, class_context, node): if node.parent.type in ('funcdef', 'classdef'): node = node.parent scope = get_parent_scope(node) if scope == class_context.tree_node: return class_context else: parent_context = self.create_instance_context(class_context, scope) if scope.type == 'funcdef': func = FunctionContext.from_context( parent_context, scope, ) bound_method = BoundMethod(self, class_context, func) if scope.name.value == '__init__' and parent_context == class_context: return self._create_init_execution(class_context, bound_method) else: return bound_method.get_function_execution() elif scope.type == 'classdef': class_context = ClassContext(self.evaluator, parent_context, scope) return class_context elif scope.type == 'comp_for': # Comprehensions currently don't have a special scope in Jedi. return self.create_instance_context(class_context, scope) else: raise NotImplementedError return class_context
def create_init_executions(self): for name in self.get_function_slot_names(u'__init__'): if isinstance(name, LazyInstanceClassName): function = FunctionContext.from_context( self.parent_context, name.tree_name.parent) bound_method = BoundMethod(self, name.class_context, function) yield self._create_init_execution(name.class_context, bound_method)
def create_init_executions(self): for name in self.get_function_slot_names(u'__init__'): # TODO is this correct? I think we need to check for functions. if isinstance(name, LazyInstanceClassName): function = FunctionContext.from_context( self.parent_context, name.tree_name.parent) bound_method = BoundMethod(self, function) yield bound_method.get_function_execution(self.var_args)
def create_init_executions(self): for name in self.get_function_slot_names(u'__init__'): if isinstance(name, LazyInstanceClassName): function = FunctionContext.from_context( self.parent_context, name.tree_name.parent ) bound_method = BoundMethod(self, name.class_context, function) yield self._create_init_execution(name.class_context, bound_method)