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
| 846 | // const", and a member lookup for "operator bool" (the implicit call in |
| 847 | // `if (obj)`) misses. |
| 848 | char *cbm_func_name_node_text(CBMArena *a, TSNode name_node, const char *source, CBMLanguage lang) { |
| 849 | char *text = cbm_node_text(a, name_node, source); |
| 850 | if (text && strcmp(ts_node_type(name_node), "operator_cast") == 0) { |
| 851 | char *paren = strchr(text, '('); |
| 852 | if (paren) { |
| 853 | while (paren > text && (paren[-1] == ' ' || paren[-1] == '\t')) { |
| 854 | paren--; |
| 855 | } |
| 856 | *paren = '\0'; |
| 857 | } |
| 858 | } |
| 859 | /* Nix quoted attrpath segment: `"kebab-case" = a: a;` and `services."my.svc" = …` |
| 860 | * are ordinary names that merely need quoting in source. The node text carries |
| 861 | * the delimiters, so without this the def is named `"kebab-case"` — quotes and |
| 862 | * all — and every consumer keying on the name (search, CALLS resolution, the |
| 863 | * LSP join) would have to know to re-quote. Stripped here rather than in the |
| 864 | * resolver so the def name and the call-scope QN, which both route through this |
| 865 | * function, cannot disagree. */ |
| 866 | if (text && lang == CBM_LANG_NIX) { |
| 867 | cbm_nix_strip_attr_quotes(text); |
| 868 | } |
| 869 | return text; |
| 870 | } |
| 871 | |
| 872 | /* ── Nix attrpath helpers ─────────────────────────────────── |
| 873 | * A Nix binding's name is a PATH (`a.b.c = …`), whose segments may be quoted or |
no test coverage detected