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

codeActionKinds not sent when CodeActionClientCapabilities is not dynamic. #3148

Conversation

ethan-vanderheijden
Copy link
Contributor

When a client registers with CodeActionClientCapabilities.dynamic equal to true, the server will respond with:

capabilities: {
    ...
    codeActionProvider: {
        codeActionKinds: [...],
        resolveProvider: true,
    },
}

But if CodeActionClientCapabilities.dynamic is false, then the server responds with:

capabilities: {
    ...
    codeActionProvider: {
        resolveProvider: true,
    },
}

The server will never provide codeActionKinds when CodeActionClientCapabilities is not dynamic. I believe this behavior is a mistake (correct me if I'm wrong), and with this pull request, the server will always respond with codeActionKinds.

@eclipse-ls-bot
Copy link

Can one of the admins verify this patch?

@rgrunber
Copy link
Contributor

rgrunber commented May 8, 2024

I agree here. I think even if the client doesn't request dynamic registration, the static registration should include codeActionKinds.

Just a small note on your above example (but I think you're probably aware). When the client sends an initialize request, and if the capabilities contain codeAction whose dynamicRegistration is set to true, then there is no codeActionProvider in the response at all. The whole point of dynamic registration is it allows the server to register the capability as needed, and not immediately in response to the initialize request. The server ends up responding in a separate request with something like :

[Trace - 20:21:14] Received request 'client/registerCapability - (22)'.
Params: {
    "registrations": [
        {
            "id": "5c466800-e81a-4dd3-878d-5b1b9520dead",
            "method": "textDocument/codeAction",
            "registerOptions": {
                "codeActionKinds": [
                    "quickfix",
                    "refactor",
                    "refactor.extract",
                    "refactor.inline",
                    "refactor.rewrite",
                    "source",
                    "source.organizeImports"
                ],
                "resolveProvider": true
            }
        }
    ]
}

With that said, I think your PR is correct, and you've located the correct method that populates the code action kinds.

@rgrunber rgrunber added this to the End May 2024 milestone May 8, 2024
@rgrunber rgrunber force-pushed the fix-non-dynamic-code-actions branch from 1f29e7f to 8ec8110 Compare May 8, 2024 00:56
@rgrunber rgrunber changed the title Fix: codeActionKinds not sent when CodeActionClientCapability is not dyanmic. Fix: codeActionKinds not sent when CodeActionClientCapability is not dynamic. May 8, 2024
@rgrunber rgrunber force-pushed the fix-non-dynamic-code-actions branch from 8ec8110 to 4c8cf80 Compare May 8, 2024 03:02
Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good!

Comparing dynamicRegistration=false before & after the PR.

(ignore the response time, I was debugging to modify dynamic registration)

--- old.txt 2024-05-07 22:56:23.502143895 -0400
+++ new.txt 2024-05-07 22:51:39.087502455 -0400
@@ -1,4 +1,4 @@
-[Trace - 22:55:42] Received response 'initialize - (0)' in 37789ms.
+[Trace - 22:48:38] Received response 'initialize - (0)' in 100949ms.
 Result: {
     "capabilities": {
         "textDocumentSync": {
@@ -11,6 +11,15 @@
             }
         },
         "codeActionProvider": {
+            "codeActionKinds": [
+                "quickfix",
+                "refactor",
+                "refactor.extract",
+                "refactor.inline",
+                "refactor.rewrite",
+                "source",
+                "source.organizeImports"
+            ],
             "resolveProvider": true
         },
         "workspace": {

@rgrunber rgrunber changed the title Fix: codeActionKinds not sent when CodeActionClientCapability is not dynamic. codeActionKinds not sent when CodeActionClientCapability is not dynamic. May 8, 2024
@rgrunber rgrunber changed the title codeActionKinds not sent when CodeActionClientCapability is not dynamic. codeActionKinds not sent when CodeActionClientCapabilities is not dynamic. May 8, 2024
@rgrunber rgrunber merged commit bd80646 into eclipse-jdtls:master May 8, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants