org.eclipse.lsp4j.Registration Java Examples

The following examples show how to use org.eclipse.lsp4j.Registration. 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: ExecutableCommandRegistry.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected IDisposable register(String command, IExecutableCommandService service) {
	String requestId = UUID.randomUUID().toString();
	Registration reg = new Registration();
	reg.setId(requestId);
	reg.setMethod(ExecutableCommandRegistry.METHOD);
	ExecuteCommandOptions executeCommandOptions = new ExecuteCommandOptions();
	executeCommandOptions.setCommands(Collections.unmodifiableList(Lists.newArrayList(command)));
	reg.setRegisterOptions(executeCommandOptions);
	RegistrationParams registrationParams = new RegistrationParams();
	registrationParams.setRegistrations(Lists.newArrayList(reg));
	client.registerCapability(registrationParams);
	registeredCommands.put(command, service);
	return () -> {
		Unregistration unReg = new Unregistration();
		unReg.setId(requestId);
		unReg.setMethod(ExecutableCommandRegistry.METHOD);
		UnregistrationParams unregistrationParams = new UnregistrationParams();
		unregistrationParams.setUnregisterations(Lists.newArrayList(unReg));
		this.client.unregisterCapability(unregistrationParams);
		this.registeredCommands.remove(command, service);
	};
}
 
Example #2
Source File: LanguageServerWrapper.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
private void addRegistration(@Nonnull Registration reg, @Nonnull Runnable unregistrationHandler) {
    String regId = reg.getId();
    synchronized (dynamicRegistrations) {
        assert !dynamicRegistrations.containsKey(regId):"Registration id is not unique"; //$NON-NLS-1$
        dynamicRegistrations.put(regId, unregistrationHandler);
    }
}
 
Example #3
Source File: XMLCapabilityManager.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
public void registerCapability(String id, String method, Object options) {
	if (registeredCapabilities.add(id)) {
		Registration registration = new Registration(id, method, options);
		RegistrationParams registrationParams = new RegistrationParams(Collections.singletonList(registration));
		languageClient.registerCapability(registrationParams);
	}
}
 
Example #4
Source File: BaseJDTLanguageServer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public void registerCapability(String id, String method, Object options) {
	if (registeredCapabilities.add(id)) {
		Registration registration = new Registration(id, method, options);
		RegistrationParams registrationParams = new RegistrationParams(Collections.singletonList(registration));
		client.registerCapability(registrationParams);
	}
}
 
Example #5
Source File: ActionScriptLanguageServer.java    From vscode-as3mxml with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example #6
Source File: CommandRegistryTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<Void> registerCapability(RegistrationParams params) {
	Registration reg = Iterables.getFirst(params.getRegistrations(), null);
	registered.put(reg.getId(), reg);
	return CompletableFuture.completedFuture(null);
}
 
Example #7
Source File: RegistrationParams.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
public RegistrationParams() {
  this(new ArrayList<Registration>());
}
 
Example #8
Source File: RegistrationParams.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
public RegistrationParams(@NonNull final List<Registration> registrations) {
  this.registrations = Preconditions.<List<Registration>>checkNotNull(registrations, "registrations");
}
 
Example #9
Source File: RegistrationParams.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
@Pure
@NonNull
public List<Registration> getRegistrations() {
  return this.registrations;
}
 
Example #10
Source File: RegistrationParams.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
public void setRegistrations(@NonNull final List<Registration> registrations) {
  this.registrations = Preconditions.checkNotNull(registrations, "registrations");
}