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

jdtls: -32601: No delegateCommandHandler for java.action.generateConstructorsPrompt #2774

Open
tukaloff opened this issue Jul 23, 2023 · 3 comments

Comments

@tukaloff
Copy link

On vim.lsp.buf.execute_command for java.action.generateConstructorsPrompt return exception:

jdtls: -32601: No delegateCommandHandler for java.action.generateConstructorsPrompt

but works for vim.lsp.buf.code_action

@mfussenegger
Copy link
Contributor

You should only see that if the client sets extendedClientCapabilities.generateConstructorsPromptSupport to true. And if you set that, the client is expected to handle the command on the client side.

It looks like https://github.com/weilbith/nvim-code-action-menu/ doesn't handle client commands at all. You'll have to use the builtin vim.lsp.buf.code_action()

@tukaloff
Copy link
Author

@mfussenegger thanks for help!

I tried to set this param in ftplugin/java.lua in my nvim config and use sending command script on java file and still receive this error.

I don't understand how to set it up.

My settings in ftplugin:

...
local extendedClientCapabilities = jdtls.extendedClientCapabilities
extendedClientCapabilities.generateConstructorsPromptSupport = true

local config = {
    cmd = get_cmd(),

    capabilities = capabilities,
    root_dir = require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'}),

    settings = {
        ['java.settings.url'] = java_settings_url,
        java = {
            signatureHelp = {enabled = true},
            contentProvider = {preferred = "fernflower"},
            configuration = {
                runtimes = {
                    {
                        name = 'JavaSE-11',
                        path = jdk_dir
                    }
                }
            }
        }
    },
    on_attach = on_attach,

    init_options = {
        extendedClientCapabilities = extendedClientCapabilities
    },
}

jdtls.start_or_attach(config)

script I call on file

local command = {
  arguments = { {
      context = {
        diagnostics = {}
      },
      range = {
        ["end"] = {
          character = 0,
          line = 25
        },
        start = {
          character = 0,
          line = 25
        }
      },
      textDocument = {
        uri = "file:///Users/tukaloff/git/media-fs-transfer-tool/src/main/java/com/tukaloff/mediafstransfertool/FileService.java"
      }
    } },
  command = "java.action.generateConstructorsPrompt",
  title = "Generate Constructors..."
} 

vim.lsp.buf.execute_command(command)

@mfussenegger
Copy link
Contributor

java.action.generateConstructorsPrompt is a client side command. You can't use vim.lsp.buf.execute_command(command) with it, that method is for server side commands.

See https://github.com/neovim/neovim/blob/4e4ad4312e6b3755a2114ab81c62033e6bc616fe/runtime/lua/vim/lsp.lua#L1669 for how neovim core handles commands

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

No branches or pull requests

2 participants