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

Method visit_data_class

src/extraction/kotlin_extractor.rs:465–523  ·  view source on GitHub ↗

Extract a data class.

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

Source from the content-addressed store, hash-verified

463
464 /// Extract a data class.
465 fn visit_data_class(state: &mut ExtractionState, node: TsNode<'_>) {
466 let name = Self::extract_class_name(state, node);
467 let visibility = Self::extract_visibility(node, state);
468 let docstring = Self::extract_kdoc(state, node);
469 let signature = Some(Self::extract_declaration_signature(state, node));
470 let start_line = node.start_position().row as u32;
471 let end_line = node.end_position().row as u32;
472 let start_column = node.start_position().column as u32;
473 let end_column = node.end_position().column as u32;
474 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
475 let id = generate_node_id(&state.file_path, &NodeKind::DataClass, &name, start_line);
476
477 let graph_node = Node {
478 id: id.clone(),
479 kind: NodeKind::DataClass,
480 name: name.clone(),
481 qualified_name,
482 file_path: state.file_path.clone(),
483 start_line,
484 attrs_start_line: start_line,
485 end_line,
486 start_column,
487 end_column,
488 signature,
489 docstring,
490 visibility,
491 is_async: false,
492 branches: 0,
493 loops: 0,
494 returns: 0,
495 max_nesting: 0,
496 unsafe_blocks: 0,
497 unchecked_calls: 0,
498 assertions: 0,
499 updated_at: state.timestamp,
500 parent_id: None,
501 };
502 state.nodes.push(graph_node);
503
504 if let Some(parent_id) = state.parent_node_id() {
505 state.edges.push(Edge {
506 source: parent_id.to_string(),
507 target: id.clone(),
508 kind: EdgeKind::Contains,
509 line: Some(start_line),
510 });
511 }
512
513 Self::extract_annotations_from_modifiers(state, node, &id);
514 Self::extract_delegation_specifiers(state, node, &id);
515
516 state.node_stack.push((name, id));
517 state.class_depth += 1;
518 if let Some(body) = find_direct_child_by_kind(node, "class_body") {
519 Self::visit_children(state, body);
520 }
521 state.class_depth -= 1;
522 state.node_stack.pop();

Callers

nothing calls this directly

Calls 5

generate_node_idFunction · 0.85
visit_childrenFunction · 0.85
pushMethod · 0.80
parent_node_idMethod · 0.45

Tested by

no test coverage detected