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

Function peel_receiver

codegraph-kernel/src/tsjs/extractors.rs:2668–2687  ·  view source on GitHub ↗

Strip transparent wrappers off a receiver (mirrors peelTsJsReceiver), including the grammar's `(a && b)!` parse of `a && b!`.

(node: Node<'_>)

Source from the content-addressed store, hash-verified

2666/// Strip transparent wrappers off a receiver (mirrors peelTsJsReceiver),
2667/// including the grammar's `(a && b)!` parse of `a && b!`.
2668fn peel_receiver(node: Node<'_>) -> Node<'_> {
2669 let mut cur = node;
2670 while is_transparent_receiver(cur.kind()) {
2671 let mut inner = if cur.kind() == "type_assertion" {
2672 cur.named_child(cur.named_child_count().saturating_sub(1))
2673 } else {
2674 cur.named_child(0)
2675 };
2676 if cur.kind() == "non_null_expression" {
2677 while let Some(b) = inner.filter(|n| n.kind() == "binary_expression") {
2678 inner = b.child_by_field_name("right");
2679 }
2680 }
2681 match inner {
2682 Some(i) => cur = i,
2683 None => break,
2684 }
2685 }
2686 cur
2687}
2688
2689/// `this` / `super`, or a member chain rooted at either or at `window`, still
2690/// collapse to the bare method name; a subscript anywhere in the chain does

Callers 3

callee_name_ofMethod · 0.85
this_subscript_ofMethod · 0.85
keeps_bare_receiverFunction · 0.85

Calls 1

is_transparent_receiverFunction · 0.85

Tested by

no test coverage detected