MCPcopy Create free account
hub / github.com/google/go-jsonnet / showCode

Method showCode

error_formatter.go:94–111  ·  view source on GitHub ↗
(buf *bytes.Buffer, loc ast.LocationRange)

Source from the content-addressed store, hash-verified

92}
93
94func (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
113func (ef *termErrorFormatter) frame(frame *TraceFrame, buf *bytes.Buffer) {
114 // TODO(sbarzowski) tabs are probably a bad idea

Callers 2

formatStaticMethod · 0.95
frameMethod · 0.95

Calls 4

LineBeginningFunction · 0.92
LineEndingFunction · 0.92
WithCodeMethod · 0.80
GetSnippetMethod · 0.80

Tested by

no test coverage detected