WatchFiles implements project.Client.
(ctx context.Context, id project.WatcherID, watchers []*lsproto.FileSystemWatcher)
| 228 | |
| 229 | // WatchFiles implements project.Client. |
| 230 | func (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. |
| 259 | func (s *Server) UnwatchFiles(ctx context.Context, id project.WatcherID) error { |
nothing calls this directly
no test coverage detected