MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / extract_anonymous_class

Method extract_anonymous_class

codegraph-kernel/src/php.rs:1082–1110  ·  view source on GitHub ↗

extractAnonymousClass — unreachable on v0.24.2 (the declaration_list nests inside `anonymous_class`, so findAnonymousClassBody finds no DIRECT child) — mirrored from the shared TS path for shape.

(&mut self, node: Node<'t>, body: Node<'t>)

Source from the content-addressed store, hash-verified

1080 /// nests inside `anonymous_class`, so findAnonymousClassBody finds no
1081 /// DIRECT child) — mirrored from the shared TS path for shape.
1082 fn extract_anonymous_class(&mut self, node: Node<'t>, body: Node<'t>) {
1083 let type_node = node
1084 .child_by_field_name("constructor")
1085 .or_else(|| node.child_by_field_name("type"))
1086 .or_else(|| node.child_by_field_name("name"))
1087 .or_else(|| node.named_child(0));
1088 let mut type_name =
1089 type_node.map(|t| self.text(t).to_string()).unwrap_or_else(|| "Object".to_string());
1090 type_name = strip_generic_and_qualifier(&type_name);
1091 if type_name.is_empty() {
1092 type_name = "Object".to_string();
1093 }
1094 let anon_name = format!("<{type_name}$anon@{}>", node.start_position().row + 1);
1095 let Some(row) = self.create_node("class", &anon_name, node, Extra::default()) else {
1096 return;
1097 };
1098 let (line, column) = match type_node {
1099 Some(t) => (t.start_position().row as u32, self.col_of(t)),
1100 None => (node.start_position().row as u32, self.col_of(node)),
1101 };
1102 self.push_ref(row, &type_name, edge_kind_index("extends").unwrap(), line, column);
1103 self.stack.push(Scope { row, kind: "class", name: anon_name });
1104 for i in 0..body.named_child_count() {
1105 if let Some(c) = body.named_child(i) {
1106 self.visit_node(c);
1107 }
1108 }
1109 self.stack.pop();
1110 }
1111
1112 /// extractStaticMemberRef — php's class_constant_access_expression +
1113 /// scoped_property_access_expression (member_access_expression is

Callers 2

visit_nodeMethod · 0.45

Calls 8

edge_kind_indexFunction · 0.85
unwrapMethod · 0.60
textMethod · 0.45
create_nodeMethod · 0.45
col_ofMethod · 0.45
push_refMethod · 0.45
visit_nodeMethod · 0.45

Tested by

no test coverage detected