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

Method quoted_identifier

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

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>)

Source from the content-addressed store, hash-verified

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

Callers 2

common_js_export_nameMethod · 0.80
this_subscript_ofMethod · 0.80

Calls 4

lenMethod · 0.80
nextMethod · 0.80
textMethod · 0.65
allMethod · 0.65

Tested by

no test coverage detected