(v node, offset int)
| 33 | } |
| 34 | |
| 35 | func navigationStepsRev(v node, offset int) []string { |
| 36 | switch tv := v.(type) { |
| 37 | case *objectVal: |
| 38 | // Do any of our properties have an object that contains the target |
| 39 | // offset? |
| 40 | for _, attr := range tv.Attrs { |
| 41 | k := attr.Name |
| 42 | av := attr.Value |
| 43 | |
| 44 | switch av.(type) { |
| 45 | case *objectVal, *arrayVal: |
| 46 | // okay |
| 47 | default: |
| 48 | continue |
| 49 | } |
| 50 | |
| 51 | if av.Range().ContainsOffset(offset) { |
| 52 | return append(navigationStepsRev(av, offset), "."+k) |
| 53 | } |
| 54 | } |
| 55 | case *arrayVal: |
| 56 | // Do any of our elements contain the target offset? |
| 57 | for i, elem := range tv.Values { |
| 58 | |
| 59 | switch elem.(type) { |
| 60 | case *objectVal, *arrayVal: |
| 61 | // okay |
| 62 | default: |
| 63 | continue |
| 64 | } |
| 65 | |
| 66 | if elem.Range().ContainsOffset(offset) { |
| 67 | return append(navigationStepsRev(elem, offset), fmt.Sprintf("[%d]", i)) |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | return nil |
| 73 | } |
no test coverage detected