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

Method object_owner_path

codegraph-kernel/src/tsjs/extractors.rs:999–1020  ·  view source on GitHub ↗

objectOwnerPath: an assignment target's links written as plain names (`dw_page` → [dw_page], `App.utils.dom` → [App, utils, dom]), or None for anything else — `this.x`, `a[k]`, a call, CommonJS's `module.exports` / `exports.x`, or a prototype.

(&self, left: Option<Node<'t>>)

Source from the content-addressed store, hash-verified

997 /// for anything else — `this.x`, `a[k]`, a call, CommonJS's
998 /// `module.exports` / `exports.x`, or a prototype.
999 fn object_owner_path(&self, left: Option<Node<'t>>) -> Option<Vec<String>> {
1000 let mut path: Vec<String> = Vec::new();
1001 let mut cur = left?;
1002 while cur.kind() == "member_expression" {
1003 let property = cur.child_by_field_name("property")?;
1004 if property.kind() != "property_identifier" {
1005 return None;
1006 }
1007 path.push(self.text(property).to_string());
1008 cur = cur.child_by_field_name("object")?;
1009 }
1010 if cur.kind() != "identifier" {
1011 return None;
1012 }
1013 let root = self.text(cur);
1014 if root == "module" || root == "exports" || path.iter().any(|p| p == "prototype") {
1015 return None;
1016 }
1017 path.push(root.to_string());
1018 path.reverse();
1019 Some(path)
1020 }
1021
1022 // --- object-literal / store helpers -------------------------------------------------
1023

Callers 1

Calls 2

pushMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected