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

Method visit_pattern_defaults

codegraph-kernel/src/tsjs/extractors.rs:125–159  ·  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 child in node.named_children(&mut node.walk()) {
130 self.visit_pattern_defaults(child);
131 }
132 }
133 "required_parameter" | "optional_parameter" => {
134 if let Some(pattern) = node.child_by_field_name("pattern") {
135 self.visit_pattern_defaults(pattern);
136 }
137 if let Some(value) = node.child_by_field_name("value") {
138 self.visit_function_body(value);
139 }
140 }
141 "assignment_pattern" | "object_assignment_pattern" => {
142 if let Some(left) = node.child_by_field_name("left") {
143 self.visit_pattern_defaults(left);
144 }
145 if let Some(right) = node.child_by_field_name("right") {
146 self.visit_function_body(right);
147 }
148 }
149 "pair_pattern" => {
150 if let Some(key) = node.child_by_field_name("key").filter(|k| k.kind() == "computed_property_name") {
151 self.visit_function_body(key);
152 }
153 if let Some(value) = node.child_by_field_name("value") {
154 self.visit_pattern_defaults(value);
155 }
156 }
157 _ => {}
158 }
159 }
160
161 /// The property a CommonJS export assignment binds a function to —
162 /// `exports.NAME = <node>` / `module.exports.NAME = <node>`, or the same

Callers 1

Calls 2

walkMethod · 0.45
visit_function_bodyMethod · 0.45

Tested by

no test coverage detected