@Test void addWatchers() { LanguageClient client = mock(LanguageClient.class); ClientProvider provider = new ClientProvider(); provider.set(client); ArgumentCaptor<RegistrationParams> captor = forClass(RegistrationParams.class); WatcherService watcherService = new WatcherServiceImpl(provider); watcherService.addWatchers(List.of("foo/bar", "baz", "bar\\foo")); assertEquals(List.of("foo/bar", "baz", "bar\\foo"), watcherService.getWatchingFolders()); verify(client).registerCapability(captor.capture()); RegistrationParams params = captor.getValue(); assertEquals(3, params.getRegistrations().size()); assertRegistration(params.getRegistrations().get(0), "foo/bar"); assertRegistration(params.getRegistrations().get(1), "baz"); assertRegistration(params.getRegistrations().get(2), "bar\\foo"); }
@Override @Synchronized public void addWatchers(@Nonnull List<String> paths) { register( paths.stream() .map( folder -> { folderWatchers.add(folder); return new Registration( folder, WATCH_FILES, new DidChangeWatchedFilesRegistrationOptions( asList( new FileSystemWatcher(createFileWatcher(folder), WATCH_ALL_KIND), new FileSystemWatcher(createFolderWatcher(folder), WATCH_ALL_KIND)))); }) .collect(toList())); }
WatcherServiceImpl implements WatcherService { @Override @Synchronized public void addWatchers(@Nonnull List<String> paths) { register( paths.stream() .map( folder -> { folderWatchers.add(folder); return new Registration( folder, WATCH_FILES, new DidChangeWatchedFilesRegistrationOptions( asList( new FileSystemWatcher(createFileWatcher(folder), WATCH_ALL_KIND), new FileSystemWatcher(createFolderWatcher(folder), WATCH_ALL_KIND)))); }) .collect(toList())); } }
WatcherServiceImpl implements WatcherService { @Override @Synchronized public void addWatchers(@Nonnull List<String> paths) { register( paths.stream() .map( folder -> { folderWatchers.add(folder); return new Registration( folder, WATCH_FILES, new DidChangeWatchedFilesRegistrationOptions( asList( new FileSystemWatcher(createFileWatcher(folder), WATCH_ALL_KIND), new FileSystemWatcher(createFolderWatcher(folder), WATCH_ALL_KIND)))); }) .collect(toList())); } @Inject  WatcherServiceImpl(Provider<LanguageClient> clientProvider); }
WatcherServiceImpl implements WatcherService { @Override @Synchronized public void addWatchers(@Nonnull List<String> paths) { register( paths.stream() .map( folder -> { folderWatchers.add(folder); return new Registration( folder, WATCH_FILES, new DidChangeWatchedFilesRegistrationOptions( asList( new FileSystemWatcher(createFileWatcher(folder), WATCH_ALL_KIND), new FileSystemWatcher(createFolderWatcher(folder), WATCH_ALL_KIND)))); }) .collect(toList())); } @Inject  WatcherServiceImpl(Provider<LanguageClient> clientProvider); @Nonnull List<String> getWatchingFolders(); @Override void watchConfigurationChange(); @Override void watchPredefinedFolder(); @Override @Synchronized void addWatchers(@Nonnull List<String> paths); @Override @Synchronized void removeWatchers(@Nonnull List<String> paths); }
WatcherServiceImpl implements WatcherService { @Override @Synchronized public void addWatchers(@Nonnull List<String> paths) { register( paths.stream() .map( folder -> { folderWatchers.add(folder); return new Registration( folder, WATCH_FILES, new DidChangeWatchedFilesRegistrationOptions( asList( new FileSystemWatcher(createFileWatcher(folder), WATCH_ALL_KIND), new FileSystemWatcher(createFolderWatcher(folder), WATCH_ALL_KIND)))); }) .collect(toList())); } @Inject  WatcherServiceImpl(Provider<LanguageClient> clientProvider); @Nonnull List<String> getWatchingFolders(); @Override void watchConfigurationChange(); @Override void watchPredefinedFolder(); @Override @Synchronized void addWatchers(@Nonnull List<String> paths); @Override @Synchronized void removeWatchers(@Nonnull List<String> paths);  }