Extract base class name text from a single base_class child node.
| 3803 | |
| 3804 | // Extract base class name text from a single base_class child node. |
| 3805 | static char *extract_cpp_base_text(CBMArena *a, TSNode bc, const char *source) { |
| 3806 | const char *bk = ts_node_type(bc); |
| 3807 | if (strcmp(bk, "access_specifier") == 0) { |
| 3808 | return NULL; |
| 3809 | } |
| 3810 | if (strcmp(bk, "type_identifier") == 0 || strcmp(bk, "qualified_identifier") == 0 || |
| 3811 | strcmp(bk, "scoped_identifier") == 0) { |
| 3812 | /* A qualified base may embed a template_type in its `name` field |
| 3813 | * (e.g. `std::vector<T>`), so the raw text carries `<...>` args. |
| 3814 | * Strip the generic argument list to keep the bare qualified name. */ |
| 3815 | char *t = cbm_node_text(a, bc, source); |
| 3816 | if (t) { |
| 3817 | char *angle = strchr(t, '<'); |
| 3818 | if (angle) { |
| 3819 | *angle = '\0'; |
| 3820 | } |
| 3821 | } |
| 3822 | return t; |
| 3823 | } |
| 3824 | if (strcmp(bk, "template_type") == 0) { |
| 3825 | TSNode tname = ts_node_child_by_field_name(bc, TS_FIELD("name")); |
| 3826 | if (!ts_node_is_null(tname)) { |
| 3827 | return cbm_node_text(a, tname, source); |
| 3828 | } |
| 3829 | } |
| 3830 | return NULL; |
| 3831 | } |
| 3832 | |
| 3833 | // Extract base classes from a C++ base_class_clause node. |
| 3834 | static const char **extract_cpp_base_classes(CBMArena *a, TSNode clause, const char *source) { |
no test coverage detected