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

Method extract_instantiation

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

Source from the content-addressed store, hash-verified

1183 }
1184
1185 fn extract_instantiation(&mut self, node: Node<'t>) {
1186 if self.stack.is_empty() {
1187 return;
1188 }
1189 let ctor = node
1190 .child_by_field_name("constructor")
1191 .or_else(|| node.child_by_field_name("type"))
1192 .or_else(|| node.child_by_field_name("name"))
1193 .or_else(|| node.named_child(0));
1194 let Some(ctor) = ctor else { return };
1195 // `new List<Foo>()` → `List`; `new Ns.Foo()` → `Foo`. Target-typed
1196 // `new()` / anonymous `new { }` / arrays `new T[n]` never reach here
1197 // (not in INSTANTIATION_KINDS) — invisible by design, except a `new()`
1198 // that initializes a field or property (extract_target_typed_new).
1199 let class_name = strip_generic_and_qualifier(self.text(ctor));
1200 if !class_name.is_empty() {
1201 let from = self.top_row();
1202 self.push_ref_at(from, &class_name, edge_kind_index("instantiates").unwrap(), node);
1203 }
1204 }
1205
1206 /// extractAnonymousClass — `new T() { ... }`. The C# grammar never
1207 /// produces a class_body/declaration_list child on object_creation

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