Extract variable declarations (const, let, var) Handles arrow functions assigned to variables
(
&self,
node: &Node,
source: &str,
file_path: &str,
exported: bool,
)
| 674 | /// Extract variable declarations (const, let, var) |
| 675 | /// Handles arrow functions assigned to variables |
| 676 | fn extract_variable_declarations( |
| 677 | &self, |
| 678 | node: &Node, |
| 679 | source: &str, |
| 680 | file_path: &str, |
| 681 | exported: bool, |
| 682 | ) -> Vec<Entity> { |
| 683 | let mut entities = Vec::new(); |
| 684 | |
| 685 | // Check if it's a const declaration |
| 686 | let is_const = node.kind() == "lexical_declaration" |
| 687 | && node |
| 688 | .child(0) |
| 689 | .map(|c| self.node_text(&c, source) == Some("const".to_string())) |
| 690 | .unwrap_or(false); |
| 691 | |
| 692 | // Iterate through variable declarators |
| 693 | for i in 0..node.child_count() { |
| 694 | if let Some(declarator) = node.child(i) { |
| 695 | if declarator.kind() == "variable_declarator" { |
| 696 | if let Some(entity) = self.extract_variable_declarator( |
| 697 | &declarator, |
| 698 | node, |
| 699 | source, |
| 700 | file_path, |
| 701 | exported, |
| 702 | is_const, |
| 703 | ) { |
| 704 | entities.push(entity); |
| 705 | } |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | entities |
| 711 | } |
| 712 | |
| 713 | /// Extract a single variable declarator |
| 714 | fn extract_variable_declarator( |
no test coverage detected