MCPcopy Index your code
hub / github.com/microsoft/typescript-go / WatchFiles

Method WatchFiles

internal/lsp/server.go:230–256  ·  view source on GitHub ↗

WatchFiles implements project.Client.

(ctx context.Context, id project.WatcherID, watchers []*lsproto.FileSystemWatcher)

Source from the content-addressed store, hash-verified

228
229// WatchFiles implements project.Client.
230func (s *Server) WatchFiles(ctx context.Context, id project.WatcherID, watchers []*lsproto.FileSystemWatcher) error {
231 if s.builtinWatcher != nil {
232 if err := s.builtinWatcher.WatchFiles(string(id), watchers); err != nil {
233 return fmt.Errorf("failed to register file watcher: %w", err)
234 }
235 s.watchers.Add(id)
236 return nil
237 }
238 _, err := sendClientRequest(ctx, s, lsproto.ClientRegisterCapabilityInfo, &lsproto.RegistrationParams{
239 Registrations: []*lsproto.Registration{
240 {
241 Id: string(id),
242 RegisterOptions: &lsproto.RegisterOptions{
243 WorkspaceDidChangeWatchedFiles: &lsproto.DidChangeWatchedFilesRegistrationOptions{
244 Watchers: watchers,
245 },
246 },
247 },
248 },
249 })
250 if err != nil {
251 return fmt.Errorf("failed to register file watcher: %w", err)
252 }
253
254 s.watchers.Add(id)
255 return nil
256}
257
258// UnwatchFiles implements project.Client.
259func (s *Server) UnwatchFiles(ctx context.Context, id project.WatcherID) error {

Callers

nothing calls this directly

Calls 5

sendClientRequestFunction · 0.85
WatchFilesMethod · 0.65
ErrorfMethod · 0.65
AddMethod · 0.65
stringEnum · 0.50

Tested by

no test coverage detected