Skip to main content

cpp_syntax_may_spell_member

Function cpp_syntax_may_spell_member 

Source
pub fn cpp_syntax_may_spell_member(
    root: Node<'_>,
    source: &str,
    identifier: &str,
) -> bool
Expand description

Whether a member named identifier can be spelled anywhere in this file’s syntax.

Both member scans below – [maybe_record_method_hit] and [maybe_record_member_field_hit] – begin by comparing the terminal name of a syntax node against the target’s member name, so a file whose syntax never spells that name yields neither a proven nor an unproven hit. That makes this an exact admission test rather than an approximation: candidate discovery can drop such a file without narrowing what the query proves.

Only tree-sitter nodes are read. Two node kinds carry text the C++ grammar does not tokenize into identifiers – a function-like macro’s preproc_arg replacement, which [maybe_record_function_macro_replacement_method_hits] recovers by its own sentinel parse, and an ERROR region – so those admit on containment instead of on a token match. A comment is the one subtree no scan reads, so it is skipped.

Defined only for a plain identifier: name_matches_callable widens the comparison for an operator name to the operator token alone, and a destructor or conversion-function name is not spelled the way it is recorded. cpp_member_is_spelled_at_references is the admission side of that condition.