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

Method WithSnapshotLoadingProjectTree

internal/project/session.go:1064–1076  ·  view source on GitHub ↗

WithSnapshotLoadingProjectTree acquires a ref'd snapshot with the requested project trees loaded, then calls fn. The snapshot stays alive for the duration of fn.

(
	ctx context.Context,
	requestedProjectTrees *collections.Set[tspath.Path],
	fn func(*Snapshot),
)

Source from the content-addressed store, hash-verified

1062// requested project trees loaded, then calls fn. The snapshot stays alive
1063// for the duration of fn.
1064func (s *Session) WithSnapshotLoadingProjectTree(
1065 ctx context.Context,
1066 requestedProjectTrees *collections.Set[tspath.Path],
1067 fn func(*Snapshot),
1068) {
1069 snapshot := s.getSnapshot(
1070 ctx,
1071 ResourceRequest{ProjectTree: &ProjectTreeRequest{requestedProjectTrees}},
1072 true, /*callerRef*/
1073 )
1074 defer snapshot.Deref(s)
1075 fn(snapshot)
1076}
1077
1078// GetCurrentLanguageServiceWithAutoImports flushes pending file changes, clones the
1079// current snapshot with auto-import preparation for the given URI, then returns a

Callers 2

handleWorkspaceSymbolMethod · 0.80

Calls 3

getSnapshotMethod · 0.95
fnFunction · 0.50
DerefMethod · 0.45

Tested by

no test coverage detected