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

Function resolve_field_body

codegraph-kernel/src/tsjs/mod.rs:1258–1278  ·  view source on GitHub ↗

typescriptExtractor.resolveBody / javascriptExtractor.resolveBody: the body of a function-valued class field, nested in the arrow / HOF-wrapped arrow.

(node: Node)

Source from the content-addressed store, hash-verified

1256/// typescriptExtractor.resolveBody / javascriptExtractor.resolveBody: the body
1257/// of a function-valued class field, nested in the arrow / HOF-wrapped arrow.
1258fn resolve_field_body(node: Node) -> Option<Node> {
1259 if !matches!(node.kind(), "public_field_definition" | "field_definition") {
1260 return None;
1261 }
1262 for i in 0..node.named_child_count() {
1263 let child = node.named_child(i)?;
1264 if matches!(child.kind(), "arrow_function" | "function_expression") {
1265 return child.child_by_field_name("body");
1266 }
1267 if child.kind() == "call_expression" {
1268 if let Some(args) = child.child_by_field_name("arguments") {
1269 for arg in args.named_children(&mut args.walk()) {
1270 if matches!(arg.kind(), "arrow_function" | "function_expression") {
1271 return arg.child_by_field_name("body");
1272 }
1273 }
1274 }
1275 }
1276 }
1277 None
1278}
1279
1280/// resolveBody ?? getChildByField(node, 'body') — the body-walk resolution.
1281fn body_of(node: Node) -> Option<Node> {

Callers 2

create_nodeMethod · 0.85
body_ofFunction · 0.85

Calls 1

walkMethod · 0.45

Tested by

no test coverage detected