use of org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixEdit in project sts4 by spring-projects.
the class SimpleLanguageServer method executeCommand.
protected CompletableFuture<Object> executeCommand(ExecuteCommandParams params) {
ExecuteCommandHandler handler = commands.get(params.getCommand());
if (handler != null) {
return handler.handle(params);
}
if (CODE_ACTION_COMMAND_ID.equals(params.getCommand())) {
Assert.isLegal(params.getArguments().size() == 2);
QuickfixResolveParams quickfixParams = new QuickfixResolveParams((String) params.getArguments().get(0), params.getArguments().get(1));
return quickfixResolve(quickfixParams).flatMap((QuickfixEdit edit) -> {
Mono<ApplyWorkspaceEditResponse> applyEdit = Mono.fromFuture(client.applyEdit(new ApplyWorkspaceEditParams(edit.workspaceEdit)));
Mono<Object> moveCursor = edit.cursorMovement == null ? Mono.just(new ApplyWorkspaceEditResponse(true)) : Mono.fromFuture(client.moveCursor(edit.cursorMovement));
return applyEdit.flatMap(r -> r.getApplied() ? moveCursor : Mono.just(new ApplyWorkspaceEditResponse(true)));
}).toFuture();
}
Log.warn("Unknown command ignored: " + params.getCommand());
return CompletableFuture.completedFuture(false);
}
Aggregations