org.eclipse.lsp4j.DidChangeWatchedFilesRegistrationOptions Java Examples
The following examples show how to use
org.eclipse.lsp4j.DidChangeWatchedFilesRegistrationOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLCapabilityManager.java From lemminx with Eclipse Public License 2.0 | 5 votes |
private void registerWatchedFiles() { List<FileSystemWatcher> watchers = new ArrayList<>(2); watchers.add(new FileSystemWatcher("**/*.xsd")); watchers.add(new FileSystemWatcher("**/*.dtd")); DidChangeWatchedFilesRegistrationOptions options = new DidChangeWatchedFilesRegistrationOptions(watchers); registerCapability(WORKSPACE_WATCHED_FILES_ID, WORKSPACE_WATCHED_FILES, options); }
Example #2
Source File: SyntaxProjectsManager.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public List<FileSystemWatcher> registerWatchers() { logInfo(">> registerFeature 'workspace/didChangeWatchedFiles'"); if (JavaLanguageServerPlugin.getPreferencesManager().getClientPreferences().isWorkspaceChangeWatchedFilesDynamicRegistered()) { IPath[] sources = new IPath[0]; try { sources = listAllSourcePaths(); } catch (JavaModelException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } List<FileSystemWatcher> fileWatchers = new ArrayList<>(); Set<String> patterns = new LinkedHashSet<>(basicWatchers); patterns.addAll(Stream.of(sources).map(ResourceUtils::toGlobPattern).collect(Collectors.toList())); for (String pattern : patterns) { FileSystemWatcher watcher = new FileSystemWatcher(pattern); fileWatchers.add(watcher); } if (!patterns.equals(watchers)) { JavaLanguageServerPlugin.logInfo(">> registerFeature 'workspace/didChangeWatchedFiles'"); DidChangeWatchedFilesRegistrationOptions didChangeWatchedFilesRegistrationOptions = new DidChangeWatchedFilesRegistrationOptions(fileWatchers); JavaLanguageServerPlugin.getInstance().unregisterCapability(Preferences.WORKSPACE_WATCHED_FILES_ID, Preferences.WORKSPACE_WATCHED_FILES); JavaLanguageServerPlugin.getInstance().registerCapability(Preferences.WORKSPACE_WATCHED_FILES_ID, Preferences.WORKSPACE_WATCHED_FILES, didChangeWatchedFilesRegistrationOptions); watchers.clear(); watchers.addAll(patterns); } return fileWatchers; } return Collections.emptyList(); }
Example #3
Source File: ActionScriptLanguageServer.java From vscode-as3mxml with Apache License 2.0 | 5 votes |
@Override public void initialized(InitializedParams params) { boolean canRegisterDidChangeWatchedFiles = false; try { canRegisterDidChangeWatchedFiles = actionScriptServices.getClientCapabilities().getWorkspace().getDidChangeWatchedFiles().getDynamicRegistration(); } catch(NullPointerException e) { canRegisterDidChangeWatchedFiles = false; } if(canRegisterDidChangeWatchedFiles) { List<FileSystemWatcher> watchers = new ArrayList<>(); //ideally, we'd only check .as, .mxml, asconfig.json, and directories //but there's no way to target directories without * watchers.add(new FileSystemWatcher("**/*")); String id = "as3mxml-language-server-" + Math.random(); DidChangeWatchedFilesRegistrationOptions options = new DidChangeWatchedFilesRegistrationOptions(watchers); Registration registration = new Registration(id, "workspace/didChangeWatchedFiles", options); List<Registration> registrations = new ArrayList<>(); registrations.add(registration); RegistrationParams registrationParams = new RegistrationParams(registrations); languageClient.registerCapability(registrationParams); } //we can't notify the client about problems until we receive this //initialized notification. this is the first time that we'll start //checking for errors. actionScriptServices.setInitialized(); }