APIUpdate creates a new snapshot incorporating the given file changes and the supplied API open/close request. The apiRequest may open or close projects and files; opens are tracked in the snapshot (ref-counted) so they persist across future updates, and closes release a previously taken ref. Even a
(ctx context.Context, apiFileChanges FileChangeSummary, apiRequest *APISnapshotRequest)
| 12 | // Returns a ref'd snapshot (which the caller must Deref when done) and any error |
| 13 | // encountered while applying the request, e.g. failing to load a project to open. |
| 14 | func (s *Session) APIUpdate(ctx context.Context, apiFileChanges FileChangeSummary, apiRequest *APISnapshotRequest) (*Snapshot, error) { |
| 15 | s.snapshotUpdateMu.Lock() |
| 16 | defer s.snapshotUpdateMu.Unlock() |
| 17 | s.cancelScheduledSnapshotUpdate() |
| 18 | |
| 19 | fileChanges, overlays, ataChanges, _ := s.flushChanges(ctx) |
| 20 | mergeFileChangeSummary(&fileChanges, apiFileChanges) |
| 21 | |
| 22 | newSnapshot := s.updateSnapshotRef(ctx, overlays, SnapshotChange{ |
| 23 | apiRequest: apiRequest, |
| 24 | fileChanges: fileChanges, |
| 25 | ataChanges: ataChanges, |
| 26 | }) |
| 27 | return newSnapshot, newSnapshot.apiError |
| 28 | } |
no test coverage detected