MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / _anon_member_label

Function _anon_member_label

scripts/code_verify_rules.py:2605–2635  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

2603
2604
2605def _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# ---------------------------------------------------------------------------

Callers 1

_cpp_rulesFunction · 0.85

Calls 4

_function_nameFunction · 0.85
_type_nameFunction · 0.85
_walkFunction · 0.85
_node_textFunction · 0.85

Tested by

no test coverage detected