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

Method receiver_of

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

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