cppWrittenClassParts (languages/c-cpp.ts): the `::` segments of a class, struct or union name written with a scope, the scope's template arguments dropped (`["SkipList", "Node"]` for `struct SkipList ::Node`). None for a plain name and for a specialization, whose innermost name has template arguments.
(&self, node: Node)
| 721 | /// Comparator>::Node`). None for a plain name and for a specialization, |
| 722 | /// whose innermost name has template arguments. |
| 723 | fn cpp_written_class_parts(&self, node: Node) -> Option<Vec<String>> { |
| 724 | if !matches!(node.kind(), "class_specifier" | "struct_specifier" | "union_specifier") { |
| 725 | return None; |
| 726 | } |
| 727 | let written = node.child_by_field_name("name")?; |
| 728 | if written.kind() != "qualified_identifier" { |
| 729 | return None; |
| 730 | } |
| 731 | let mut innermost = Some(written); |
| 732 | while let Some(n) = innermost.filter(|n| n.kind() == "qualified_identifier") { |
| 733 | innermost = n.child_by_field_name("name"); |
| 734 | } |
| 735 | if innermost.map(|n| n.kind()) != Some("type_identifier") { |
| 736 | return None; |
| 737 | } |
| 738 | let parts: Vec<String> = strip_cpp_template_args(self.text(written)) |
| 739 | .split("::") |
| 740 | .map(|p| p.trim().to_string()) |
| 741 | .filter(|p| !p.is_empty()) |
| 742 | .collect(); |
| 743 | let identifier = |p: &String| { |
| 744 | let mut chars = p.chars(); |
| 745 | chars.next().is_some_and(|c| c.is_ascii_alphabetic() || c == '_') |
| 746 | && chars.all(|c| c.is_ascii_alphanumeric() || c == '_') |
| 747 | }; |
| 748 | if parts.is_empty() || !parts.iter().all(identifier) { |
| 749 | return None; |
| 750 | } |
| 751 | Some(parts) |
| 752 | } |
| 753 | |
| 754 | /// writtenScopeQualifiedName (tree-sitter.ts): a class whose name is |
| 755 | /// written in a scope is qualified like an out-of-line method under it. |