Extract base class name text from a single base_class child node.
| 1926 | |
| 1927 | // Extract base class name text from a single base_class child node. |
| 1928 | static char *extract_cpp_base_text(CBMArena *a, TSNode bc, const char *source) { |
| 1929 | const char *bk = ts_node_type(bc); |
| 1930 | if (strcmp(bk, "access_specifier") == 0) { |
| 1931 | return NULL; |
| 1932 | } |
| 1933 | if (strcmp(bk, "type_identifier") == 0 || strcmp(bk, "qualified_identifier") == 0 || |
| 1934 | strcmp(bk, "scoped_identifier") == 0) { |
| 1935 | /* A qualified base may embed a template_type in its `name` field |
| 1936 | * (e.g. `std::vector<T>`), so the raw text carries `<...>` args. |
| 1937 | * Strip the generic argument list to keep the bare qualified name. */ |
| 1938 | char *t = cbm_node_text(a, bc, source); |
| 1939 | if (t) { |
| 1940 | char *angle = strchr(t, '<'); |
| 1941 | if (angle) { |
| 1942 | *angle = '\0'; |
| 1943 | } |
| 1944 | } |
| 1945 | return t; |
| 1946 | } |
| 1947 | if (strcmp(bk, "template_type") == 0) { |
| 1948 | TSNode tname = ts_node_child_by_field_name(bc, TS_FIELD("name")); |
| 1949 | if (!ts_node_is_null(tname)) { |
| 1950 | return cbm_node_text(a, tname, source); |
| 1951 | } |
| 1952 | } |
| 1953 | return NULL; |
| 1954 | } |
| 1955 | |
| 1956 | // Extract base classes from a C++ base_class_clause node. |
| 1957 | static const char **extract_cpp_base_classes(CBMArena *a, TSNode clause, const char *source) { |
no test coverage detected