Ejemplo n.º 1
0
    def visit_common_function_def(
            self, node: Union[ast.FunctionDef, ast.AsyncFunctionDef]) -> Any:
        r = create_range_from_ast_node(node)
        self.function = FunctionDeclaration(
            node.name,
            self.scope_manager.get_qualified_name_from_current_scope(
                node.name, r.start_position.line),
            FilePosition(self.current_file, r), [], "")

        for call in reversed(self.current_function_calls):
            if call.name == self.function.name and call.file_position == self.function.file_position:
                return
        # self.scope_manager.append_function_to_current_scope(self.function)
        self.current_function_declaration.append(self.function)

        def action():
            self.collect_parameters(node)
            self.generic_visit(node)

        self.scope_manager.with_scope(
            FunctionScope(
                node.name,
                self.scope_manager.get_qualified_scope_name_from_current_scope(
                ), FilePosition.get_empty_file_position()), action)
        del self.current_function_declaration[-1]
 def __init__(self):
     file_position = FilePosition.get_empty_file_position()
     qualified_name = "builtins.function." + self.get_name()
     super().__init__(self.get_name(), qualified_name, file_position, [],
                      "", self.get_type())
     if self.get_override() is None:
         self.override = []
     else:
         self.override: List[str] = self.get_override()
Ejemplo n.º 3
0
 def __init__(self):
     super().__init__(self.get_name(), "builtins.type." + self.get_name(),
                      FilePosition.get_empty_file_position())