The name a string literal spells when it is a plain identifier: `'svc'` or `"getItems"` → the text between the quotes. None for anything else, including a string with an escape or a character no identifier can hold. Mirrors quotedIdentifier in tree-sitter.ts.
(&self, node: Node<'t>)
| 266 | /// including a string with an escape or a character no identifier can |
| 267 | /// hold. Mirrors quotedIdentifier in tree-sitter.ts. |
| 268 | fn quoted_identifier(&self, node: Node<'t>) -> Option<&'t str> { |
| 269 | if node.kind() != "string" { |
| 270 | return None; |
| 271 | } |
| 272 | let text = self.text(node); |
| 273 | let quoted = text.len() >= 2 |
| 274 | && (text.starts_with('\'') || text.starts_with('"')) |
| 275 | && text.ends_with(&text[..1]); |
| 276 | if !quoted { |
| 277 | return None; |
| 278 | } |
| 279 | let key = &text[1..text.len() - 1]; |
| 280 | let mut chars = key.chars(); |
| 281 | let first = chars.next()?; |
| 282 | if !(first.is_ascii_alphabetic() || first == '_' || first == '$') |
| 283 | || !chars.all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '$') |
| 284 | { |
| 285 | return None; |
| 286 | } |
| 287 | Some(key) |
| 288 | } |
| 289 | |
| 290 | // --- reactComponentHoc / extractReactComponentNode (#841) -------------------- |
| 291 |
no test coverage detected