Skip to content
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

Correctly declare support for "workspace/willRenameFiles". #3127

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

rgrunber
Copy link
Contributor

@rgrunber rgrunber commented Apr 5, 2024

@angelozerr , can you verify this change fixes things for you ? I also would need to adjust vscode-java as it appears to break it by sending a duplicate workspace/willRenameFiles, which causes some problems. Basically that client doesn't want the renames to be applied immediately, but rather get the edits and allow a user to apply/discard them.

--- old.txt 2024-04-05 11:22:47.101634192 -0400
+++ new.txt 2024-04-05 11:31:28.769420565 -0400
@@ -1,4 +1,4 @@
-[Trace - 11:22:11] Received response 'initialize - (0)' in 5456ms.
+[Trace - 11:31:03] Received response 'initialize - (0)' in 6603ms.
 Result: {
     "capabilities": {
         "textDocumentSync": {
@@ -14,6 +14,19 @@
             "workspaceFolders": {
                 "supported": true,
                 "changeNotifications": true
+            },
+            "fileOperations": {
+                "willRename": {
+                    "filters": [
+                        {
+                            "pattern": {
+                                "glob": "**/*.java",
+                                "matches": "file"
+                            },
+                            "scheme": "file"
+                        }
+                    ]
+                }
             }
         },
         "callHierarchyProvider": true,

- The server capabilities in the initialize response must contain a
  "willRename" object in the workspace's "fileOperations" object if the
  client indicates support for the request.

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
@rgrunber rgrunber merged commit d559507 into eclipse-jdtls:master Apr 8, 2024
7 checks passed
@rgrunber rgrunber deleted the fix-3126 branch April 8, 2024 17:47
@mikehaertl
Copy link

@rgrunber If I read this correctly this change now reports a filter back to the client that restricts willRename operations to **/*.java files. It seems this prevents package rename operations in some clients now as the filter excludes directories. At least that's what I see in neovim with nvim-lsp-file-operations. I just started using this, though, so not sure if it worked before.

From the tests it seems that renaming a package should work:

// Test renaming package from "parent.pack2" to "parent.newpack2"
@Test
public void testRenamePackage() throws JavaModelException, BadLocationException {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JDT LS should mention as capability that it can support willRenameFiles
2 participants