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

Method literal_or_identifier

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

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