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