Extract an interface declaration.
(state: &mut ExtractionState, node: TsNode<'_>)
| 362 | |
| 363 | /// Extract an interface declaration. |
| 364 | fn visit_interface(state: &mut ExtractionState, node: TsNode<'_>) { |
| 365 | let name = find_direct_child_by_kind(node, "name") |
| 366 | .map_or_else(|| "<anonymous>".to_string(), |n| state.node_text(n)); |
| 367 | |
| 368 | let visibility = Visibility::Pub; |
| 369 | let docstring = Self::extract_docstring(state, node); |
| 370 | let start_line = node.start_position().row as u32; |
| 371 | let end_line = node.end_position().row as u32; |
| 372 | let start_column = node.start_position().column as u32; |
| 373 | let end_column = node.end_position().column as u32; |
| 374 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 375 | let id = generate_node_id(&state.file_path, &NodeKind::Trait, &name, start_line); |
| 376 | |
| 377 | let graph_node = Node { |
| 378 | id: id.clone(), |
| 379 | kind: NodeKind::Trait, |
| 380 | name: name.clone(), |
| 381 | qualified_name, |
| 382 | file_path: state.file_path.clone(), |
| 383 | start_line, |
| 384 | attrs_start_line: start_line, |
| 385 | end_line, |
| 386 | start_column, |
| 387 | end_column, |
| 388 | signature: Some(format!("interface {name}")), |
| 389 | docstring, |
| 390 | visibility, |
| 391 | is_async: false, |
| 392 | branches: 0, |
| 393 | loops: 0, |
| 394 | returns: 0, |
| 395 | max_nesting: 0, |
| 396 | unsafe_blocks: 0, |
| 397 | unchecked_calls: 0, |
| 398 | assertions: 0, |
| 399 | updated_at: state.timestamp, |
| 400 | parent_id: None, |
| 401 | }; |
| 402 | state.nodes.push(graph_node); |
| 403 | |
| 404 | // Contains edge from parent. |
| 405 | if let Some(parent_id) = state.parent_node_id() { |
| 406 | state.edges.push(Edge { |
| 407 | source: parent_id.to_string(), |
| 408 | target: id.clone(), |
| 409 | kind: EdgeKind::Contains, |
| 410 | line: Some(start_line), |
| 411 | }); |
| 412 | } |
| 413 | |
| 414 | // Visit interface body. |
| 415 | state.node_stack.push((name.clone(), id)); |
| 416 | state.class_depth += 1; |
| 417 | if let Some(body) = find_direct_child_by_kind(node, "declaration_list") { |
| 418 | Self::visit_class_body(state, body); |
| 419 | } |
| 420 | state.class_depth -= 1; |
| 421 | state.node_stack.pop(); |
nothing calls this directly
no test coverage detected