UnwrapExpressionUntil is similar to UnwrapExpression except it gives the caller an opportunity to test each level of unwrapping to see each a particular expression is accepted. This could be used, for example, to unwrap until a particular other interface is satisfied, regardless of wrap wrapping le
(expr Expression, until func(Expression) bool)
| 55 | // function rejects even the final, physical expression then the result of |
| 56 | // this function is nil. |
| 57 | func UnwrapExpressionUntil(expr Expression, until func(Expression) bool) Expression { |
| 58 | for { |
| 59 | if until(expr) { |
| 60 | return expr |
| 61 | } |
| 62 | unwrap, wrapped := expr.(unwrapExpression) |
| 63 | if !wrapped { |
| 64 | return nil |
| 65 | } |
| 66 | expr = unwrap.UnwrapExpression() |
| 67 | if expr == nil { |
| 68 | return nil |
| 69 | } |
| 70 | } |
| 71 | } |
no test coverage detected