objectOwnerPath: an assignment target's links written as plain names (`dw_page` → [dw_page], `App.utils.dom` → [App, utils, dom], `module.exports`, the module's export object, #2966), or None for anything else — `this.x`, `a[k]`, a call, another CommonJS export target (`exports.x`, `module.exports.x`), or a prototype.
(&self, left: Option<Node<'t>>)
| 1098 | /// anything else — `this.x`, `a[k]`, a call, another CommonJS export |
| 1099 | /// target (`exports.x`, `module.exports.x`), or a prototype. |
| 1100 | fn object_owner_path(&self, left: Option<Node<'t>>) -> Option<Vec<String>> { |
| 1101 | let mut path: Vec<String> = Vec::new(); |
| 1102 | let mut cur = left?; |
| 1103 | while cur.kind() == "member_expression" { |
| 1104 | let property = cur.child_by_field_name("property")?; |
| 1105 | if property.kind() != "property_identifier" { |
| 1106 | return None; |
| 1107 | } |
| 1108 | path.push(self.text(property).to_string()); |
| 1109 | cur = cur.child_by_field_name("object")?; |
| 1110 | } |
| 1111 | if cur.kind() != "identifier" { |
| 1112 | return None; |
| 1113 | } |
| 1114 | let root = self.text(cur); |
| 1115 | // `path` holds the links last to first here. |
| 1116 | let export_object = root == "module" && path.len() == 1 && path[0] == "exports"; |
| 1117 | if !export_object && (root == "module" || root == "exports" || path.iter().any(|p| p == "prototype")) { |
| 1118 | return None; |
| 1119 | } |
| 1120 | path.push(root.to_string()); |
| 1121 | path.reverse(); |
| 1122 | Some(path) |
| 1123 | } |
| 1124 | |
| 1125 | // --- object-literal / store helpers ------------------------------------------------- |
| 1126 |
no test coverage detected