Extract base class name text from a single base_class child node.
| 2047 | |
| 2048 | // Extract base class name text from a single base_class child node. |
| 2049 | static char *extract_cpp_base_text(CBMArena *a, TSNode bc, const char *source) { |
| 2050 | const char *bk = ts_node_type(bc); |
| 2051 | if (strcmp(bk, "access_specifier") == 0) { |
| 2052 | return NULL; |
| 2053 | } |
| 2054 | if (strcmp(bk, "type_identifier") == 0 || strcmp(bk, "qualified_identifier") == 0 || |
| 2055 | strcmp(bk, "scoped_identifier") == 0) { |
| 2056 | /* A qualified base may embed a template_type in its `name` field |
| 2057 | * (e.g. `std::vector<T>`), so the raw text carries `<...>` args. |
| 2058 | * Strip the generic argument list to keep the bare qualified name. */ |
| 2059 | char *t = cbm_node_text(a, bc, source); |
| 2060 | if (t) { |
| 2061 | char *angle = strchr(t, '<'); |
| 2062 | if (angle) { |
| 2063 | *angle = '\0'; |
| 2064 | } |
| 2065 | } |
| 2066 | return t; |
| 2067 | } |
| 2068 | if (strcmp(bk, "template_type") == 0) { |
| 2069 | TSNode tname = ts_node_child_by_field_name(bc, TS_FIELD("name")); |
| 2070 | if (!ts_node_is_null(tname)) { |
| 2071 | return cbm_node_text(a, tname, source); |
| 2072 | } |
| 2073 | } |
| 2074 | return NULL; |
| 2075 | } |
| 2076 | |
| 2077 | // Extract base classes from a C++ base_class_clause node. |
| 2078 | static const char **extract_cpp_base_classes(CBMArena *a, TSNode clause, const char *source) { |
no test coverage detected