MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / visit_pattern_defaults

Method visit_pattern_defaults

codegraph-kernel/src/tsjs/extractors.rs:102–138  ·  view source on GitHub ↗

The defaults in a parameter list or a destructuring pattern, in source order. Mirrors TreeSitterExtractor.visitPatternDefaults.

(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

100 /// The defaults in a parameter list or a destructuring pattern, in source
101 /// order. Mirrors TreeSitterExtractor.visitPatternDefaults.
102 fn visit_pattern_defaults(&mut self, node: Node<'t>) {
103 stack_guard!();
104 match node.kind() {
105 "formal_parameters" | "object_pattern" | "array_pattern" | "rest_pattern" => {
106 for i in 0..node.named_child_count() {
107 if let Some(child) = node.named_child(i) {
108 self.visit_pattern_defaults(child);
109 }
110 }
111 }
112 "required_parameter" | "optional_parameter" => {
113 if let Some(pattern) = node.child_by_field_name("pattern") {
114 self.visit_pattern_defaults(pattern);
115 }
116 if let Some(value) = node.child_by_field_name("value") {
117 self.visit_function_body(value);
118 }
119 }
120 "assignment_pattern" | "object_assignment_pattern" => {
121 if let Some(left) = node.child_by_field_name("left") {
122 self.visit_pattern_defaults(left);
123 }
124 if let Some(right) = node.child_by_field_name("right") {
125 self.visit_function_body(right);
126 }
127 }
128 "pair_pattern" => {
129 if let Some(key) = node.child_by_field_name("key").filter(|k| k.kind() == "computed_property_name") {
130 self.visit_function_body(key);
131 }
132 if let Some(value) = node.child_by_field_name("value") {
133 self.visit_pattern_defaults(value);
134 }
135 }
136 _ => {}
137 }
138 }
139
140 /// The property a CommonJS export assignment binds a function to —
141 /// `exports.NAME = <node>` / `module.exports.NAME = <node>`, or the same

Callers 1

Calls 1

visit_function_bodyMethod · 0.45

Tested by

no test coverage detected