extractField (2046) — field_declaration; each declarator becomes a field/constant node anchored at the DECLARATOR, and the declarator — its `= initializer` — is walked with that node on the stack. Returns the walked declarators, for the fn-ref scan to skip.
(&mut self, node: Node<'t>)
| 873 | /// its `= initializer` — is walked with that node on the stack. Returns |
| 874 | /// the walked declarators, for the fn-ref scan to skip. |
| 875 | fn extract_field(&mut self, node: Node<'t>) -> Vec<usize> { |
| 876 | let mut walked = Vec::new(); |
| 877 | let docstring = preceding_docstring(node, self.src); |
| 878 | let visibility = Some(self.visibility_of(node)); |
| 879 | let is_static = Some(self.is_static(node)); |
| 880 | // `const` / `static readonly` → constant (value-ref targets). |
| 881 | let field_kind: &'static str = if self.is_const(node) { "constant" } else { "field" }; |
| 882 | |
| 883 | // Direct declarators (Java shape) — none for C#; the wrapper path: |
| 884 | let mut declarators: Vec<Node> = (0..node.named_child_count()) |
| 885 | .filter_map(|i| node.named_child(i)) |
| 886 | .filter(|c| c.kind() == "variable_declarator") |
| 887 | .collect(); |
| 888 | let var_decl = (0..node.named_child_count()) |
| 889 | .filter_map(|i| node.named_child(i)) |
| 890 | .find(|c| c.kind() == "variable_declaration"); |
| 891 | if declarators.is_empty() { |
| 892 | if let Some(vd) = var_decl { |
| 893 | declarators = (0..vd.named_child_count()) |
| 894 | .filter_map(|i| vd.named_child(i)) |
| 895 | .filter(|c| c.kind() == "variable_declarator") |
| 896 | .collect(); |
| 897 | } |
| 898 | } |
| 899 | // (PHP property_element branch: unreachable for C#.) |
| 900 | |
| 901 | if !declarators.is_empty() { |
| 902 | let type_search = var_decl.unwrap_or(node); |
| 903 | let type_node = (0..type_search.named_child_count()) |
| 904 | .filter_map(|i| type_search.named_child(i)) |
| 905 | .find(|c| { |
| 906 | !matches!( |
| 907 | c.kind(), |
| 908 | "modifiers" | "modifier" | "variable_declarator" | "variable_declaration" |
| 909 | | "marker_annotation" | "annotation" |
| 910 | ) |
| 911 | }); |
| 912 | let type_text = type_node.map(|t| self.text(t).to_string()); |
| 913 | |
| 914 | for decl in declarators { |
| 915 | let name_node = decl.child_by_field_name("name").or_else(|| { |
| 916 | (0..decl.named_child_count()) |
| 917 | .filter_map(|i| decl.named_child(i)) |
| 918 | .find(|c| c.kind() == "identifier") |
| 919 | }); |
| 920 | let Some(name_node) = name_node else { continue }; |
| 921 | let name = self.text(name_node).to_string(); |
| 922 | let signature = match &type_text { |
| 923 | Some(t) => format!("{t} {name}"), |
| 924 | None => name.clone(), |
| 925 | }; |
| 926 | let row = self.create_node( |
| 927 | field_kind, |
| 928 | &name, |
| 929 | decl, |
| 930 | Extra { |
| 931 | docstring: docstring.clone(), |
| 932 | signature: Some(signature), |
no test coverage detected