src/basilisp/lang/compiler/nodes.py
def fix_missing_locations(
        self, start_loc: Optional[Tuple[int, int]] = None
    ) -> "Node":
        """Return a transformed copy of this node with location in this node's
        environment updated to match the `start_loc` if given, or using its
        existing location otherwise. All child nodes will be recursively
        transformed and replaced. Child nodes will use their parent node
        location if they do not have one."""
        if self.env.line is None or self.env.col is None:
            loc = start_loc
        else:
            loc = (self.env.line, self.env.col)

        assert loc is not None and all(
            [e is not None for e in loc]
        ), "Must specify location information"

        new_attrs: MutableMapping[str, Union[NodeEnv, Node, Iterable[Node]]] = {
            "env": attr.evolve(self.env, line=loc[0], col=loc[1])
        }
        for child_kw in self.children:
            child_attr = munge(child_kw.name)
            assert child_attr != "env", "Node environment already set"

            if child_attr.endswith("s"):
                iter_child: Iterable[Node] = getattr(self, child_attr)
                assert iter_child is not None, "Listed child must not be none"
                new_children = []
                for item in iter_child:
                    new_children.append(item.fix_missing_locations(start_loc))
                new_attrs[child_attr] = vec.vector(new_children)
            else:
                child: Node = getattr(self, child_attr)
                assert child is not None, "Listed child must not be none"
                new_attrs[child_attr] = child.fix_missing_locations(start_loc)

        return self.assoc(**new_attrs)
def fix_missing_locations(
        self, start_loc: Optional[Tuple[int, int]] = None
    ) -> "Node":
        if self.env.line is None or self.env.col is None:
            loc = start_loc
        else:
            loc = (self.env.line, self.env.col)

        assert loc is not None and all(
            [e is not None for e in loc]
        ), "Must specify location information"

        new_attrs: MutableMapping[str, Union[NodeEnv, Node, Iterable[Node]]] = {
            "env": attr.evolve(self.env, line=loc[0], col=loc[1])
        }
        for child_kw in self.children:
            child_attr = munge(child_kw.name)
            assert child_attr != "env", "Node environment already set"

            if child_attr.endswith("s"):
                iter_child: Iterable[Node] = getattr(self, child_attr)
                assert iter_child is not None, "Listed child must not be none"
                new_children = []
                for item in iter_child:
                    new_children.append(item.fix_missing_locations(start_loc))
                new_attrs[child_attr] = vec.vector(new_children)
            else:
                child: Node = getattr(self, child_attr)
                assert child is not None, "Listed child must not be none"
                new_attrs[child_attr] = child.fix_missing_locations(start_loc)

        return self.assoc(**new_attrs)
def fix_missing_locations ( self , start_loc : Optional [ Tuple [ int , int ] ] = None ) -> "Node" : if self . env . line is None or self . env . col is None : loc = start_loc else : loc = ( self . env . line , self . env . col ) assert loc is not None and all ( [ e is not None for e in loc ] ) , "Must specify location information" new_attrs : MutableMapping [ str , Union [ NodeEnv , Node , Iterable [ Node ] ] ] = { "env" : attr . evolve ( self . env , line = loc [ 0 ] , col = loc [ 1 ] ) } for child_kw in self . children : child_attr = munge ( child_kw . name ) assert child_attr != "env" , "Node environment already set" if child_attr . endswith ( "s" ) : iter_child : Iterable [ Node ] = getattr ( self , child_attr ) assert iter_child is not None , "Listed child must not be none" new_children = [ ] for item in iter_child : new_children . append ( item . fix_missing_locations ( start_loc ) ) new_attrs [ child_attr ] = vec . vector ( new_children ) else : child : Node = getattr ( self , child_attr ) assert child is not None , "Listed child must not be none" new_attrs [ child_attr ] = child . fix_missing_locations ( start_loc ) return self . assoc ( * * new_attrs )
Return a transformed copy of this node with location in this node's
        environment updated to match the `start_loc` if given, or using its
        existing location otherwise. All child nodes will be recursively
        transformed and replaced. Child nodes will use their parent node
        location if they do not have one.
Return a transformed copy of this node with location in this node s environment updated to match the start_loc if given or using its existing location otherwise . All child nodes will be recursively transformed and replaced . Child nodes will use their parent node location if they do not have one .