MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / visit_enum

Method visit_enum

src/extraction/zig_extractor.rs:410–466  ·  view source on GitHub ↗

Extract an enum definition: `const LogLevel = enum { ... }`.

(
        state: &mut ExtractionState,
        decl_node: TsNode<'_>,
        enum_node: TsNode<'_>,
        name: &str,
    )

Source from the content-addressed store, hash-verified

408
409 /// Extract an enum definition: `const LogLevel = enum { ... }`.
410 fn visit_enum(
411 state: &mut ExtractionState,
412 decl_node: TsNode<'_>,
413 enum_node: TsNode<'_>,
414 name: &str,
415 ) {
416 let docstring = Self::extract_docstring(state, decl_node);
417 let signature = Self::extract_first_line_signature(state, decl_node);
418 let start_line = decl_node.start_position().row as u32;
419 let end_line = decl_node.end_position().row as u32;
420 let start_column = decl_node.start_position().column as u32;
421 let end_column = decl_node.end_position().column as u32;
422 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
423 let id = generate_node_id(&state.file_path, &NodeKind::Enum, name, start_line);
424
425 let graph_node = Node {
426 id: id.clone(),
427 kind: NodeKind::Enum,
428 name: name.to_string(),
429 qualified_name,
430 file_path: state.file_path.clone(),
431 start_line,
432 attrs_start_line: start_line,
433 end_line,
434 start_column,
435 end_column,
436 signature,
437 docstring,
438 visibility: Visibility::Pub,
439 is_async: false,
440 branches: 0,
441 loops: 0,
442 returns: 0,
443 max_nesting: 0,
444 unsafe_blocks: 0,
445 unchecked_calls: 0,
446 assertions: 0,
447 updated_at: state.timestamp,
448 parent_id: None,
449 };
450 state.nodes.push(graph_node);
451
452 // Contains edge from parent.
453 if let Some(parent_id) = state.parent_node_id() {
454 state.edges.push(Edge {
455 source: parent_id.to_string(),
456 target: id.clone(),
457 kind: EdgeKind::Contains,
458 line: Some(start_line),
459 });
460 }
461
462 // Visit enum body for variants.
463 state.node_stack.push((name.to_string(), id));
464 Self::visit_enum_body(state, enum_node);
465 state.node_stack.pop();
466 }
467

Callers

nothing calls this directly

Calls 3

generate_node_idFunction · 0.85
pushMethod · 0.80
parent_node_idMethod · 0.45

Tested by

no test coverage detected