MCPcopy Create free account
hub / github.com/buggregator/server / applyContext

Function applyContext

modules/sentry/source_context.go:211–224  ·  view source on GitHub ↗

applyContext sets context_line / pre_context / post_context around a 0-based line index, using sourceContextLines of surrounding context.

(fm map[string]any, lines []string, idx int)

Source from the content-addressed store, hash-verified

209// applyContext sets context_line / pre_context / post_context around a 0-based
210// line index, using sourceContextLines of surrounding context.
211func applyContext(fm map[string]any, lines []string, idx int) {
212 fm["context_line"] = lines[idx]
213
214 pre := make([]any, 0, sourceContextLines)
215 for i := max(0, idx-sourceContextLines); i < idx; i++ {
216 pre = append(pre, lines[i])
217 }
218 post := make([]any, 0, sourceContextLines)
219 for i := idx + 1; i < min(len(lines), idx+1+sourceContextLines); i++ {
220 post = append(post, lines[i])
221 }
222 fm["pre_context"] = pre
223 fm["post_context"] = post
224}
225
226func toLineNumber(v any) (int, bool) {
227 switch n := v.(type) {

Callers 1

enrichFrameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected