Extract LABEL instruction key-value pairs as Field nodes.
(state: &mut ExtractionState, node: TsNode<'_>)
| 491 | |
| 492 | /// Extract LABEL instruction key-value pairs as Field nodes. |
| 493 | fn visit_label(state: &mut ExtractionState, node: TsNode<'_>) { |
| 494 | let mut cursor = node.walk(); |
| 495 | if cursor.goto_first_child() { |
| 496 | loop { |
| 497 | let child = cursor.node(); |
| 498 | if child.kind() == "label_pair" { |
| 499 | let key = if let Some(n) = child.child_by_field_name("key") { |
| 500 | state.node_text(n) |
| 501 | } else { |
| 502 | if !cursor.goto_next_sibling() { |
| 503 | break; |
| 504 | } |
| 505 | continue; |
| 506 | }; |
| 507 | |
| 508 | let start_line = child.start_position().row as u32; |
| 509 | let end_line = child.end_position().row as u32; |
| 510 | let start_column = child.start_position().column as u32; |
| 511 | let end_column = child.end_position().column as u32; |
| 512 | let text = state.node_text(child); |
| 513 | let qualified_name = format!("{}::{}", state.qualified_prefix(), key); |
| 514 | let id = generate_node_id(&state.file_path, &NodeKind::Field, &key, start_line); |
| 515 | |
| 516 | let graph_node = Node { |
| 517 | id: id.clone(), |
| 518 | kind: NodeKind::Field, |
| 519 | name: key, |
| 520 | qualified_name, |
| 521 | file_path: state.file_path.clone(), |
| 522 | start_line, |
| 523 | attrs_start_line: start_line, |
| 524 | end_line, |
| 525 | start_column, |
| 526 | end_column, |
| 527 | signature: Some(format!("LABEL {}", text.trim())), |
| 528 | docstring: None, |
| 529 | visibility: Visibility::Pub, |
| 530 | is_async: false, |
| 531 | branches: 0, |
| 532 | loops: 0, |
| 533 | returns: 0, |
| 534 | max_nesting: 0, |
| 535 | unsafe_blocks: 0, |
| 536 | unchecked_calls: 0, |
| 537 | assertions: 0, |
| 538 | updated_at: state.timestamp, |
| 539 | parent_id: None, |
| 540 | }; |
| 541 | state.nodes.push(graph_node); |
| 542 | |
| 543 | // Contains edge from parent. |
| 544 | if let Some(parent_id) = state.parent_node_id() { |
| 545 | state.edges.push(Edge { |
| 546 | source: parent_id.to_string(), |
| 547 | target: id, |
| 548 | kind: EdgeKind::Contains, |
| 549 | line: Some(start_line), |
| 550 | }); |
nothing calls this directly
no test coverage detected