zetasql/resolved_ast/gen_resolved_ast.py
def _ComputeTreeData(self):
    """Add computed nodes to the tree.

    Traverse the node tree hierarchy and add computed nodes that couldn't be
    built before we have the full tree.
    """
    assert not self.root_child_nodes

    def TraverseToRoot(node):
      """Count the number of leaf nodes existing as descendents of each node.

      Traverses upwards from each leaf, incrementing a counter.

      Args:
        node: Node to count descendents of.
      """
      node.setdefault('num_descendant_leaf_types', 0)
      node['num_descendant_leaf_types'] += 1

      for field in node['fields']:
        field_type = field['ctype']
        if field_type in self.node_map:
          field_node = self._GetNodeByName(field_type)
          field['proto_type'] = field_node['proto_field_type']

      parent_name = node['parent']
      if parent_name != ROOT_NODE_NAME:
        parent_node = self._GetNodeByName(parent_name)
        TraverseToRoot(parent_node)
        parent_subclass_list = parent_node['subclasses']
      else:
        parent_subclass_list = self.root_child_nodes

      # Note: this comparison is by value, so the transitive closure of <node>'s
      # entries cannot contain <node>.
      if node not in parent_subclass_list:
        parent_subclass_list.append(node)

    for node in self.nodes:
      if not node['is_abstract']:
        TraverseToRoot(node)
Add computed nodes to the tree.

    Traverse the node tree hierarchy and add computed nodes that couldn't be
    built before we have the full tree.
    
Add computed nodes to the tree.
Traverse the node tree hierarchy and add computed nodes that couldn't be
built before we have the full tree.
Add computed nodes to the tree . Traverse the node tree hierarchy and add computed nodes that couldn ' t be built before we have the full tree .
def _ComputeTreeData(self):
    assert not self.root_child_nodes
    def TraverseToRoot(node):
      node.setdefault('num_descendant_leaf_types', 0)
      node['num_descendant_leaf_types'] += 1
      for field in node['fields']:
        field_type = field['ctype']
        if field_type in self.node_map:
          field_node = self._GetNodeByName(field_type)
          field['proto_type'] = field_node['proto_field_type']
      parent_name = node['parent']
      if parent_name != ROOT_NODE_NAME:
        parent_node = self._GetNodeByName(parent_name)
        TraverseToRoot(parent_node)
        parent_subclass_list = parent_node['subclasses']
      else:
        parent_subclass_list = self.root_child_nodes
      if node not in parent_subclass_list:
        parent_subclass_list.append(node)
    for node in self.nodes:
      if not node['is_abstract']:
        TraverseToRoot(node)
def _ComputeTreeData ( self ) : assert not self . root_child_nodes def TraverseToRoot ( node ) : """Count the number of leaf nodes existing as descendents of each node.

      Traverses upwards from each leaf, incrementing a counter.

      Args:
        node: Node to count descendents of.
      """ node . setdefault ( 'num_descendant_leaf_types' , 0 ) node [ 'num_descendant_leaf_types' ] += 1 for field in node [ 'fields' ] : field_type = field [ 'ctype' ] if field_type in self . node_map : field_node = self . _GetNodeByName ( field_type ) field [ 'proto_type' ] = field_node [ 'proto_field_type' ] parent_name = node [ 'parent' ] if parent_name != ROOT_NODE_NAME : parent_node = self . _GetNodeByName ( parent_name ) TraverseToRoot ( parent_node ) parent_subclass_list = parent_node [ 'subclasses' ] else : parent_subclass_list = self . root_child_nodes if node not in parent_subclass_list : parent_subclass_list . append ( node ) for node in self . nodes : if not node [ 'is_abstract' ] : TraverseToRoot ( node )
Add computed nodes to the tree.
Add computed nodes to the tree .
"""Add computed nodes to the tree.

    Traverse the node tree hierarchy and add computed nodes that couldn't be
    built before we have the full tree.
    """ """Count the number of leaf nodes existing as descendents of each node.

      Traverses upwards from each leaf, incrementing a counter.

      Args:
        node: Node to count descendents of.
      """ # Note: this comparison is by value, so the transitive closure of <node>'s # entries cannot contain <node>.
self