From e4a02a17fdf66e78c4b4392345eefbe8b59f4b8d Mon Sep 17 00:00:00 2001 From: Winston Liu <50Wliu@users.noreply.github.com> Date: Tue, 28 May 2019 16:36:03 -0400 Subject: [PATCH] HACK: Support eclipe.jdt.ls's break with the LSP spec --- lib/adapters/code-action-adapter.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/adapters/code-action-adapter.ts b/lib/adapters/code-action-adapter.ts index c456e7e..54da57b 100644 --- a/lib/adapters/code-action-adapter.ts +++ b/lib/adapters/code-action-adapter.ts @@ -89,10 +89,20 @@ export default class CodeActionAdapter { connection: LanguageClientConnection, ): Promise { if (Command.is(command)) { - await connection.executeCommand({ - command: command.command, - arguments: command.arguments, - }); + // eclipse.jdt.ls breaks with the spec and expects the client to handle the command + // https://github.com/eclipse/eclipse.jdt.ls/issues/376 + if (command.command === 'java.apply.workspaceEdit') { + if (command.arguments) { + // Guaranteed only ever one element in the arguments array + const edit: WorkspaceEdit = command.arguments[0]; + CodeActionAdapter.applyWorkspaceEdit(edit); + } + } else { + await connection.executeCommand({ + command: command.command, + arguments: command.arguments, + }); + } } }