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

Method visit_class

src/extraction/java_extractor.rs:349–421  ·  view source on GitHub ↗

Extract a class declaration.

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

Source from the content-addressed store, hash-verified

347
348 /// Extract a class declaration.
349 fn visit_class(state: &mut ExtractionState, node: TsNode<'_>) {
350 let name = Self::extract_name(state, node).unwrap_or_else(|| "<anonymous>".to_string());
351 let visibility = Self::extract_java_visibility(node, state);
352 let docstring = Self::extract_java_docstring(state, node);
353 let signature = Some(Self::extract_declaration_signature(state, node));
354 let start_line = node.start_position().row as u32;
355 let end_line = node.end_position().row as u32;
356 let start_column = node.start_position().column as u32;
357 let end_column = node.end_position().column as u32;
358 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
359
360 // Determine if this is an inner class or a top-level class.
361 let kind = if state.class_depth > 0 {
362 NodeKind::InnerClass
363 } else {
364 NodeKind::Class
365 };
366
367 let id = generate_node_id(&state.file_path, &kind, &name, start_line);
368
369 let graph_node = Node {
370 id: id.clone(),
371 kind,
372 name: name.clone(),
373 qualified_name,
374 file_path: state.file_path.clone(),
375 start_line,
376 attrs_start_line: start_line,
377 end_line,
378 start_column,
379 end_column,
380 signature,
381 docstring,
382 visibility,
383 is_async: false,
384 branches: 0,
385 loops: 0,
386 returns: 0,
387 max_nesting: 0,
388 unsafe_blocks: 0,
389 unchecked_calls: 0,
390 assertions: 0,
391 updated_at: state.timestamp,
392 parent_id: None,
393 };
394 state.nodes.push(graph_node);
395
396 // Contains edge from parent.
397 if let Some(parent_id) = state.parent_node_id() {
398 state.edges.push(Edge {
399 source: parent_id.to_string(),
400 target: id.clone(),
401 kind: EdgeKind::Contains,
402 line: Some(start_line),
403 });
404 }
405
406 // Extract extends/implements.

Callers

nothing calls this directly

Calls 4

generate_node_idFunction · 0.85
visit_childrenFunction · 0.85
pushMethod · 0.80
parent_node_idMethod · 0.45

Tested by

no test coverage detected