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

Method visit_const_statement

src/extraction/qbasic_extractor.rs:230–285  ·  view source on GitHub ↗

Visit a CONST statement and emit a Const node.

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

Source from the content-addressed store, hash-verified

228
229 /// Visit a CONST statement and emit a Const node.
230 fn visit_const_statement(
231 state: &mut ExtractionState,
232 line: TsNode<'_>,
233 const_stmt: TsNode<'_>,
234 pending_comment: Option<&str>,
235 ) {
236 // Find the identifier child of const_statement.
237 let Some(id_node) = find_direct_child_by_kind(const_stmt, "identifier") else {
238 return;
239 };
240 let name = state.node_text(id_node);
241
242 let start_line = line.start_position().row as u32;
243 let end_line = line.end_position().row as u32;
244 let start_column = line.start_position().column as u32;
245 let end_column = line.end_position().column as u32;
246 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
247 let id = generate_node_id(&state.file_path, &NodeKind::Const, &name, start_line);
248 let text = state.node_text(line);
249
250 let graph_node = Node {
251 id: id.clone(),
252 kind: NodeKind::Const,
253 name,
254 qualified_name,
255 file_path: state.file_path.clone(),
256 start_line,
257 attrs_start_line: start_line,
258 end_line,
259 start_column,
260 end_column,
261 signature: Some(text.trim().to_string()),
262 docstring: pending_comment.map(std::string::ToString::to_string),
263 visibility: Visibility::Pub,
264 is_async: false,
265 branches: 0,
266 loops: 0,
267 returns: 0,
268 max_nesting: 0,
269 unsafe_blocks: 0,
270 unchecked_calls: 0,
271 assertions: 0,
272 updated_at: state.timestamp,
273 parent_id: None,
274 };
275 state.nodes.push(graph_node);
276
277 if let Some(parent_id) = state.parent_node_id() {
278 state.edges.push(Edge {
279 source: parent_id.to_string(),
280 target: id,
281 kind: EdgeKind::Contains,
282 line: Some(start_line),
283 });
284 }
285 }
286
287 /// Visit a DIM SHARED statement and emit a Field node.

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected