(&mut self, node: Node<'t>)
| 323 | } |
| 324 | |
| 325 | fn hook_call(&mut self, node: Node<'t>) -> bool { |
| 326 | stack_guard!(); |
| 327 | let fname = match self.callee_name(node) { |
| 328 | Some(f) => f, |
| 329 | None => return false, |
| 330 | }; |
| 331 | |
| 332 | // library(dplyr) / require(stats) / requireNamespace("jsonlite") / |
| 333 | // source("helpers.R") (r.ts:189-208). A dynamic/missing/empty first |
| 334 | // arg is consumed SILENTLY — nothing recorded, subtree never visited. |
| 335 | if is_import_fn(fname) || fname == "source" { |
| 336 | let module = match self.literal_or_identifier(self.first_arg_value(node)) { |
| 337 | Some(m) if !m.is_empty() => m, |
| 338 | _ => return true, |
| 339 | }; |
| 340 | // signature: whole call text .trim().slice(0, 100) — UTF-16 slice. |
| 341 | // (A call node's text starts at the callee and ends at `)`, so |
| 342 | // trim() never has anything to strip on reachable inputs.) |
| 343 | let (sig, _) = util::slice_utf16(self.text(node).trim(), 100); |
| 344 | let module = module.to_string(); |
| 345 | let imp = self.create_node("import", &module, node, Some(&sig)); |
| 346 | if imp.is_some() && !self.stack.is_empty() { |
| 347 | let parent_row = self.top_row(); |
| 348 | self.push_ref_at(parent_row, &module, "imports", node); |
| 349 | } |
| 350 | return true; |
| 351 | } |
| 352 | |
| 353 | // setClass("Patient", …) / setRefClass / R6Class / ggproto |
| 354 | // (r.ts:211-221). A falsy name FALLS THROUGH to the generic call — |
| 355 | // `ggproto(NULL, Geom, …)` emits `calls ggproto` + file-scope body |
| 356 | // leak (asymmetric with imports, preserved). |
| 357 | if is_class_fn(fname) { |
| 358 | let name = match self.literal_or_identifier(self.first_arg_value(node)) { |
| 359 | Some(n) if !n.is_empty() => n.to_string(), |
| 360 | _ => return false, |
| 361 | }; |
| 362 | if let Some(cls_row) = self.create_node("class", &name, node, None) { |
| 363 | self.stack.push(Scope { row: cls_row, kind: "class", name }); |
| 364 | self.extract_class_members(node, cls_row); |
| 365 | self.stack.pop(); |
| 366 | } |
| 367 | return true; |
| 368 | } |
| 369 | |
| 370 | // setGeneric("describe", …) / setMethod("describe", "Patient", fn) |
| 371 | // (r.ts:224-249): function node named by the first arg; signature and |
| 372 | // body from the FIRST argument (any position) whose value is a |
| 373 | // function_definition. |
| 374 | if is_generic_fn(fname) { |
| 375 | let name = match self.literal_or_identifier(self.first_arg_value(node)) { |
| 376 | Some(n) if !n.is_empty() => n.to_string(), |
| 377 | _ => return false, |
| 378 | }; |
| 379 | let mut impl_node: Option<Node<'t>> = None; |
| 380 | if let Some(args) = node.child_by_field_name("arguments") { |
| 381 | let mut cursor = args.walk(); |
| 382 | for a in args.named_children(&mut cursor) { |
no test coverage detected