Walk the AST and extract entities
(
&self,
node: &Node,
source: &str,
file_path: &str,
entities: &mut Vec<Entity>,
in_export: bool,
)
| 543 | |
| 544 | /// Walk the AST and extract entities |
| 545 | fn walk_tree( |
| 546 | &self, |
| 547 | node: &Node, |
| 548 | source: &str, |
| 549 | file_path: &str, |
| 550 | entities: &mut Vec<Entity>, |
| 551 | in_export: bool, |
| 552 | ) { |
| 553 | // Check if this node is an export statement |
| 554 | let is_export = node.kind() == "export_statement"; |
| 555 | let child_in_export = in_export || is_export; |
| 556 | |
| 557 | match node.kind() { |
| 558 | // Function declarations |
| 559 | "function_declaration" => { |
| 560 | if let Some(entity) = |
| 561 | self.extract_function(node, source, file_path, child_in_export) |
| 562 | { |
| 563 | entities.push(entity); |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | // Arrow functions assigned to variables (const foo = () => {}) |
| 568 | "lexical_declaration" | "variable_declaration" => { |
| 569 | entities.extend(self.extract_variable_declarations( |
| 570 | node, |
| 571 | source, |
| 572 | file_path, |
| 573 | child_in_export, |
| 574 | )); |
| 575 | } |
| 576 | |
| 577 | // Class declarations |
| 578 | "class_declaration" => { |
| 579 | if let Some(entity) = self.extract_class(node, source, file_path, child_in_export) { |
| 580 | entities.push(entity); |
| 581 | } |
| 582 | // Also extract methods from the class |
| 583 | self.extract_class_members(node, source, file_path, entities); |
| 584 | } |
| 585 | |
| 586 | // Interface declarations (TypeScript) |
| 587 | "interface_declaration" => { |
| 588 | if let Some(entity) = |
| 589 | self.extract_interface(node, source, file_path, child_in_export) |
| 590 | { |
| 591 | entities.push(entity); |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | // Type alias declarations (TypeScript) |
| 596 | "type_alias_declaration" => { |
| 597 | if let Some(entity) = |
| 598 | self.extract_type_alias(node, source, file_path, child_in_export) |
| 599 | { |
| 600 | entities.push(entity); |
| 601 | } |
| 602 | } |
no test coverage detected