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

Method extract_instantiation

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

Source from the content-addressed store, hash-verified

905 // --- extractInstantiation (:4610, generic tail) -----------------------
906
907 fn extract_instantiation(&mut self, node: Node<'t>) {
908 if self.stack.is_empty() {
909 return;
910 }
911 let from_row = self.top_row();
912 let ctor = node
913 .child_by_field_name("constructor")
914 .or_else(|| node.child_by_field_name("type"))
915 .or_else(|| node.child_by_field_name("name"))
916 .or_else(|| node.named_child(0));
917 let Some(ctor) = ctor else { return };
918 let mut class_name = self.text(ctor).to_string();
919 if let Some(lt) = class_name.find('<') {
920 if lt > 0 {
921 class_name.truncate(lt);
922 }
923 }
924 let last_dot = class_name.rfind('.').map(|i| i as i64).unwrap_or(-1);
925 let last_colons = class_name.rfind("::").map(|i| (i + 1) as i64).unwrap_or(-1);
926 let last = last_dot.max(last_colons);
927 if last >= 0 {
928 class_name = class_name[(last as usize + 1)..].to_string();
929 class_name = class_name.trim_start_matches([':', '.']).to_string();
930 }
931 let class_name = class_name.trim().to_string();
932 if class_name.is_empty() {
933 return;
934 }
935 self.push_ref_at(from_row, &class_name, "instantiates", node);
936 }
937
938 // --- extractBareCall (dart.ts:305-379) --------------------------------
939

Callers 2

visitMethod · 0.45
visit_bodyMethod · 0.45

Calls 3

textMethod · 0.65
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected