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

Function peel_receiver

codegraph-kernel/src/tsjs/extractors.rs:2151–2170  ·  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

2149/// Strip transparent wrappers off a receiver (mirrors peelTsJsReceiver),
2150/// including the grammar's `(a && b)!` parse of `a && b!`.
2151fn peel_receiver(node: Node<'_>) -> Node<'_> {
2152 let mut cur = node;
2153 while is_transparent_receiver(cur.kind()) {
2154 let mut inner = if cur.kind() == "type_assertion" {
2155 cur.named_child(cur.named_child_count().saturating_sub(1))
2156 } else {
2157 cur.named_child(0)
2158 };
2159 if cur.kind() == "non_null_expression" {
2160 while let Some(b) = inner.filter(|n| n.kind() == "binary_expression") {
2161 inner = b.child_by_field_name("right");
2162 }
2163 }
2164 match inner {
2165 Some(i) => cur = i,
2166 None => break,
2167 }
2168 }
2169 cur
2170}
2171
2172/// `this` / `super`, or a member chain rooted at either or at `window`, still
2173/// 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