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

Method literal_or_identifier

codegraph-kernel/src/rlang.rs:278–293  ·  view source on GitHub ↗

literalOrIdentifier (r.ts:70-81): identifier text (backticks kept), a string's first string_content text, `Some("")` for an empty string literal (falsy downstream, like null), None otherwise.

(&self, node: Option<Node<'t>>)

Source from the content-addressed store, hash-verified

276 /// string's first string_content text, `Some("")` for an empty string
277 /// literal (falsy downstream, like null), None otherwise.
278 fn literal_or_identifier(&self, node: Option<Node<'t>>) -> Option<&'t str> {
279 let node = node?;
280 match node.kind() {
281 "identifier" => Some(self.text(node)),
282 "string" => {
283 let mut cursor = node.walk();
284 for c in node.named_children(&mut cursor) {
285 if c.kind() == "string_content" {
286 return Some(self.text(c));
287 }
288 }
289 Some("")
290 }
291 _ => None,
292 }
293 }
294
295 // --- the visitNode walk (tree-sitter.ts:936-953, 1248, 1295-1301) -----
296 // Hook first (consumed → return; scanFnRefSubtree is a no-op for R), then

Callers 2

hook_callMethod · 0.80
extract_class_membersMethod · 0.80

Calls 1

textMethod · 0.45

Tested by

no test coverage detected