Convert a resolved function/method name node to its name string. Most nodes map directly to their text, but a C++ conversion-operator's `operator_cast` node spans the full "operator bool() const" — this grammar folds the parameter list and cv-qualifiers into the node. The method's name is only the "operator " prefix, so truncate at the first '(' and trim trailing space. Without this the conv
| 1187 | // const", and a member lookup for "operator bool" (the implicit call in |
| 1188 | // `if (obj)`) misses. |
| 1189 | char *cbm_func_name_node_text(CBMArena *a, TSNode name_node, const char *source, CBMLanguage lang) { |
| 1190 | char *text = cbm_node_text(a, name_node, source); |
| 1191 | /* A C keyword is never a function name: the definition is an error-recovery |
| 1192 | * artifact. No name means no def and no call scope (calls inside fall back |
| 1193 | * to the enclosing scope), the same as any unnamed definition. */ |
| 1194 | if (text && c_declarator_lang(lang) && cbm_c_reserved_func_name(text)) { |
| 1195 | return NULL; |
| 1196 | } |
| 1197 | if (text && strcmp(ts_node_type(name_node), "operator_cast") == 0) { |
| 1198 | char *paren = strchr(text, '('); |
| 1199 | if (paren) { |
| 1200 | while (paren > text && (paren[-1] == ' ' || paren[-1] == '\t')) { |
| 1201 | paren--; |
| 1202 | } |
| 1203 | *paren = '\0'; |
| 1204 | } |
| 1205 | } |
| 1206 | /* Nix quoted attrpath segment: `"kebab-case" = a: a;` and `services."my.svc" = …` |
| 1207 | * are ordinary names that merely need quoting in source. The node text carries |
| 1208 | * the delimiters, so without this the def is named `"kebab-case"` — quotes and |
| 1209 | * all — and every consumer keying on the name (search, CALLS resolution, the |
| 1210 | * LSP join) would have to know to re-quote. Stripped here rather than in the |
| 1211 | * resolver so the def name and the call-scope QN, which both route through this |
| 1212 | * function, cannot disagree. */ |
| 1213 | if (text && lang == CBM_LANG_NIX) { |
| 1214 | cbm_nix_strip_attr_quotes(text); |
| 1215 | } |
| 1216 | return text; |
| 1217 | } |
| 1218 | |
| 1219 | /* ── Nix attrpath helpers ─────────────────────────────────── |
| 1220 | * A Nix binding's name is a PATH (`a.b.c = …`), whose segments may be quoted or |
no test coverage detected