Strip transparent wrappers off a receiver (mirrors peelTsJsReceiver), including the grammar's `(a && b)!` parse of `a && b!`.
(node: Node<'_>)
| 2666 | /// Strip transparent wrappers off a receiver (mirrors peelTsJsReceiver), |
| 2667 | /// including the grammar's `(a && b)!` parse of `a && b!`. |
| 2668 | fn peel_receiver(node: Node<'_>) -> Node<'_> { |
| 2669 | let mut cur = node; |
| 2670 | while is_transparent_receiver(cur.kind()) { |
| 2671 | let mut inner = if cur.kind() == "type_assertion" { |
| 2672 | cur.named_child(cur.named_child_count().saturating_sub(1)) |
| 2673 | } else { |
| 2674 | cur.named_child(0) |
| 2675 | }; |
| 2676 | if cur.kind() == "non_null_expression" { |
| 2677 | while let Some(b) = inner.filter(|n| n.kind() == "binary_expression") { |
| 2678 | inner = b.child_by_field_name("right"); |
| 2679 | } |
| 2680 | } |
| 2681 | match inner { |
| 2682 | Some(i) => cur = i, |
| 2683 | None => break, |
| 2684 | } |
| 2685 | } |
| 2686 | cur |
| 2687 | } |
| 2688 | |
| 2689 | /// `this` / `super`, or a member chain rooted at either or at `window`, still |
| 2690 | /// collapse to the bare method name; a subscript anywhere in the chain does |
no test coverage detected