A parameter's default value is code the function runs, each time a call leaves that argument out (#2588). Each default, and a computed key in a destructured parameter, is walked as the body is, with the same scope on the stack; the names a parameter binds and its type annotation are not. A function with no body never runs. Mirrors TreeSitterExtractor.visitParameterDefaults.
(&mut self, func: Node<'t>, body: Option<Node<'t>>)
| 85 | /// are not. A function with no body never runs. Mirrors |
| 86 | /// TreeSitterExtractor.visitParameterDefaults. |
| 87 | fn visit_parameter_defaults(&mut self, func: Node<'t>, body: Option<Node<'t>>) { |
| 88 | let Some(body) = body else { return }; |
| 89 | // A class field holds its function: `onPick = (item = first()) => {…}`. |
| 90 | let owner = if matches!(func.kind(), "public_field_definition" | "field_definition") { |
| 91 | body.parent() |
| 92 | } else { |
| 93 | Some(func) |
| 94 | }; |
| 95 | if let Some(params) = owner.and_then(|o| o.child_by_field_name("parameters")) { |
| 96 | self.visit_pattern_defaults(params); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /// The defaults in a parameter list or a destructuring pattern, in source |
| 101 | /// order. Mirrors TreeSitterExtractor.visitPatternDefaults. |
no test coverage detected