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

Function resolve_field_body

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

1142/// typescriptExtractor.resolveBody / javascriptExtractor.resolveBody: the body
1143/// of a function-valued class field, nested in the arrow / HOF-wrapped arrow.
1144fn resolve_field_body(node: Node) -> Option<Node> {
1145 if !matches!(node.kind(), "public_field_definition" | "field_definition") {
1146 return None;
1147 }
1148 for i in 0..node.named_child_count() {
1149 let child = node.named_child(i)?;
1150 if matches!(child.kind(), "arrow_function" | "function_expression") {
1151 return child.child_by_field_name("body");
1152 }
1153 if child.kind() == "call_expression" {
1154 if let Some(args) = child.child_by_field_name("arguments") {
1155 for arg in args.named_children(&mut args.walk()) {
1156 if matches!(arg.kind(), "arrow_function" | "function_expression") {
1157 return arg.child_by_field_name("body");
1158 }
1159 }
1160 }
1161 }
1162 }
1163 None
1164}
1165
1166/// resolveBody ?? getChildByField(node, 'body') — the body-walk resolution.
1167fn 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