Return a short human label for a top-level entity inside an anonymous namespace -- function name, type name, or first declared identifier -- so the report can point at the actual symbol rather than just the line.
(node, src: bytes)
| 2603 | |
| 2604 | |
| 2605 | def _anon_member_label(node, src: bytes) -> str: |
| 2606 | """Return a short human label for a top-level entity inside an anonymous |
| 2607 | namespace -- function name, type name, or first declared identifier -- |
| 2608 | so the report can point at the actual symbol rather than just the line.""" |
| 2609 | if node.type == "function_definition": |
| 2610 | name = _function_name(node, src) |
| 2611 | return name if name else "<function>" |
| 2612 | if node.type in ( |
| 2613 | "class_specifier", |
| 2614 | "struct_specifier", |
| 2615 | "enum_specifier", |
| 2616 | "union_specifier", |
| 2617 | "type_definition", |
| 2618 | "alias_declaration", |
| 2619 | ): |
| 2620 | name = _type_name(node, src) |
| 2621 | return name if name else "<type>" |
| 2622 | if node.type == "template_declaration": |
| 2623 | for child in node.children: |
| 2624 | if child.type in ( |
| 2625 | "function_definition", |
| 2626 | "class_specifier", |
| 2627 | "struct_specifier", |
| 2628 | ): |
| 2629 | return _anon_member_label(child, src) |
| 2630 | return "<template>" |
| 2631 | if node.type == "declaration": |
| 2632 | for child in _walk(node): |
| 2633 | if child.type in ("identifier", "field_identifier"): |
| 2634 | return _node_text(child, src) |
| 2635 | return "<entity>" |
| 2636 | |
| 2637 | |
| 2638 | # --------------------------------------------------------------------------- |
no test coverage detected