Extract base class name text from a single base_class child node.
| 2090 | |
| 2091 | // Extract base class name text from a single base_class child node. |
| 2092 | static char *extract_cpp_base_text(CBMArena *a, TSNode bc, const char *source) { |
| 2093 | const char *bk = ts_node_type(bc); |
| 2094 | if (strcmp(bk, "access_specifier") == 0) { |
| 2095 | return NULL; |
| 2096 | } |
| 2097 | if (strcmp(bk, "type_identifier") == 0 || strcmp(bk, "qualified_identifier") == 0 || |
| 2098 | strcmp(bk, "scoped_identifier") == 0) { |
| 2099 | /* A qualified base may embed a template_type in its `name` field |
| 2100 | * (e.g. `std::vector<T>`), so the raw text carries `<...>` args. |
| 2101 | * Strip the generic argument list to keep the bare qualified name. */ |
| 2102 | char *t = cbm_node_text(a, bc, source); |
| 2103 | if (t) { |
| 2104 | char *angle = strchr(t, '<'); |
| 2105 | if (angle) { |
| 2106 | *angle = '\0'; |
| 2107 | } |
| 2108 | } |
| 2109 | return t; |
| 2110 | } |
| 2111 | if (strcmp(bk, "template_type") == 0) { |
| 2112 | TSNode tname = ts_node_child_by_field_name(bc, TS_FIELD("name")); |
| 2113 | if (!ts_node_is_null(tname)) { |
| 2114 | return cbm_node_text(a, tname, source); |
| 2115 | } |
| 2116 | } |
| 2117 | return NULL; |
| 2118 | } |
| 2119 | |
| 2120 | // Extract base classes from a C++ base_class_clause node. |
| 2121 | static const char **extract_cpp_base_classes(CBMArena *a, TSNode clause, const char *source) { |
no test coverage detected