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

Method setupLanguageService

internal/api/session.go:522–529  ·  view source on GitHub ↗

setupLanguageService creates a LanguageService for the given snapshot/project. Unlike setupChecker, this does NOT acquire a checker from the pool, so callers that only need an LS (and not a Checker) can avoid blocking on / holding a pooled checker. The LS acquires its own checker internally (keyed

(sd *snapshotData, program *compiler.Program, projectHandle ProjectID, activeFile string)

Source from the content-addressed store, hash-verified

520// LS operation acquires a checker exactly once; nested acquisitions (e.g. find-all-
521// references) would deadlock on the single-slot persistent checker.
522func (s *Session) setupLanguageService(sd *snapshotData, program *compiler.Program, projectHandle ProjectID, activeFile string) (*ls.LanguageService, error) {
523 projectName := parseProjectHandle(projectHandle)
524 proj := sd.snapshot.ProjectCollection.GetProjectByPath(projectName)
525 if proj == nil {
526 return nil, fmt.Errorf("%w: project %s not found", ErrClientError, projectName)
527 }
528 return ls.NewLanguageService(proj.ConfigFilePath(), program, sd.snapshot, activeFile), nil
529}
530
531// HandleRequest implements Handler.
532func (s *Session) HandleRequest(ctx context.Context, method string, params json.Value) (any, error) {

Calls 5

NewLanguageServiceFunction · 0.92
parseProjectHandleFunction · 0.85
GetProjectByPathMethod · 0.80
ConfigFilePathMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected