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

Function peel_receiver

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

2287/// Strip transparent wrappers off a receiver (mirrors peelTsJsReceiver),
2288/// including the grammar's `(a && b)!` parse of `a && b!`.
2289fn peel_receiver(node: Node<'_>) -> Node<'_> {
2290 let mut cur = node;
2291 while is_transparent_receiver(cur.kind()) {
2292 let mut inner = if cur.kind() == "type_assertion" {
2293 cur.named_child(cur.named_child_count().saturating_sub(1))
2294 } else {
2295 cur.named_child(0)
2296 };
2297 if cur.kind() == "non_null_expression" {
2298 while let Some(b) = inner.filter(|n| n.kind() == "binary_expression") {
2299 inner = b.child_by_field_name("right");
2300 }
2301 }
2302 match inner {
2303 Some(i) => cur = i,
2304 None => break,
2305 }
2306 }
2307 cur
2308}
2309
2310/// `this` / `super`, or a member chain rooted at either or at `window`, still
2311/// 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