parameters: (self)
docstring: 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.
docstring_summary: Add computed nodes to the tree.
docstring_tokens: Add computed nodes to the tree .
function: 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 descendants of each node.
  
        Traverses upwards from each leaf, incrementing a counter.
  
        Args:
          node: Node to count descendants 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)
function_tokens: def _ComputeTreeData ( self ) : assert not self . root_child_nodes def TraverseToRoot ( node ) : """Count the number of leaf nodes existing as descendants of each node.
  
        Traverses upwards from each leaf, incrementing a counter.
  
        Args:
          node: Node to count descendants 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 )