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

Method extract_anonymous_class

codegraph-kernel/src/php.rs:1236–1263  ·  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

1234 /// nests inside `anonymous_class`, so findAnonymousClassBody finds no
1235 /// DIRECT child) — mirrored from the shared TS path for shape.
1236 fn extract_anonymous_class(&mut self, node: Node<'t>, body: Node<'t>) {
1237 stack_guard!();
1238 let type_node = node
1239 .child_by_field_name("constructor")
1240 .or_else(|| node.child_by_field_name("type"))
1241 .or_else(|| node.child_by_field_name("name"))
1242 .or_else(|| node.named_child(0));
1243 let mut type_name =
1244 type_node.map(|t| self.text(t).to_string()).unwrap_or_else(|| "Object".to_string());
1245 type_name = strip_generic_and_qualifier(&type_name);
1246 if type_name.is_empty() {
1247 type_name = "Object".to_string();
1248 }
1249 let anon_name = format!("<{type_name}$anon@{}>", node.start_position().row + 1);
1250 let Some(row) = self.create_node("class", &anon_name, node, Extra::default()) else {
1251 return;
1252 };
1253 let (line, column) = match type_node {
1254 Some(t) => (t.start_position().row as u32, self.col_of(t)),
1255 None => (node.start_position().row as u32, self.col_of(node)),
1256 };
1257 self.push_ref(row, &type_name, edge_kind_index("extends").unwrap(), line, column);
1258 self.stack.push(Scope { row, kind: "class", name: anon_name });
1259 for c in body.named_children(&mut body.walk()) {
1260 self.visit_node(c);
1261 }
1262 self.stack.pop();
1263 }
1264
1265 /// extractStaticMemberRef — php's class_constant_access_expression +
1266 /// scoped_property_access_expression (member_access_expression is

Callers 2

visit_nodeMethod · 0.45

Calls 11

edge_kind_indexFunction · 0.85
mapMethod · 0.80
pushMethod · 0.80
textMethod · 0.65
unwrapMethod · 0.60
create_nodeMethod · 0.45
col_ofMethod · 0.45
push_refMethod · 0.45
walkMethod · 0.45
visit_nodeMethod · 0.45

Tested by

no test coverage detected