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

Function resolve_field_body

codegraph-kernel/src/tsjs/mod.rs:1157–1179  ·  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

1155/// typescriptExtractor.resolveBody / javascriptExtractor.resolveBody: the body
1156/// of a function-valued class field, nested in the arrow / HOF-wrapped arrow.
1157fn resolve_field_body(node: Node) -> Option<Node> {
1158 if !matches!(node.kind(), "public_field_definition" | "field_definition") {
1159 return None;
1160 }
1161 for i in 0..node.named_child_count() {
1162 let child = node.named_child(i)?;
1163 if matches!(child.kind(), "arrow_function" | "function_expression") {
1164 return child.child_by_field_name("body");
1165 }
1166 if child.kind() == "call_expression" {
1167 if let Some(args) = child.child_by_field_name("arguments") {
1168 for j in 0..args.named_child_count() {
1169 if let Some(arg) = args.named_child(j) {
1170 if matches!(arg.kind(), "arrow_function" | "function_expression") {
1171 return arg.child_by_field_name("body");
1172 }
1173 }
1174 }
1175 }
1176 }
1177 }
1178 None
1179}
1180
1181/// resolveBody ?? getChildByField(node, 'body') — the body-walk resolution.
1182fn body_of(node: Node) -> Option<Node> {

Callers 2

create_nodeMethod · 0.85
body_ofFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected