(ctx context.Context, p *path.Command, t api.ResourceType)
| 51 | } |
| 52 | |
| 53 | func buildResources(ctx context.Context, p *path.Command, t api.ResourceType) (*ResolvedResources, error) { |
| 54 | cmdIdx := p.Indices[0] |
| 55 | |
| 56 | capture, err := capture.ResolveGraphics(ctx) |
| 57 | if err != nil { |
| 58 | return nil, err |
| 59 | } |
| 60 | |
| 61 | allCmds, err := Cmds(ctx, p.Capture) |
| 62 | |
| 63 | if err != nil { |
| 64 | return nil, err |
| 65 | } |
| 66 | |
| 67 | s, err := SyncData(ctx, p.Capture) |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | cmds, err := sync.MutationCmdsFor(ctx, p.Capture, s, allCmds, api.CmdID(cmdIdx), p.Indices[1:], false) |
| 72 | if err != nil { |
| 73 | return nil, err |
| 74 | } |
| 75 | initialCmds, ranges, err := initialcmds.InitialCommands(ctx, p.Capture) |
| 76 | if err != nil { |
| 77 | return nil, err |
| 78 | } |
| 79 | state := capture.NewUninitializedState(ctx).ReserveMemory(ranges) |
| 80 | var currentCmdIndex uint64 |
| 81 | var currentCmdResourceCount int |
| 82 | idMap := api.ResourceMap{} |
| 83 | |
| 84 | resources := make(map[id.ID]api.Resource) |
| 85 | |
| 86 | state.OnResourceCreated = func(r api.Resource) { |
| 87 | currentCmdResourceCount++ |
| 88 | i := genResourceID(currentCmdIndex, currentCmdResourceCount) |
| 89 | idMap[r] = i |
| 90 | resources[i] = r |
| 91 | } |
| 92 | |
| 93 | api.ForeachCmd(ctx, initialCmds, func(ctx context.Context, id api.CmdID, cmd api.Cmd) error { |
| 94 | if err := cmd.Mutate(ctx, id, state, nil, nil); err != nil { |
| 95 | log.W(ctx, "Get resources at %v: Initial cmd [%v]%v - %v", p.Indices, id, cmd, err) |
| 96 | } |
| 97 | return nil |
| 98 | }) |
| 99 | err = api.ForeachCmd(ctx, cmds, func(ctx context.Context, id api.CmdID, cmd api.Cmd) error { |
| 100 | currentCmdResourceCount = 0 |
| 101 | currentCmdIndex = uint64(id) |
| 102 | cmd.Mutate(ctx, id, state, nil, nil) |
| 103 | return nil |
| 104 | }) |
| 105 | if err != nil { |
| 106 | return nil, err |
| 107 | } |
| 108 | |
| 109 | resourceData := make(map[id.ID]interface{}) |
| 110 | i := uint64(0) |
no test coverage detected