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

Method visit_pattern_defaults

codegraph-kernel/src/tsjs/extractors.rs:125–161  ·  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

123 /// The defaults in a parameter list or a destructuring pattern, in source
124 /// order. Mirrors TreeSitterExtractor.visitPatternDefaults.
125 fn visit_pattern_defaults(&mut self, node: Node<'t>) {
126 stack_guard!();
127 match node.kind() {
128 "formal_parameters" | "object_pattern" | "array_pattern" | "rest_pattern" => {
129 for i in 0..node.named_child_count() {
130 if let Some(child) = node.named_child(i) {
131 self.visit_pattern_defaults(child);
132 }
133 }
134 }
135 "required_parameter" | "optional_parameter" => {
136 if let Some(pattern) = node.child_by_field_name("pattern") {
137 self.visit_pattern_defaults(pattern);
138 }
139 if let Some(value) = node.child_by_field_name("value") {
140 self.visit_function_body(value);
141 }
142 }
143 "assignment_pattern" | "object_assignment_pattern" => {
144 if let Some(left) = node.child_by_field_name("left") {
145 self.visit_pattern_defaults(left);
146 }
147 if let Some(right) = node.child_by_field_name("right") {
148 self.visit_function_body(right);
149 }
150 }
151 "pair_pattern" => {
152 if let Some(key) = node.child_by_field_name("key").filter(|k| k.kind() == "computed_property_name") {
153 self.visit_function_body(key);
154 }
155 if let Some(value) = node.child_by_field_name("value") {
156 self.visit_pattern_defaults(value);
157 }
158 }
159 _ => {}
160 }
161 }
162
163 /// The property a CommonJS export assignment binds a function to —
164 /// `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