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

Method visit_struct

src/extraction/zig_extractor.rs:327–385  ·  view source on GitHub ↗

Extract a struct definition: `const Point = struct { ... }`.

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

Source from the content-addressed store, hash-verified

325
326 /// Extract a struct definition: `const Point = struct { ... }`.
327 fn visit_struct(
328 state: &mut ExtractionState,
329 decl_node: TsNode<'_>,
330 struct_node: TsNode<'_>,
331 name: &str,
332 ) {
333 let docstring = Self::extract_docstring(state, decl_node);
334 let signature = Self::extract_first_line_signature(state, decl_node);
335 let start_line = decl_node.start_position().row as u32;
336 let end_line = decl_node.end_position().row as u32;
337 let start_column = decl_node.start_position().column as u32;
338 let end_column = decl_node.end_position().column as u32;
339 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
340 let id = generate_node_id(&state.file_path, &NodeKind::Struct, name, start_line);
341
342 let graph_node = Node {
343 id: id.clone(),
344 kind: NodeKind::Struct,
345 name: name.to_string(),
346 qualified_name,
347 file_path: state.file_path.clone(),
348 start_line,
349 attrs_start_line: start_line,
350 end_line,
351 start_column,
352 end_column,
353 signature,
354 docstring,
355 visibility: Visibility::Pub,
356 is_async: false,
357 branches: 0,
358 loops: 0,
359 returns: 0,
360 max_nesting: 0,
361 unsafe_blocks: 0,
362 unchecked_calls: 0,
363 assertions: 0,
364 updated_at: state.timestamp,
365 parent_id: None,
366 };
367 state.nodes.push(graph_node);
368
369 // Contains edge from parent.
370 if let Some(parent_id) = state.parent_node_id() {
371 state.edges.push(Edge {
372 source: parent_id.to_string(),
373 target: id.clone(),
374 kind: EdgeKind::Contains,
375 line: Some(start_line),
376 });
377 }
378
379 // Visit struct body for fields, methods, etc.
380 state.node_stack.push((name.to_string(), id));
381 state.class_depth += 1;
382 Self::visit_struct_body(state, struct_node);
383 state.class_depth -= 1;
384 state.node_stack.pop();

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