org.eclipse.lsp4j.UnregistrationParams Java Examples

The following examples show how to use org.eclipse.lsp4j.UnregistrationParams. 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: DefaultLanguageClient.java    From lsp4intellij with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Void> unregisterCapability(UnregistrationParams params) {
    return CompletableFuture.runAsync(() -> params.getUnregisterations().forEach((Unregistration r) -> {
        String id = r.getId();
        Optional<DynamicRegistrationMethods> method = DynamicRegistrationMethods.forName(r.getMethod());
        if (registrations.containsKey(id)) {
            registrations.remove(id);
        } else {
            Map<DynamicRegistrationMethods, String> inverted = new HashMap<>();
            for (Map.Entry<String, DynamicRegistrationMethods> entry : registrations.entrySet()) {
                inverted.put(entry.getValue(), entry.getKey());
            }
            if (method.isPresent() && inverted.containsKey(method.get())) {
                registrations.remove(inverted.get(method.get()));
            }
        }
    }));
}
 
Example #2
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 #3
Source File: LanguageServerWrapper.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
void unregisterCapability(UnregistrationParams params) {
    params.getUnregisterations().forEach(reg -> {
        String id = reg.getId();
        Runnable unregistrator;
        synchronized (dynamicRegistrations) {
            unregistrator = dynamicRegistrations.get(id);
            dynamicRegistrations.remove(id);
        }
        if (unregistrator != null) {
            unregistrator.run();
        }
    });
}
 
Example #4
Source File: XMLCapabilityManager.java    From lemminx with Eclipse Public License 2.0 5 votes vote down vote up
public void unregisterCapability(String id, String method) {
	if (registeredCapabilities.remove(id)) {
		Unregistration unregistration = new Unregistration(id, method);
		UnregistrationParams unregistrationParams = new UnregistrationParams(
				Collections.singletonList(unregistration));
		languageClient.unregisterCapability(unregistrationParams);
	}
}
 
Example #5
Source File: BaseJDTLanguageServer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public void unregisterCapability(String id, String method) {
	if (registeredCapabilities.remove(id)) {
		Unregistration unregistration = new Unregistration(id, method);
		UnregistrationParams unregistrationParams = new UnregistrationParams(Collections.singletonList(unregistration));
		client.unregisterCapability(unregistrationParams);
	}
}
 
Example #6
Source File: LanguageClientImpl.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<Void> unregisterCapability(UnregistrationParams params) {
    return CompletableFuture.runAsync(() -> wrapper.unregisterCapability(params));
}
 
Example #7
Source File: JavaClientConnection.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @see {@link org.eclipse.lsp4j.services.LanguageClient#unregisterCapability(RegistrationParams)}
 */
public void unregisterCapability(UnregistrationParams params) {
	client.unregisterCapability(params);
}
 
Example #8
Source File: CommandRegistryTest.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<Void> unregisterCapability(UnregistrationParams params) {
	Unregistration unreg = Iterables.getFirst(params.getUnregisterations(), null);
	registered.remove(unreg.getId());
	return CompletableFuture.completedFuture(null);
}
 
Example #9
Source File: LanguageClient.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * The client/unregisterCapability request is sent from the server to the client
 * to unregister a previously register capability.
 */
@JsonRequest("client/unregisterCapability")
default CompletableFuture<Void> unregisterCapability(UnregistrationParams params) {
	throw new UnsupportedOperationException();
}