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