Extract Field nodes from the bindings inside a derivation attrset.
(
state: &mut ExtractionState,
attrset_node: TsNode<'_>,
parent_id: &str,
)
| 682 | |
| 683 | /// Extract Field nodes from the bindings inside a derivation attrset. |
| 684 | fn extract_derivation_fields( |
| 685 | state: &mut ExtractionState, |
| 686 | attrset_node: TsNode<'_>, |
| 687 | parent_id: &str, |
| 688 | ) { |
| 689 | let mut cursor = attrset_node.walk(); |
| 690 | if cursor.goto_first_child() { |
| 691 | loop { |
| 692 | let child = cursor.node(); |
| 693 | if child.kind() == "binding_set" { |
| 694 | let mut inner = child.walk(); |
| 695 | if inner.goto_first_child() { |
| 696 | loop { |
| 697 | let item = inner.node(); |
| 698 | if item.kind() == "binding" { |
| 699 | if let Some(field_name) = Self::extract_binding_name(state, item) { |
| 700 | let start_line = item.start_position().row as u32; |
| 701 | let end_line = item.end_position().row as u32; |
| 702 | let start_column = item.start_position().column as u32; |
| 703 | let end_column = item.end_position().column as u32; |
| 704 | let kind = NodeKind::Field; |
| 705 | let qualified_name = |
| 706 | format!("{}::{}", state.qualified_prefix(), field_name); |
| 707 | let id = generate_node_id( |
| 708 | &state.file_path, |
| 709 | &kind, |
| 710 | &field_name, |
| 711 | start_line, |
| 712 | ); |
| 713 | |
| 714 | let text = state.node_text(item); |
| 715 | let signature = text |
| 716 | .lines() |
| 717 | .next() |
| 718 | .map(|l| l.trim().to_string()) |
| 719 | .filter(|l| !l.is_empty()); |
| 720 | |
| 721 | let graph_node = Node { |
| 722 | id: id.clone(), |
| 723 | kind, |
| 724 | name: field_name, |
| 725 | qualified_name, |
| 726 | file_path: state.file_path.clone(), |
| 727 | start_line, |
| 728 | attrs_start_line: start_line, |
| 729 | end_line, |
| 730 | start_column, |
| 731 | end_column, |
| 732 | signature, |
| 733 | docstring: None, |
| 734 | visibility: Visibility::Pub, |
| 735 | is_async: false, |
| 736 | branches: 0, |
| 737 | loops: 0, |
| 738 | returns: 0, |
| 739 | max_nesting: 0, |
| 740 | unsafe_blocks: 0, |
| 741 | unchecked_calls: 0, |
nothing calls this directly
no test coverage detected