NewChild creates a new child of the given type and adds it at the end of the list of children. The name defaults to the ID (kebab-case) name of the type, plus the [Node.NumLifetimeChildren] of the parent.
(typ *types.Type)
| 315 | // of the list of children. The name defaults to the ID (kebab-case) name |
| 316 | // of the type, plus the [Node.NumLifetimeChildren] of the parent. |
| 317 | func (n *NodeBase) NewChild(typ *types.Type) Node { |
| 318 | kid := newOfType(typ) |
| 319 | InitNode(kid) |
| 320 | n.Children = append(n.Children, kid) |
| 321 | SetParent(kid, n) |
| 322 | return kid |
| 323 | } |
| 324 | |
| 325 | // InsertChild adds given child at position in children list. |
| 326 | // The kid node is assumed to not be on another tree (see [MoveToParent]) |