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

Method receiver_of

codegraph-kernel/src/dart.rs:1397–1415  ·  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

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