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

Method visit_struct

src/extraction/csharp_extractor.rs:387–447  ·  view source on GitHub ↗

Extract a struct declaration.

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

Source from the content-addressed store, hash-verified

385
386 /// Extract a struct declaration.
387 fn visit_struct(state: &mut ExtractionState, node: TsNode<'_>) {
388 let name = Self::extract_name(state, node).unwrap_or_else(|| "<anonymous>".to_string());
389 let visibility = Self::extract_csharp_visibility(node, state);
390 let docstring = Self::extract_xml_docstring(state, node);
391 let signature = Some(Self::extract_declaration_signature(state, node));
392 let start_line = node.start_position().row as u32;
393 let end_line = node.end_position().row as u32;
394 let start_column = node.start_position().column as u32;
395 let end_column = node.end_position().column as u32;
396 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
397 let id = generate_node_id(&state.file_path, &NodeKind::Struct, &name, start_line);
398
399 let graph_node = Node {
400 id: id.clone(),
401 kind: NodeKind::Struct,
402 name: name.clone(),
403 qualified_name,
404 file_path: state.file_path.clone(),
405 start_line,
406 attrs_start_line: start_line,
407 end_line,
408 start_column,
409 end_column,
410 signature,
411 docstring,
412 visibility,
413 is_async: false,
414 branches: 0,
415 loops: 0,
416 returns: 0,
417 max_nesting: 0,
418 unsafe_blocks: 0,
419 unchecked_calls: 0,
420 assertions: 0,
421 updated_at: state.timestamp,
422 parent_id: None,
423 };
424 state.nodes.push(graph_node);
425
426 // Contains edge from parent.
427 if let Some(parent_id) = state.parent_node_id() {
428 state.edges.push(Edge {
429 source: parent_id.to_string(),
430 target: id.clone(),
431 kind: EdgeKind::Contains,
432 line: Some(start_line),
433 });
434 }
435
436 // Extract base list (struct can implement interfaces).
437 Self::extract_base_list(state, node, &id, false);
438
439 // Visit struct body.
440 state.node_stack.push((name, id));
441 state.class_depth += 1;
442 if let Some(body) = node.child_by_field_name("body") {
443 Self::visit_children(state, body);
444 }

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected