Strip transparent wrappers off a receiver (mirrors peelTsJsReceiver), including the grammar's `(a && b)!` parse of `a && b!`.
(node: Node<'_>)
| 2287 | /// Strip transparent wrappers off a receiver (mirrors peelTsJsReceiver), |
| 2288 | /// including the grammar's `(a && b)!` parse of `a && b!`. |
| 2289 | fn 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 |
no test coverage detected