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

Method emit_use_node

src/extraction/lua_extractor.rs:383–428  ·  view source on GitHub ↗

Emit a Use node for a `require` call.

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

Source from the content-addressed store, hash-verified

381
382 /// Emit a Use node for a `require` call.
383 fn emit_use_node(state: &mut ExtractionState, node: TsNode<'_>, mod_name: &str) {
384 let start_line = node.start_position().row as u32;
385 let end_line = node.end_position().row as u32;
386 let start_column = node.start_position().column as u32;
387 let end_column = node.end_position().column as u32;
388 let text = state.node_text(node);
389 let qualified_name = format!("{}::{}", state.qualified_prefix(), mod_name);
390 let id = generate_node_id(&state.file_path, &NodeKind::Use, mod_name, start_line);
391
392 let graph_node = Node {
393 id: id.clone(),
394 kind: NodeKind::Use,
395 name: mod_name.to_string(),
396 qualified_name,
397 file_path: state.file_path.clone(),
398 start_line,
399 attrs_start_line: start_line,
400 end_line,
401 start_column,
402 end_column,
403 signature: Some(text.trim().to_string()),
404 docstring: None,
405 visibility: Visibility::Private,
406 is_async: false,
407 branches: 0,
408 loops: 0,
409 returns: 0,
410 max_nesting: 0,
411 unsafe_blocks: 0,
412 unchecked_calls: 0,
413 assertions: 0,
414 updated_at: state.timestamp,
415 parent_id: None,
416 };
417 state.nodes.push(graph_node);
418
419 // Contains edge from parent.
420 if let Some(parent_id) = state.parent_node_id() {
421 state.edges.push(Edge {
422 source: parent_id.to_string(),
423 target: id,
424 kind: EdgeKind::Contains,
425 line: Some(start_line),
426 });
427 }
428 }
429
430 /// Extract the module name from a `require("module")` call.
431 ///

Callers

nothing calls this directly

Calls 4

generate_node_idFunction · 0.85
pushMethod · 0.80
node_textMethod · 0.45
parent_node_idMethod · 0.45

Tested by

no test coverage detected