(body hcl.Body)
| 299 | } |
| 300 | |
| 301 | func (r *Runner) decodeRangeFromBody(body hcl.Body) (hcl.Range, hcl.Body, hcl.Diagnostics) { |
| 302 | var diags hcl.Diagnostics |
| 303 | |
| 304 | rangeBody, remain, moreDiags := body.PartialContent(testFileRangeSchema) |
| 305 | |
| 306 | diags = append(diags, moreDiags...) |
| 307 | if rangeBody == nil { |
| 308 | return hcl.Range{}, nil, diags |
| 309 | } |
| 310 | |
| 311 | var Range hcl.Range |
| 312 | for _, block := range rangeBody.Blocks { |
| 313 | switch block.Type { |
| 314 | // We intentionally omit Filename here, because the test spec doesn't |
| 315 | // need to specify that explicitly: we can infer it to be the file |
| 316 | // path we pass to hcldec. |
| 317 | case "from": |
| 318 | Range.Start, moreDiags = r.decodePosFromBody(block.Body) |
| 319 | diags = append(diags, moreDiags...) |
| 320 | case "to": |
| 321 | Range.End, moreDiags = r.decodePosFromBody(block.Body) |
| 322 | diags = append(diags, moreDiags...) |
| 323 | default: |
| 324 | panic(fmt.Sprintf("unsupported block type %q", block.Type)) |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | return Range, remain, diags |
| 329 | } |
| 330 | |
| 331 | var testFileSchema = &hcl.BodySchema{ |
| 332 | Attributes: []hcl.AttributeSchema{ |
no test coverage detected