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

Method visit_enum

src/extraction/java_extractor.rs:490–545  ·  view source on GitHub ↗

Extract an enum declaration with its constants.

(state: &mut ExtractionState, node: TsNode<'_>)

Source from the content-addressed store, hash-verified

488
489 /// Extract an enum declaration with its constants.
490 fn visit_enum(state: &mut ExtractionState, node: TsNode<'_>) {
491 let name = Self::extract_name(state, node).unwrap_or_else(|| "<anonymous>".to_string());
492 let visibility = Self::extract_java_visibility(node, state);
493 let docstring = Self::extract_java_docstring(state, node);
494 let signature = Some(Self::extract_declaration_signature(state, node));
495 let start_line = node.start_position().row as u32;
496 let end_line = node.end_position().row as u32;
497 let start_column = node.start_position().column as u32;
498 let end_column = node.end_position().column as u32;
499 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
500 let id = generate_node_id(&state.file_path, &NodeKind::Enum, &name, start_line);
501
502 let graph_node = Node {
503 id: id.clone(),
504 kind: NodeKind::Enum,
505 name: name.clone(),
506 qualified_name,
507 file_path: state.file_path.clone(),
508 start_line,
509 attrs_start_line: start_line,
510 end_line,
511 start_column,
512 end_column,
513 signature,
514 docstring,
515 visibility,
516 is_async: false,
517 branches: 0,
518 loops: 0,
519 returns: 0,
520 max_nesting: 0,
521 unsafe_blocks: 0,
522 unchecked_calls: 0,
523 assertions: 0,
524 updated_at: state.timestamp,
525 parent_id: None,
526 };
527 state.nodes.push(graph_node);
528
529 // Contains edge from parent.
530 if let Some(parent_id) = state.parent_node_id() {
531 state.edges.push(Edge {
532 source: parent_id.to_string(),
533 target: id.clone(),
534 kind: EdgeKind::Contains,
535 line: Some(start_line),
536 });
537 }
538
539 // Extract enum constants from the enum_body.
540 state.node_stack.push((name, id));
541 if let Some(body) = node.child_by_field_name("body") {
542 Self::extract_enum_constants(state, body);
543 }
544 state.node_stack.pop();
545 }
546
547 /// Extract enum constants from an `enum_body` node.

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