Extract variable declarations (const, let, var) Handles arrow functions assigned to variables
(
&self,
node: &Node,
source: &str,
file_path: &str,
exported: bool,
)
| 702 | /// Extract variable declarations (const, let, var) |
| 703 | /// Handles arrow functions assigned to variables |
| 704 | fn extract_variable_declarations( |
| 705 | &self, |
| 706 | node: &Node, |
| 707 | source: &str, |
| 708 | file_path: &str, |
| 709 | exported: bool, |
| 710 | ) -> Vec<Entity> { |
| 711 | let mut entities = Vec::new(); |
| 712 | |
| 713 | // Check if it's a const declaration |
| 714 | let is_const = node.kind() == "lexical_declaration" |
| 715 | && node |
| 716 | .child(0) |
| 717 | .map(|c| self.node_text(&c, source) == Some("const".to_string())) |
| 718 | .unwrap_or(false); |
| 719 | |
| 720 | // Iterate through variable declarators |
| 721 | for i in 0..node.child_count() { |
| 722 | if let Some(declarator) = node.child(i) { |
| 723 | if declarator.kind() == "variable_declarator" { |
| 724 | if let Some(entity) = self.extract_variable_declarator( |
| 725 | &declarator, |
| 726 | node, |
| 727 | source, |
| 728 | file_path, |
| 729 | exported, |
| 730 | is_const, |
| 731 | ) { |
| 732 | entities.push(entity); |
| 733 | } |
| 734 | } |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | entities |
| 739 | } |
| 740 | |
| 741 | /// Extract a single variable declarator |
| 742 | fn extract_variable_declarator( |
no test coverage detected