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

Method visit_dim_statement

src/extraction/qbasic_extractor.rs:288–351  ·  view source on GitHub ↗

Visit a DIM SHARED statement and emit a Field node.

(
        state: &mut ExtractionState,
        line: TsNode<'_>,
        dim_stmt: TsNode<'_>,
        pending_comment: Option<&str>,
    )

Source from the content-addressed store, hash-verified

286
287 /// Visit a DIM SHARED statement and emit a Field node.
288 fn visit_dim_statement(
289 state: &mut ExtractionState,
290 line: TsNode<'_>,
291 dim_stmt: TsNode<'_>,
292 pending_comment: Option<&str>,
293 ) {
294 // Check if this is DIM SHARED by looking at the text.
295 let text = state.node_text(line);
296 if !text.contains("SHARED") {
297 return; // Only extract DIM SHARED at top level
298 }
299
300 // Find the dim_variable child, then get its identifier.
301 let Some(dim_var) = find_direct_child_by_kind(dim_stmt, "dim_variable") else {
302 return;
303 };
304 let Some(id_node) = find_direct_child_by_kind(dim_var, "identifier") else {
305 return;
306 };
307 let name = state.node_text(id_node);
308
309 let start_line = line.start_position().row as u32;
310 let end_line = line.end_position().row as u32;
311 let start_column = line.start_position().column as u32;
312 let end_column = line.end_position().column as u32;
313 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
314 let id = generate_node_id(&state.file_path, &NodeKind::Field, &name, start_line);
315
316 let graph_node = Node {
317 id: id.clone(),
318 kind: NodeKind::Field,
319 name,
320 qualified_name,
321 file_path: state.file_path.clone(),
322 start_line,
323 attrs_start_line: start_line,
324 end_line,
325 start_column,
326 end_column,
327 signature: Some(text.trim().to_string()),
328 docstring: pending_comment.map(std::string::ToString::to_string),
329 visibility: Visibility::Pub,
330 is_async: false,
331 branches: 0,
332 loops: 0,
333 returns: 0,
334 max_nesting: 0,
335 unsafe_blocks: 0,
336 unchecked_calls: 0,
337 assertions: 0,
338 updated_at: state.timestamp,
339 parent_id: None,
340 };
341 state.nodes.push(graph_node);
342
343 if let Some(parent_id) = state.parent_node_id() {
344 state.edges.push(Edge {
345 source: parent_id.to_string(),

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected