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

Method literal_or_identifier

codegraph-kernel/src/rlang.rs:281–296  ·  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

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

Callers 2

hook_callMethod · 0.80
extract_class_membersMethod · 0.80

Calls 2

walkMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected