-
Notifications
You must be signed in to change notification settings - Fork 406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support java.apply.workspaceEdit #2688
Conversation
Can one of the admins verify this patch? |
If this is still wanted, I'm open to just merging. It should be safe given that clients can choose for themselves whether to use the new delegate command for applying workspace edits, or whether it should be done client side. |
Well its still needed in at least some editors, eg helix-editor, see helix-editor/helix#5421 |
So, yes, pretty much wanted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine overall. Just some minor cleanup that can hopefully simplify things.
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JSONUtility.java
Outdated
Show resolved
Hide resolved
org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JDTDelegateCommandHandler.java
Outdated
Show resolved
Hide resolved
- Fixes eclipse-jdtls#376 - This follows exactly same pattern as organizeImports was done. Signed-off-by: Anton Romanov <[email protected]>
Would it be ok to rename the command from There's one small thing I forgot. That extra line in the Because of that line, the server sends
which ends up in https://github.com/microsoft/vscode-languageserver-node/blob/277e4564193c4ed258fe4d8d405d3379665bbab9/client/src/common/executeCommand.ts#L77-L83 .
This can be seen on Line 79 in 2412ed9
Line 279 in 2412ed9
However, I think we can just rename the command you're proposing and as long as clients know to use that, it should be ok. Let me know if you're fine with that. |
But it doesn't come from clients, it comes from jdt.ls itself o_O so clients really have nothing to do with that Are you suggesting that upon receiving "java.apply.workspaceEdit" from server clients have to know to send back "java.edit.workspaceEdit" ? In which case this defeats the purpose of the change - to have protocol compliant clients to work without any jdtls-specific code :( |
can we instead just remove that from |
I was looking at that. However, when VS Code tries to run Lines 214 to 216 in 2412ed9
How about we add some extendedClientCapability (that only VS Code would need to set as Lines 163 to 170 in 2412ed9
Let me know. |
I thought the whole point was that VScode's jdt.ls plugin handles I think I'll try to set up vscode to just cross-check this change to make sure w/e we come up with will work with both |
I was using |
Required by vscode? jdtls? As I said I've removed it from plugin.xml, rebuilt jdtls and it worked just fine. And vscode plugin wouldn't even send it back as it process it itself (thus the conflict if we do put it there) and there is no need to register this command with it... so everyone is happy if its not there? A different, non-jdtls specific client that simply implements the spec would simply echo the command back when user selects the codeAction, as per spec
|
If it's not listed in What's the reason that eclipse.jdt.ls isn't sending a regular workspace edit to begin with? |
I take it for this approach you wouldn't want to just check for client name? Or alternatively - ignore |
There was a PR that changed code action to use edit directly if supported by the client. It was reverted because on vscode-java apparently that would cause formatting differences from how internal custom command would do it ( #1278 ) |
I think we could investigate using a workspace edit directly since the VS Code client should be passing it's format settings to the server since #1657 . I guess the only other issue would be if there are clients that would take longer to migrate to the new (correct) approach. I just wanted to get this PR merged to give other clients some workaround. |
Could eclipse.jdt.ls check the This should work for any standard compliant client that implements the capability, and also wouldn't break any existing client that works via |
This is exactly what #1278 was doing. And we could just re-apply it again, as the only reason that it was reverted was that it didn't use vscode's client-side identation settings. But supposedly that should not be an issue anymore as @rgrunber points out |
I've opened #2962 to return edit directly |
Closing in favor of #2962 |
Fixes #376
This follows exactly same pattern as organizeImports was done. This should preserve existing behaviour for vscode