Search in sources :

Example 1 with QuickfixResolveParams

use of org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixResolveParams 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);
}
Also used : JsonObject(com.google.gson.JsonObject) CodeLensOptions(org.eclipse.lsp4j.CodeLensOptions) LanguageClient(org.eclipse.lsp4j.services.LanguageClient) Sts4LanguageServer(org.springframework.ide.vscode.commons.languageserver.Sts4LanguageServer) QuickfixData(org.springframework.ide.vscode.commons.languageserver.quickfix.Quickfix.QuickfixData) LoggerFactory(org.slf4j.LoggerFactory) DiagnosticService(org.springframework.ide.vscode.commons.languageserver.DiagnosticService) MessageType(org.eclipse.lsp4j.MessageType) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) VscodeCompletionEngineAdapter(org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter) Map(java.util.Map) IProblemCollector(org.springframework.ide.vscode.commons.languageserver.reconcile.IProblemCollector) URI(java.net.URI) QuickfixRegistry(org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixRegistry) ProgressService(org.springframework.ide.vscode.commons.languageserver.ProgressService) DiagnosticSeverity(org.eclipse.lsp4j.DiagnosticSeverity) BadLocationException(org.springframework.ide.vscode.commons.util.BadLocationException) Collection(java.util.Collection) UUID(java.util.UUID) ClasspathListenerManager(org.springframework.ide.vscode.commons.languageserver.jdt.ls.ClasspathListenerManager) Assert(org.springframework.ide.vscode.commons.util.Assert) ServerCapabilities(org.eclipse.lsp4j.ServerCapabilities) Quickfix(org.springframework.ide.vscode.commons.languageserver.quickfix.Quickfix) List(java.util.List) ExecuteCommandOptions(org.eclipse.lsp4j.ExecuteCommandOptions) JsonArray(com.google.gson.JsonArray) ClasspathListener(org.springframework.ide.vscode.commons.languageserver.jdt.ls.ClasspathListener) WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder) InitializeParams(org.eclipse.lsp4j.InitializeParams) WorkspaceFoldersOptions(org.eclipse.lsp4j.WorkspaceFoldersOptions) LanguageClientAware(org.eclipse.lsp4j.services.LanguageClientAware) Disposable(reactor.core.Disposable) ApplyWorkspaceEditParams(org.eclipse.lsp4j.ApplyWorkspaceEditParams) AsyncRunner(org.springframework.ide.vscode.commons.languageserver.util.AsyncRunner) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) CompletableFuture(java.util.concurrent.CompletableFuture) Diagnostic(org.eclipse.lsp4j.Diagnostic) Range(org.eclipse.lsp4j.Range) QuickfixResolveParams(org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixResolveParams) Scheduler(reactor.core.scheduler.Scheduler) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) LazyCompletionResolver(org.springframework.ide.vscode.commons.languageserver.completion.VscodeCompletionEngineAdapter.LazyCompletionResolver) ImmutableList(com.google.common.collect.ImmutableList) ExecuteCommandParams(org.eclipse.lsp4j.ExecuteCommandParams) MessageParams(org.eclipse.lsp4j.MessageParams) Schedulers(reactor.core.scheduler.Schedulers) Registration(org.eclipse.lsp4j.Registration) LinkedHashSet(java.util.LinkedHashSet) TextDocumentSyncKind(org.eclipse.lsp4j.TextDocumentSyncKind) InitializeResult(org.eclipse.lsp4j.InitializeResult) RegistrationParams(org.eclipse.lsp4j.RegistrationParams) QuickfixEdit(org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixEdit) Logger(org.slf4j.Logger) Log(org.springframework.ide.vscode.commons.util.Log) ProgressParams(org.springframework.ide.vscode.commons.languageserver.ProgressParams) ICompletionEngine(org.springframework.ide.vscode.commons.languageserver.completion.ICompletionEngine) Mono(reactor.core.publisher.Mono) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) Consumer(java.util.function.Consumer) CollectionUtil(org.springframework.ide.vscode.commons.util.CollectionUtil) STS4LanguageClient(org.springframework.ide.vscode.commons.languageserver.STS4LanguageClient) Paths(java.nio.file.Paths) ProblemSeverity(org.springframework.ide.vscode.commons.languageserver.reconcile.ProblemSeverity) CompletionOptions(org.eclipse.lsp4j.CompletionOptions) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) IReconcileEngine(org.springframework.ide.vscode.commons.languageserver.reconcile.IReconcileEngine) ReconcileProblem(org.springframework.ide.vscode.commons.languageserver.reconcile.ReconcileProblem) Collections(java.util.Collections) ApplyWorkspaceEditResponse(org.eclipse.lsp4j.ApplyWorkspaceEditResponse) QuickfixEdit(org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixEdit) ApplyWorkspaceEditParams(org.eclipse.lsp4j.ApplyWorkspaceEditParams) ApplyWorkspaceEditResponse(org.eclipse.lsp4j.ApplyWorkspaceEditResponse) QuickfixResolveParams(org.springframework.ide.vscode.commons.languageserver.quickfix.QuickfixResolveParams) Mono(reactor.core.publisher.Mono)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 URI (java.net.URI)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 UUID (java.util.UUID)1 Callable (java.util.concurrent.Callable)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Consumer (java.util.function.Consumer)1 ApplyWorkspaceEditParams (org.eclipse.lsp4j.ApplyWorkspaceEditParams)1 ApplyWorkspaceEditResponse (org.eclipse.lsp4j.ApplyWorkspaceEditResponse)1 CodeLensOptions (org.eclipse.lsp4j.CodeLensOptions)1