public Object executeCommand(final ExecuteCommandParams params, final ILanguageServerAccess access, final CancelIndicator cancelIndicator) { Object result = null; Collection<IExecutableCommandService> _get = this.registeredCommands.get(params.getCommand()); for (final IExecutableCommandService service : _get) { { final Object localResult = service.execute(params, access, cancelIndicator); if ((localResult != null)) { if ((result != null)) { StringConcatenation _builder = new StringConcatenation(); _builder.append("Multiple commands \'"); String _command = params.getCommand(); _builder.append(_command); _builder.append("\' have been registered. All are executed but only one result will be send back."); ExecutableCommandRegistry.LOG.error(_builder); } else { result = localResult; } } } } return result; }
@Override public CompletableFuture<Object> executeCommand(final ExecuteCommandParams params) { if (params.getCommand().equals(params.getCommand())) { SomMinitest.executeTest(som, params.getArguments()); } return CompletableFuture.completedFuture(new Object()); }
@Override public CompletableFuture<Object> executeCommand(ExecuteCommandParams params) { logInfo(">> workspace/executeCommand"); WorkspaceExecuteCommandHandler handler = new WorkspaceExecuteCommandHandler(); return computeAsync((cc) -> { return handler.executeCommand(params, toMonitor(cc)); }); }
@Test public void testExecuteCommand() { WorkspaceExecuteCommandHandler handler = new WorkspaceExecuteCommandHandler(); ExecuteCommandParams params = new ExecuteCommandParams(); params.setCommand("testcommand1"); params.setArguments(Arrays.asList("hello", "world")); Object result = handler.executeCommand(params, monitor); assertEquals("testcommand1: helloworld0", result); params.setCommand("testcommand2"); result = handler.executeCommand(params, monitor); assertEquals("testcommand2: helloworld1", result); }
@Test public void testExecuteCommandNonexistingCommand() { expectedEx.expect(ResponseErrorException.class); expectedEx.expectMessage("No delegateCommandHandler for testcommand.not.existing"); WorkspaceExecuteCommandHandler handler = new WorkspaceExecuteCommandHandler(); ExecuteCommandParams params = new ExecuteCommandParams(); params.setCommand("testcommand.not.existing"); params.setArguments(Arrays.asList("hello", "world")); Object result = handler.executeCommand(params, monitor); }
@Test public void testExecuteCommandThrowsExceptionCommand() { expectedEx.expect(ResponseErrorException.class); expectedEx.expectMessage("Unsupported"); WorkspaceExecuteCommandHandler handler = new WorkspaceExecuteCommandHandler(); ExecuteCommandParams params = new ExecuteCommandParams(); params.setCommand("testcommand.throwexception"); handler.executeCommand(params, monitor); }
@Test public void testExecuteCommandInvalidParameters() { expectedEx.expect(ResponseErrorException.class); expectedEx.expectMessage("The workspace/executeCommand has empty params or command"); WorkspaceExecuteCommandHandler handler = new WorkspaceExecuteCommandHandler(); ExecuteCommandParams params = null; handler.executeCommand(params, monitor); }
@Override public CompletableFuture<Object> executeCommand(final ExecuteCommandParams params) { final Function1<CancelIndicator, Object> _function = (CancelIndicator cancelIndicator) -> { return this.commandRegistry.executeCommand(params, this.access, cancelIndicator); }; return this.requestManager.<Object>runRead(_function); }
@Override public Object execute(final ExecuteCommandParams params, final ILanguageServerAccess access, final CancelIndicator cancelIndicator) { return Boolean.valueOf(this.commandsExecuted.add(params.getCommand())); }
/** * The workspace/executeCommand request is sent from the client to the * server to trigger command execution on the server. In most cases the * server creates a WorkspaceEdit structure and applies the changes to the * workspace using the request workspace/applyEdit which is sent from the * server to the client. * * Registration Options: ExecuteCommandRegistrationOptions */ @JsonRequest default CompletableFuture<Object> executeCommand(ExecuteCommandParams params) { throw new UnsupportedOperationException(); }
/** * Called when the client wants to execute a registered command. */ public abstract Object execute(final ExecuteCommandParams params, final ILanguageServerAccess access, final CancelIndicator cancelIndicator);