extractAnonymousClass — `new T() { ... }`.
(&mut self, node: Node<'t>, body: Node<'t>)
| 910 | |
| 911 | /// extractAnonymousClass — `new T() { ... }`. |
| 912 | fn extract_anonymous_class(&mut self, node: Node<'t>, body: Node<'t>) { |
| 913 | stack_guard!(); |
| 914 | let type_node = node |
| 915 | .child_by_field_name("constructor") |
| 916 | .or_else(|| node.child_by_field_name("type")) |
| 917 | .or_else(|| node.child_by_field_name("name")) |
| 918 | .or_else(|| node.named_child(0)); |
| 919 | let mut type_name = type_node.map(|t| self.text(t).to_string()).unwrap_or_else(|| "Object".to_string()); |
| 920 | type_name = strip_generic_and_qualifier(&type_name); |
| 921 | if type_name.is_empty() { |
| 922 | type_name = "Object".to_string(); |
| 923 | } |
| 924 | |
| 925 | let anon_name = format!("<{type_name}$anon@{}>", node.start_position().row + 1); |
| 926 | let Some(row) = self.create_node("class", &anon_name, node, Extra::default()) else { |
| 927 | return; |
| 928 | }; |
| 929 | // Bug-for-bug: the TS code uses `startPosition.row` (0-based) as the |
| 930 | // LINE here — the one place it forgets the +1. |
| 931 | let (line, column) = match type_node { |
| 932 | Some(t) => (t.start_position().row as u32, self.col_of(t)), |
| 933 | None => (node.start_position().row as u32, self.col_of(node)), |
| 934 | }; |
| 935 | self.push_ref(row, &type_name, edge_kind_index("extends").unwrap(), line, column); |
| 936 | |
| 937 | self.stack.push(Scope { row, kind: "class", name: anon_name }); |
| 938 | for i in 0..body.named_child_count() { |
| 939 | if let Some(c) = body.named_child(i) { |
| 940 | self.visit_node(c); |
| 941 | } |
| 942 | } |
| 943 | self.stack.pop(); |
| 944 | } |
| 945 | |
| 946 | /// extractStaticMemberRef — `Type.CONST` value reads (java: field_access). |
| 947 | fn extract_static_member_ref(&mut self, node: Node<'t>) { |
no test coverage detected