fillInTree processes the refgroups in the tree rooted at `rg`, setting default names where they are missing, verifying that they are all defined, adding "Other" groups where needed, and adding the refgroups in depth-first-traversal order to `refGrouper.refGroups`.
(rg *refGroup)
| 294 | // are all defined, adding "Other" groups where needed, and adding the |
| 295 | // refgroups in depth-first-traversal order to `refGrouper.refGroups`. |
| 296 | func (refGrouper *refGrouper) fillInTree(rg *refGroup) error { |
| 297 | if rg.Name == "" { |
| 298 | _, rg.Name = splitKey(string(rg.Symbol)) |
| 299 | } |
| 300 | |
| 301 | if rg.filter == nil && len(rg.subgroups) == 0 { |
| 302 | return fmt.Errorf("refgroup '%s' is not defined", rg.Symbol) |
| 303 | } |
| 304 | |
| 305 | refGrouper.refGroups = append(refGrouper.refGroups, rg.RefGroup) |
| 306 | |
| 307 | for _, rg := range rg.subgroups { |
| 308 | if err := refGrouper.fillInTree(rg); err != nil { |
| 309 | return err |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | if len(rg.subgroups) != 0 { |
| 314 | var otherSymbol sizes.RefGroupSymbol |
| 315 | if rg.Symbol == "" { |
| 316 | otherSymbol = "other" |
| 317 | } else { |
| 318 | otherSymbol = sizes.RefGroupSymbol(fmt.Sprintf("%s.other", rg.Symbol)) |
| 319 | } |
| 320 | rg.otherRefGroup = &sizes.RefGroup{ |
| 321 | Symbol: otherSymbol, |
| 322 | Name: "Other", |
| 323 | } |
| 324 | refGrouper.refGroups = append(refGrouper.refGroups, *rg.otherRefGroup) |
| 325 | } |
| 326 | |
| 327 | return nil |
| 328 | } |
| 329 | |
| 330 | // Categorize decides whether to walk the reference named `refname` |
| 331 | // and which refgroup(s) it should be counted in. |
no test coverage detected