(n int, expr ast.Expr)
| 984 | } |
| 985 | |
| 986 | func (t *walker) wrapExpr(n int, expr ast.Expr) { |
| 987 | switch { |
| 988 | case t.isErrtraceWrap(expr): |
| 989 | return // already wrapped |
| 990 | |
| 991 | case isIdent(expr, "nil"): |
| 992 | // Optimization: ignore if it's "nil". |
| 993 | return |
| 994 | } |
| 995 | |
| 996 | if t.optout(expr.Pos()) { |
| 997 | return |
| 998 | } |
| 999 | |
| 1000 | *t.inserts = append(*t.inserts, |
| 1001 | &insertWrapOpen{N: n, Before: expr.Pos()}, |
| 1002 | &insertWrapClose{After: expr.End()}, |
| 1003 | ) |
| 1004 | } |
| 1005 | |
| 1006 | // Detects if an expression is in the form errtrace.Wrap(e) or errtrace.Wrap{n}(e). |
| 1007 | func (t *walker) isErrtraceWrap(expr ast.Expr) bool { |
no test coverage detected