Strip transparent wrappers off a receiver (mirrors peelTsJsReceiver), including the grammar's `(a && b)!` parse of `a && b!`.
(node: Node<'_>)
| 2149 | /// Strip transparent wrappers off a receiver (mirrors peelTsJsReceiver), |
| 2150 | /// including the grammar's `(a && b)!` parse of `a && b!`. |
| 2151 | fn peel_receiver(node: Node<'_>) -> Node<'_> { |
| 2152 | let mut cur = node; |
| 2153 | while is_transparent_receiver(cur.kind()) { |
| 2154 | let mut inner = if cur.kind() == "type_assertion" { |
| 2155 | cur.named_child(cur.named_child_count().saturating_sub(1)) |
| 2156 | } else { |
| 2157 | cur.named_child(0) |
| 2158 | }; |
| 2159 | if cur.kind() == "non_null_expression" { |
| 2160 | while let Some(b) = inner.filter(|n| n.kind() == "binary_expression") { |
| 2161 | inner = b.child_by_field_name("right"); |
| 2162 | } |
| 2163 | } |
| 2164 | match inner { |
| 2165 | Some(i) => cur = i, |
| 2166 | None => break, |
| 2167 | } |
| 2168 | } |
| 2169 | cur |
| 2170 | } |
| 2171 | |
| 2172 | /// `this` / `super`, or a member chain rooted at either or at `window`, still |
| 2173 | /// collapse to the bare method name; a subscript anywhere in the chain does |
no test coverage detected