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

Method visit_parameter_defaults

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

110 /// are not. A function with no body never runs. Mirrors
111 /// TreeSitterExtractor.visitParameterDefaults.
112 fn visit_parameter_defaults(&mut self, func: Node<'t>, body: Option<Node<'t>>) {
113 let Some(body) = body else { return };
114 // A class field holds its function: `onPick = (item = first()) => {…}`.
115 let owner = if matches!(func.kind(), "public_field_definition" | "field_definition") {
116 body.parent()
117 } else {
118 Some(func)
119 };
120 if let Some(params) = owner.and_then(|o| o.child_by_field_name("parameters")) {
121 self.visit_pattern_defaults(params);
122 }
123 }
124
125 /// The defaults in a parameter list or a destructuring pattern, in source
126 /// order. Mirrors TreeSitterExtractor.visitPatternDefaults.

Callers 5

extract_functionMethod · 0.80
extract_methodMethod · 0.80

Calls 1

Tested by

no test coverage detected