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

Method visit_parameter_defaults

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

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

Callers 5

extract_functionMethod · 0.80
extract_methodMethod · 0.80

Calls 1

Tested by

no test coverage detected