def _complete_code_lines(self, code_lines): module_node = self._inference_state.grammar.parse(''.join(code_lines)) module_value = ModuleValue( self._inference_state, module_node, code_lines=code_lines, ) module_value.parent_context = self._module_context return Completion(self._inference_state, module_value.as_context(), code_lines=code_lines, position=module_node.end_pos, signatures_callback=lambda *args, **kwargs: [], fuzzy=self._fuzzy).complete()
def _create(inference_state, compiled_value, module_context): # TODO accessing this is bad, but it probably doesn't matter that much, # because we're working with interpreteters only here. python_object = compiled_value.access_handle.access._obj result = _find_syntax_node_name(inference_state, python_object) if result is None: # TODO Care about generics from stuff like `[1]` and don't return like this. if type(python_object) in (dict, list, tuple): return ValueSet({compiled_value}) tree_values = to_stub(compiled_value) if not tree_values: return ValueSet({compiled_value}) else: module_node, tree_node, file_io, code_lines = result if module_context is None or module_context.tree_node != module_node: root_compiled_value = compiled_value.get_root_context().get_value() # TODO this __name__ might be wrong. name = root_compiled_value.py__name__() string_names = tuple(name.split('.')) module_value = ModuleValue( inference_state, module_node, file_io=file_io, string_names=string_names, code_lines=code_lines, is_package=root_compiled_value.is_package(), ) if name is not None: inference_state.module_cache.add(string_names, ValueSet([module_value])) module_context = module_value.as_context() tree_values = ValueSet({module_context.create_value(tree_node)}) if tree_node.type == 'classdef': if not compiled_value.is_class(): # Is an instance, not a class. tree_values = tree_values.execute_with_values() return ValueSet( MixedObject(compiled_value, tree_value=tree_value) for tree_value in tree_values)