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

Error displaying hover on self-written module/function documentation #932

Closed
H12 opened this issue Jul 6, 2023 · 10 comments
Closed

Error displaying hover on self-written module/function documentation #932

H12 opened this issue Jul 6, 2023 · 10 comments

Comments

@H12
Copy link

H12 commented Jul 6, 2023

Environment

  • Elixir & Erlang versions (elixir --version): Elixir 1.14.3 & Erlang 25.2.2
  • Elixir Language Server version: 0.15.1
  • Operating system: MacOS 13.3.1
  • Editor or IDE name (e.g. Emacs/VSCode): VSCode & NeoVim (Reproduced in both)
  • Editor Plugin/LSP Client name and version: ElixirLS: Elixir support and debugger (VSCode), elixir-ls (NeoVim lsp config)

Current behavior

When I attempt to display a hover window for functions/module documentation in my project, the operation fails. Doing the same for externally defined documentation works as-expected, however.

In VSCode, I see the following error:

[Error - 9:03:47 AM] Request textDocument/hover failed.
  Message: an exception was raised:
    ** (CaseClauseError) no case clause matching: nil
        (elixir_sense 2.0.0) lib/elixir_sense/providers/docs.ex:58: ElixirSense.Providers.Docs.mod_fun_docs/9
        (elixir_sense 2.0.0) lib/elixir_sense.ex:74: ElixirSense.docs/3
        (language_server 0.15.1) lib/language_server/providers/hover.ex:24: ElixirLS.LanguageServer.Providers.Hover.hover/4
        (language_server 0.15.1) lib/language_server/server.ex:834: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2
  Code: -32000 
[Error - 9:03:47 AM] Process #PID<0.420.0> raised an exception
** (CaseClauseError) no case clause matching: nil
    (elixir_sense 2.0.0) lib/elixir_sense/providers/docs.ex:58: ElixirSense.Providers.Docs.mod_fun_docs/9
    (elixir_sense 2.0.0) lib/elixir_sense.ex:74: ElixirSense.docs/3
    (language_server 0.15.1) lib/language_server/providers/hover.ex:24: ElixirLS.LanguageServer.Providers.Hover.hover/4
    (language_server 0.15.1) lib/language_server/server.ex:834: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2

In NeoVim, this is what I see:

[ERROR][2023-07-06 09:04:48] ...lsp/handlers.lua:535	"Process #PID<0.393.0> raised an exception
** (CaseClauseError) no case clause matching: nil
    (elixir_sense 2.0.0) lib/elixir_sense/providers/docs.ex:58: ElixirSense.Providers.Docs.mod_fun_docs/9
    (elixir_sense 2.0.0) lib/elixir_sense.ex:74: ElixirSense.docs/3
    (language_server 0.15.1) lib/language_server/providers/hover.ex:24: ElixirLS.LanguageServer.Providers.Hover.hover/4
    (language_server 0.15.1) lib/language_server/server.ex:834: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2"

I was able to reproduce in both editors by generating a new default mix project (e.g. mix new lsp_test) and attempting to trigger hover documentation for LspTest.hello/0 via shift+K in both VSCode and NeoVim.

Expected behavior

Hover documentation displays properly.

@lukaszsamson
Copy link
Collaborator

That's a known (and harmless) issue.

@H12
Copy link
Author

H12 commented Jul 7, 2023

Not sure exactly what changed by the issue appeared to resolve itself. I wonder if the PLT simply hadn't fully generated?

🤷🏻

@H12 H12 closed this as completed Jul 7, 2023
@lukaszsamson lukaszsamson reopened this Jul 7, 2023
@lukaszsamson
Copy link
Collaborator

Reopening for visibility

@jacksonludwig
Copy link

jacksonludwig commented Jul 28, 2023

maybe caused by this commit 303dafb

@lukaszsamson
Copy link
Collaborator

maybe caused by this commit 303dafb

No. It was never supported and didn't crash by accident. Refactor to CodeFragment API exposed the crash

@jacksonludwig
Copy link

jacksonludwig commented Jul 29, 2023

maybe caused by this commit 303dafb

No. It was never supported and didn't crash by accident. Refactor to CodeFragment API exposed the crash

Thanks for the info. But I'm confused when you say that it was never supported, as if this is expected behavior for an error to be thrown.

EDIT: Okay I think I understand: the LSP does not/no longer supports querying for hover info on these types of values.

@lukaszsamson
Copy link
Collaborator

It’s a feature that was never implemented. elixir_sense currently only provides docs from compiled modules that have doc chunks. For current file it used to return some dummy string and now it returns nil that is not handled. I plan to implement doc extraction from the current file for the next release

@lukaszsamson
Copy link
Collaborator

Partially addressed in elixir-lsp/elixir_sense#253

@lukaszsamson
Copy link
Collaborator

The crash is fixed now. ElixirLS will return stub documentation on hover for current file. Providing full documentation is tracked in elixir-lsp/elixir_sense#261

@lukaszsamson
Copy link
Collaborator

Full local documentation will be released in v0.20

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

3 participants