MCPcopy Create free account
hub / github.com/microsoft/typescript-go / APIUpdate

Method APIUpdate

internal/project/api.go:14–28  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
14func (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}

Callers 2

handleUpdateSnapshotMethod · 0.80
releaseOpenRefsMethod · 0.80

Calls 6

flushChangesMethod · 0.95
updateSnapshotRefMethod · 0.95
mergeFileChangeSummaryFunction · 0.85
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected