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

Method receiver_of

codegraph-kernel/src/dart.rs:1404–1422  ·  view source on GitHub ↗

dartReceiverOf (dart.ts) — the receiver of the member access `selector`: the node in front of it, past comments, or the end of an arrow function's body when the grammar ended the arrow in front of a generic call (`(ref) => ref.watch (p)` → `((ref) => ref).watch (p)`).

(&self, selector: Node<'t>)

Source from the content-addressed store, hash-verified

1402 /// arrow function's body when the grammar ended the arrow in front of a
1403 /// generic call (`(ref) => ref.watch<int>(p)` → `((ref) => ref).watch<int>(p)`).
1404 fn receiver_of(&self, selector: Node<'t>) -> Option<Node<'t>> {
1405 let prev = prev_named(selector);
1406 let body = prev
1407 .filter(|p| p.kind() == "function_expression")
1408 .and_then(|p| p.named_child(p.named_child_count().checked_sub(1)?));
1409 match body {
1410 Some(body) if body.kind() == "function_expression_body" => {
1411 // The arrow can end on an operator's operand, which is the
1412 // receiver: `(s) => s.id == context.read<Cubit>().id` comes
1413 // out as `((s) => s.id == context).read<Cubit>()…`.
1414 let mut end = body.named_child(body.named_child_count().checked_sub(1)?);
1415 while let Some(e) = end.filter(|e| is_operator_expression(e.kind())) {
1416 end = e.named_child(e.named_child_count().checked_sub(1)?);
1417 }
1418 end
1419 }
1420 _ => prev,
1421 }
1422 }
1423
1424 /// dartCallee (dart.ts) — the callee name of the call whose argument part
1425 /// follows `prev`.

Callers 2

callee_nameMethod · 0.80

Calls 2

prev_namedFunction · 0.85
is_operator_expressionFunction · 0.85

Tested by

no test coverage detected