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

Method extract_instantiation

codegraph-kernel/src/php.rs:1065–1085  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

1063 }
1064
1065 fn extract_instantiation(&mut self, node: Node<'t>) {
1066 if self.stack.is_empty() {
1067 return;
1068 }
1069 // php has no constructor/type/name FIELDS → namedChild(0). Backslashes
1070 // are NOT split by the suffix logic → `new \App\Models\User()` keeps
1071 // the full qualified text; `new $cls()` keeps the `$`; an
1072 // anonymous_class yields its whole source text through the shared
1073 // normalization (garbage, deterministic — preserve).
1074 let ctor = node
1075 .child_by_field_name("constructor")
1076 .or_else(|| node.child_by_field_name("type"))
1077 .or_else(|| node.child_by_field_name("name"))
1078 .or_else(|| node.named_child(0));
1079 let Some(ctor) = ctor else { return };
1080 let class_name = strip_generic_and_qualifier(self.text(ctor));
1081 if !class_name.is_empty() {
1082 let from = self.top_row();
1083 self.push_ref_at(from, &class_name, edge_kind_index("instantiates").unwrap(), node);
1084 }
1085 }
1086
1087 /// extractAnonymousClass — unreachable on v0.24.2 (the declaration_list
1088 /// nests inside `anonymous_class`, so findAnonymousClassBody finds no

Callers 2

visit_nodeMethod · 0.45

Calls 6

edge_kind_indexFunction · 0.85
textMethod · 0.65
unwrapMethod · 0.60
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected