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

Method visit_parameter_defaults

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

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>>)

Source from the content-addressed store, hash-verified

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.

Callers 4

extract_functionMethod · 0.80
extract_methodMethod · 0.80

Calls 1

Tested by

no test coverage detected