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>)
| 170 | /// including a string with an escape or a character no identifier can |
| 171 | /// hold. Mirrors quotedIdentifier in tree-sitter.ts. |
| 172 | fn quoted_identifier(&self, node: Node<'t>) -> Option<&'t str> { |
| 173 | if node.kind() != "string" { |
| 174 | return None; |
| 175 | } |
| 176 | let text = self.text(node); |
| 177 | let quoted = text.len() >= 2 |
| 178 | && (text.starts_with('\'') || text.starts_with('"')) |
| 179 | && text.ends_with(&text[..1]); |
| 180 | if !quoted { |
| 181 | return None; |
| 182 | } |
| 183 | let key = &text[1..text.len() - 1]; |
| 184 | let mut chars = key.chars(); |
| 185 | let first = chars.next()?; |
| 186 | if !(first.is_ascii_alphabetic() || first == '_' || first == '$') |
| 187 | || !chars.all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '$') |
| 188 | { |
| 189 | return None; |
| 190 | } |
| 191 | Some(key) |
| 192 | } |
| 193 | |
| 194 | // --- reactComponentHoc / extractReactComponentNode (#841) -------------------- |
| 195 |
no test coverage detected