(buf *bytes.Buffer, loc ast.LocationRange)
| 92 | } |
| 93 | |
| 94 | func (ef *termErrorFormatter) showCode(buf *bytes.Buffer, loc ast.LocationRange) { |
| 95 | errFprintf := fmt.Fprintf |
| 96 | if ef.color != nil { |
| 97 | errFprintf = ef.color |
| 98 | } |
| 99 | if loc.WithCode() { |
| 100 | // TODO(sbarzowski) include line numbers |
| 101 | // TODO(sbarzowski) underline errors instead of depending only on color |
| 102 | fmt.Fprintf(buf, "\n") |
| 103 | beginning := ast.LineBeginning(&loc) |
| 104 | ending := ast.LineEnding(&loc) |
| 105 | fmt.Fprintf(buf, "%v", ef.sp.GetSnippet(beginning)) |
| 106 | errFprintf(buf, "%v", ef.sp.GetSnippet(loc)) //nolint:errcheck |
| 107 | fmt.Fprintf(buf, "%v", ef.sp.GetSnippet(ending)) |
| 108 | buf.WriteByte('\n') |
| 109 | } |
| 110 | fmt.Fprintf(buf, "\n") |
| 111 | } |
| 112 | |
| 113 | func (ef *termErrorFormatter) frame(frame *TraceFrame, buf *bytes.Buffer) { |
| 114 | // TODO(sbarzowski) tabs are probably a bad idea |
no test coverage detected