MCPcopy
hub / github.com/google/go-jsonnet / BreakpointLocations

Method BreakpointLocations

debugger.go:219–243  ·  view source on GitHub ↗
(file string)

Source from the content-addressed store, hash-verified

217}
218
219func (d *Debugger) BreakpointLocations(file string) ([]*ast.LocationRange, error) {
220 abs, err := filepath.Abs(file)
221 if err != nil {
222 return nil, err
223 }
224 raw, err := os.ReadFile(abs)
225 if err != nil {
226 return nil, fmt.Errorf("reading file: %w", err)
227 }
228 a, err := SnippetToAST(file, string(raw))
229 if err != nil {
230 return nil, fmt.Errorf("invalid source file: %w", err)
231 }
232 bps := []*ast.LocationRange{}
233 traverse(a, func(n *ast.Node) error {
234 if n != nil {
235 l := (*n).Loc()
236 if l.File != nil {
237 bps = append(bps, l)
238 }
239 }
240 return nil
241 })
242 return bps, nil
243}
244
245func (d *Debugger) SetBreakpoint(file string, line int, column int) (string, error) {
246 valid, err := d.BreakpointLocations(file)

Callers 1

SetBreakpointMethod · 0.95

Calls 3

traverseFunction · 0.85
SnippetToASTFunction · 0.70
LocMethod · 0.65

Tested by

no test coverage detected