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

Method quoted_identifier

codegraph-kernel/src/tsjs/extractors.rs:172–192  ·  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

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

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