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

Method visit_class

src/extraction/php_extractor.rs:296–361  ·  view source on GitHub ↗

Extract a class declaration.

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

Source from the content-addressed store, hash-verified

294
295 /// Extract a class declaration.
296 fn visit_class(state: &mut ExtractionState, node: TsNode<'_>) {
297 let name = find_direct_child_by_kind(node, "name")
298 .map_or_else(|| "<anonymous>".to_string(), |n| state.node_text(n));
299
300 let visibility = Visibility::Pub;
301 let docstring = Self::extract_docstring(state, node);
302 let signature = Some(Self::extract_class_signature(state, node));
303 let start_line = node.start_position().row as u32;
304 let end_line = node.end_position().row as u32;
305 let start_column = node.start_position().column as u32;
306 let end_column = node.end_position().column as u32;
307 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
308 let id = generate_node_id(&state.file_path, &NodeKind::Class, &name, start_line);
309
310 let graph_node = Node {
311 id: id.clone(),
312 kind: NodeKind::Class,
313 name: name.clone(),
314 qualified_name,
315 file_path: state.file_path.clone(),
316 start_line,
317 attrs_start_line: start_line,
318 end_line,
319 start_column,
320 end_column,
321 signature,
322 docstring,
323 visibility,
324 is_async: false,
325 branches: 0,
326 loops: 0,
327 returns: 0,
328 max_nesting: 0,
329 unsafe_blocks: 0,
330 unchecked_calls: 0,
331 assertions: 0,
332 updated_at: state.timestamp,
333 parent_id: None,
334 };
335 state.nodes.push(graph_node);
336
337 // Contains edge from parent.
338 if let Some(parent_id) = state.parent_node_id() {
339 state.edges.push(Edge {
340 source: parent_id.to_string(),
341 target: id.clone(),
342 kind: EdgeKind::Contains,
343 line: Some(start_line),
344 });
345 }
346
347 Self::extract_annotations(state, node, &id);
348 // Extract base class (extends) references.
349 Self::extract_class_extends(state, node, &id);
350 // Extract interface (implements) references.
351 Self::extract_class_implements(state, node, &id);
352
353 // Visit class body members.

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