(&mut self, node: Node<'t>)
| 418 | // --- the main walk (visitNode, tree-sitter.ts:936-1303) --------------- |
| 419 | |
| 420 | fn visit(&mut self, node: Node<'t>) { |
| 421 | let kind = node.kind(); |
| 422 | |
| 423 | // The visitNode hook (lua.ts:105-151) runs FIRST. |
| 424 | if kind == "function_call" { |
| 425 | if let Some(module) = self.require_module(node) { |
| 426 | self.emit_require(node, &module); |
| 427 | // Consumed → scanFnRefSubtree (tree-sitter.ts:951). |
| 428 | self.scan_fn_ref_subtree(node, 0); |
| 429 | return; |
| 430 | } |
| 431 | // falls through — extractCall claims it below |
| 432 | } else if kind == "variable_declaration" { |
| 433 | // `local x = require(...)` — dig requires out of the initializer |
| 434 | // the variable branch will skip. Always falls through. |
| 435 | let mut cursor = node.walk(); |
| 436 | let assign = node.named_children(&mut cursor).find(|c| c.kind() == "assignment_statement"); |
| 437 | if let Some(assign) = assign { |
| 438 | let mut ac = assign.walk(); |
| 439 | let expr_list = assign.named_children(&mut ac).find(|c| c.kind() == "expression_list"); |
| 440 | if let Some(expr_list) = expr_list { |
| 441 | let mut ec = expr_list.walk(); |
| 442 | let vals: Vec<Node<'t>> = expr_list.named_children(&mut ec).collect(); |
| 443 | for val in vals { |
| 444 | if val.kind() == "function_call" { |
| 445 | if let Some(module) = self.require_module(val) { |
| 446 | self.emit_require(val, &module); |
| 447 | } |
| 448 | } |
| 449 | } |
| 450 | } |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | // maybeCaptureFnRefs (tree-sitter.ts:990). |
| 455 | self.maybe_capture_fn_refs(node); |
| 456 | |
| 457 | // The dispatch ladder — lua/luau rows only. |
| 458 | if kind == "function_declaration" { |
| 459 | // isInsideClassLikeNode is always false (no class-like kinds). |
| 460 | self.extract_function(node); |
| 461 | return; // skipChildren — the body walk handles children |
| 462 | } |
| 463 | if self.is_luau && kind == "type_definition" { |
| 464 | let skip = self.extract_type_alias(node); |
| 465 | if skip { |
| 466 | return; |
| 467 | } |
| 468 | // plain path returns false → children re-visited (the |
| 469 | // typeof(require(...)) alias+import pair rides this). |
| 470 | } else if kind == "variable_declaration" { |
| 471 | self.extract_variable(node); |
| 472 | // Initializer subtrees are never walked — candidates only. |
| 473 | self.scan_fn_ref_subtree(node, 0); |
| 474 | return; // skipChildren |
| 475 | } else if kind == "function_call" { |
| 476 | self.extract_call(node); |
| 477 | // no skipChildren — nested/inner calls each get their own ref |
no test coverage detected