The property a CommonJS export assignment binds a function to — `exports.NAME = ` / `module.exports.NAME = `, or the same with the name in quotes, `exports["NAME"] = ` — or None for any other assignment. The node must be the assignment's whole right-hand side. Mirrors TreeSitterExtractor.commonJsExportName.
(&self, assignment: Node<'t>, value: Node<'t>)
| 143 | /// other assignment. The node must be the assignment's whole right-hand |
| 144 | /// side. Mirrors TreeSitterExtractor.commonJsExportName. |
| 145 | fn common_js_export_name(&self, assignment: Node<'t>, value: Node<'t>) -> Option<String> { |
| 146 | let right = assignment.child_by_field_name("right")?; |
| 147 | if right.start_byte() != value.start_byte() || right.end_byte() != value.end_byte() { |
| 148 | return None; |
| 149 | } |
| 150 | let left = assignment.child_by_field_name("left")?; |
| 151 | if !matches!(left.kind(), "member_expression" | "subscript_expression") { |
| 152 | return None; |
| 153 | } |
| 154 | let object = left.child_by_field_name("object")?; |
| 155 | if !matches!(self.text(object), "exports" | "module.exports") { |
| 156 | return None; |
| 157 | } |
| 158 | if left.kind() == "subscript_expression" { |
| 159 | return self.quoted_identifier(left.child_by_field_name("index")?).map(str::to_string); |
| 160 | } |
| 161 | let property = left.child_by_field_name("property")?; |
| 162 | if property.kind() != "property_identifier" { |
| 163 | return None; |
| 164 | } |
| 165 | Some(self.text(property).to_string()) |
| 166 | } |
| 167 | |
| 168 | /// The name a string literal spells when it is a plain identifier: `'svc'` |
| 169 | /// or `"getItems"` → the text between the quotes. None for anything else, |
no test coverage detected