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

Function peel_receiver

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

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