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

Function emit_annotation_usage

src/extraction/annotations.rs:16–76  ·  view source on GitHub ↗
(
    state: &mut S,
    annotation_node: TsNode<'_>,
    target_id: &str,
    attrs_start_line: u32,
)

Source from the content-addressed store, hash-verified

14}
15
16pub(crate) fn emit_annotation_usage<S: AnnotationEmitterState>(
17 state: &mut S,
18 annotation_node: TsNode<'_>,
19 target_id: &str,
20 attrs_start_line: u32,
21) {
22 let annot_name = state.extract_annotation_name(annotation_node);
23 let start_line = annotation_node.start_position().row as u32;
24 let end_line = annotation_node.end_position().row as u32;
25 let start_column = annotation_node.start_position().column as u32;
26 let end_column = annotation_node.end_position().column as u32;
27 let qualified_name = format!("{}::@{}", state.qualified_prefix(), annot_name);
28 let id = generate_node_id(
29 state.file_path(),
30 &NodeKind::AnnotationUsage,
31 &annot_name,
32 start_line,
33 );
34
35 state.push_node(Node {
36 id: id.clone(),
37 kind: NodeKind::AnnotationUsage,
38 name: annot_name.clone(),
39 qualified_name,
40 file_path: state.file_path().to_string(),
41 start_line,
42 attrs_start_line,
43 end_line,
44 start_column,
45 end_column,
46 signature: Some(state.node_text(annotation_node).trim().to_string()),
47 docstring: None,
48 visibility: Visibility::Private,
49 is_async: false,
50 branches: 0,
51 loops: 0,
52 returns: 0,
53 max_nesting: 0,
54 unsafe_blocks: 0,
55 unchecked_calls: 0,
56 assertions: 0,
57 updated_at: state.timestamp(),
58 parent_id: None,
59 });
60
61 state.push_unresolved_ref(UnresolvedRef {
62 from_node_id: id.clone(),
63 reference_name: annot_name,
64 reference_kind: EdgeKind::Annotates,
65 line: start_line,
66 column: start_column,
67 file_path: state.file_path().to_string(),
68 });
69
70 state.push_edge(Edge {
71 source: id,
72 target: target_id.to_string(),
73 kind: EdgeKind::Annotates,

Calls 8

generate_node_idFunction · 0.85
file_pathMethod · 0.45
push_nodeMethod · 0.45
node_textMethod · 0.45
timestampMethod · 0.45
push_unresolved_refMethod · 0.45
push_edgeMethod · 0.45

Tested by 1