use of org.eclipse.lsp4j.ExecuteCommandParams in project xtext-core by eclipse.
the class CommandServiceTest method testExecuteCommand.
protected void testExecuteCommand(final Procedure1<? super CommandServiceTest.TestExecuteCommandConfiguration> configurator) {
try {
@Extension final CommandServiceTest.TestExecuteCommandConfiguration configuration = new CommandServiceTest.TestExecuteCommandConfiguration();
configurator.apply(configuration);
final String command = configuration.command;
final List<Object> args = configuration.args;
ExecuteCommandParams _executeCommandParams = new ExecuteCommandParams(command, args);
final CompletableFuture<Object> result = this.languageServer.executeCommand(_executeCommandParams);
if ((configuration.assertCommandResult != null)) {
final Object value = result.get();
configuration.assertCommandResult.accept(value);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.lsp4j.ExecuteCommandParams in project xtext-core by eclipse.
the class CommandRegistryTest method testRegistration.
@Test
public void testRegistration() {
final ExecutableCommandRegistry reg = new ExecutableCommandRegistry();
ClientCapabilities _clientCapabilities = new ClientCapabilities();
final Procedure1<ClientCapabilities> _function = (ClientCapabilities it) -> {
WorkspaceClientCapabilities _workspaceClientCapabilities = new WorkspaceClientCapabilities();
final Procedure1<WorkspaceClientCapabilities> _function_1 = (WorkspaceClientCapabilities it_1) -> {
ExecuteCommandCapabilities _executeCommandCapabilities = new ExecuteCommandCapabilities();
final Procedure1<ExecuteCommandCapabilities> _function_2 = (ExecuteCommandCapabilities it_2) -> {
it_2.setDynamicRegistration(Boolean.valueOf(true));
};
ExecuteCommandCapabilities _doubleArrow = ObjectExtensions.<ExecuteCommandCapabilities>operator_doubleArrow(_executeCommandCapabilities, _function_2);
it_1.setExecuteCommand(_doubleArrow);
};
WorkspaceClientCapabilities _doubleArrow = ObjectExtensions.<WorkspaceClientCapabilities>operator_doubleArrow(_workspaceClientCapabilities, _function_1);
it.setWorkspace(_doubleArrow);
};
final ClientCapabilities cap = ObjectExtensions.<ClientCapabilities>operator_doubleArrow(_clientCapabilities, _function);
reg.initialize(Collections.<IResourceServiceProvider>unmodifiableList(CollectionLiterals.<IResourceServiceProvider>newArrayList(this)), cap, this);
Assert.assertEquals("static-command", IterableExtensions.<String>head(reg.getCommands()));
ExecuteCommandParams _executeCommandParams = new ExecuteCommandParams();
final Procedure1<ExecuteCommandParams> _function_1 = (ExecuteCommandParams it) -> {
it.setCommand("static-command");
};
ExecuteCommandParams _doubleArrow = ObjectExtensions.<ExecuteCommandParams>operator_doubleArrow(_executeCommandParams, _function_1);
reg.executeCommand(_doubleArrow, null, null);
ExecuteCommandParams _executeCommandParams_1 = new ExecuteCommandParams();
final Procedure1<ExecuteCommandParams> _function_2 = (ExecuteCommandParams it) -> {
it.setCommand("dynamic-command");
};
ExecuteCommandParams _doubleArrow_1 = ObjectExtensions.<ExecuteCommandParams>operator_doubleArrow(_executeCommandParams_1, _function_2);
reg.executeCommand(_doubleArrow_1, null, null);
Assert.assertEquals(Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("static-command")), this.commandsExecuted);
this.commandsExecuted.clear();
final IDisposable disposable = this.register.apply("dynamic-command");
ExecuteCommandParams _executeCommandParams_2 = new ExecuteCommandParams();
final Procedure1<ExecuteCommandParams> _function_3 = (ExecuteCommandParams it) -> {
it.setCommand("dynamic-command");
};
ExecuteCommandParams _doubleArrow_2 = ObjectExtensions.<ExecuteCommandParams>operator_doubleArrow(_executeCommandParams_2, _function_3);
reg.executeCommand(_doubleArrow_2, null, null);
Assert.assertEquals(Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("dynamic-command")), this.commandsExecuted);
this.commandsExecuted.clear();
disposable.dispose();
ExecuteCommandParams _executeCommandParams_3 = new ExecuteCommandParams();
final Procedure1<ExecuteCommandParams> _function_4 = (ExecuteCommandParams it) -> {
it.setCommand("dynamic-command");
};
ExecuteCommandParams _doubleArrow_3 = ObjectExtensions.<ExecuteCommandParams>operator_doubleArrow(_executeCommandParams_3, _function_4);
reg.executeCommand(_doubleArrow_3, null, null);
Assert.assertEquals(Collections.<Object>unmodifiableSet(CollectionLiterals.<Object>newHashSet()), this.commandsExecuted);
}
Aggregations