Extract a property declaration inside a class.
(state: &mut ExtractionState, node: TsNode<'_>)
| 858 | |
| 859 | /// Extract a property declaration inside a class. |
| 860 | fn visit_property_declaration(state: &mut ExtractionState, node: TsNode<'_>) { |
| 861 | let visibility = Self::extract_visibility(state, node); |
| 862 | |
| 863 | // property_declaration contains one or more property_element children. |
| 864 | let mut cursor = node.walk(); |
| 865 | if cursor.goto_first_child() { |
| 866 | loop { |
| 867 | let child = cursor.node(); |
| 868 | if child.kind() == "property_element" || child.kind() == "variable_name" { |
| 869 | let name = if child.kind() == "property_element" { |
| 870 | find_direct_child_by_kind(child, "variable_name") |
| 871 | .map_or_else(|| state.node_text(child), |n| state.node_text(n)) |
| 872 | } else { |
| 873 | state.node_text(child) |
| 874 | }; |
| 875 | // Strip leading $ from variable names. |
| 876 | let name = name.trim_start_matches('$').to_string(); |
| 877 | |
| 878 | let start_line = child.start_position().row as u32; |
| 879 | let end_line = child.end_position().row as u32; |
| 880 | let start_column = child.start_position().column as u32; |
| 881 | let end_column = child.end_position().column as u32; |
| 882 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 883 | let id = |
| 884 | generate_node_id(&state.file_path, &NodeKind::Field, &name, start_line); |
| 885 | |
| 886 | let graph_node = Node { |
| 887 | id: id.clone(), |
| 888 | kind: NodeKind::Field, |
| 889 | name: name.clone(), |
| 890 | qualified_name, |
| 891 | file_path: state.file_path.clone(), |
| 892 | start_line, |
| 893 | attrs_start_line: start_line, |
| 894 | end_line, |
| 895 | start_column, |
| 896 | end_column, |
| 897 | signature: Some(state.node_text(node).trim().to_string()), |
| 898 | docstring: None, |
| 899 | visibility: visibility.clone(), |
| 900 | is_async: false, |
| 901 | branches: 0, |
| 902 | loops: 0, |
| 903 | returns: 0, |
| 904 | max_nesting: 0, |
| 905 | unsafe_blocks: 0, |
| 906 | unchecked_calls: 0, |
| 907 | assertions: 0, |
| 908 | updated_at: state.timestamp, |
| 909 | parent_id: None, |
| 910 | }; |
| 911 | state.nodes.push(graph_node); |
| 912 | |
| 913 | if let Some(parent_id) = state.parent_node_id() { |
| 914 | state.edges.push(Edge { |
| 915 | source: parent_id.to_string(), |
| 916 | target: id.clone(), |
| 917 | kind: EdgeKind::Contains, |
nothing calls this directly
no test coverage detected