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

Hover doesn't work on functions that are not fully qualified #673

Closed
natrys opened this issue Feb 7, 2022 · 3 comments
Closed

Hover doesn't work on functions that are not fully qualified #673

natrys opened this issue Feb 7, 2022 · 3 comments

Comments

@natrys
Copy link

natrys commented Feb 7, 2022

Environment

  • Elixir & Erlang versions (elixir --version): Elixir 1.13.2 (compiled with Erlang/OTP 24)
  • Elixir Language Server version: git HEAD
  • Operating system: Linux
  • Editor or IDE name (e.g. Emacs/VSCode): neovim/VSCode
  • Editor Plugin/LSP Client name and version:

Current behavior

When I hover on a function name that's not fully qualified (and its module already imported before) the function is being interpreted as "Elixir.function" instead of "CorrectModule.function" and as such documentation lookup fails. This happens for both project local and 3rd party library symbols.

screenshot

ElixirLS log:

Started ElixirLS v0.9.0
Elixir version: "1.13.2 (compiled with Erlang/OTP 24)"
Erlang version: "24"
ElixirLS compiled with Elixir 1.13.2 and erlang 24
MIX_ENV: test
MIX_TARGET: 
[Info  - 01:46:31] Compile took 517 milliseconds
[Info  - 01:46:31] [ElixirLS WorkspaceSymbols] Indexing...
[Info  - 01:46:31] [ElixirLS Dialyzer] Checking for stale beam files
[Info  - 01:46:31] [ElixirLS Dialyzer] Found 1 changed files in 2 milliseconds
[Info  - 01:46:31] [ElixirLS Dialyzer] Analyzing 0 modules: []
[Info  - 01:46:31] [ElixirLS Dialyzer] Analysis finished in 23 milliseconds
[Info  - 01:46:31] Dialyzer analysis is up to date
[Info  - 01:46:31] [ElixirLS WorkspaceSymbols] Module discovery complete
[Info  - 01:46:32] [ElixirLS WorkspaceSymbols] 23 callbacks added to index
[Info  - 01:46:32] [ElixirLS WorkspaceSymbols] 194 modules added to index
[Info  - 01:46:32] [ElixirLS Dialyzer] Writing manifest...
[Info  - 01:46:33] [ElixirLS Dialyzer] Done writing manifest in 1159 milliseconds.
[Info  - 01:46:33] [ElixirLS WorkspaceSymbols] 334 types added to index
[Info  - 01:46:40] [ElixirLS WorkspaceSymbols] 4173 functions added to index
[Error - 01:47:06] Request textDocument/hover failed.
  Message: an exception was raised:
    ** (UndefinedFunctionError) function :"Elixir.hello".__info__/1 is undefined (module :"Elixir.hello" is not available)
        :"Elixir.hello".__info__(:compile)
        (language_server 0.9.0) lib/language_server/providers/hover.ex:149: ElixirLS.LanguageServer.Providers.Hover.source/1
        (language_server 0.9.0) lib/language_server/providers/hover.ex:134: ElixirLS.LanguageServer.Providers.Hover.dep_name/2
        (language_server 0.9.0) lib/language_server/providers/hover.ex:92: ElixirLS.LanguageServer.Providers.Hover.hexdocs_link/3
        (language_server 0.9.0) lib/language_server/providers/hover.ex:72: ElixirLS.LanguageServer.Providers.Hover.add_hexdocs_link/3
        (language_server 0.9.0) lib/language_server/providers/hover.ex:65: ElixirLS.LanguageServer.Providers.Hover.contents/3
        (language_server 0.9.0) lib/language_server/providers/hover.ex:29: ElixirLS.LanguageServer.Providers.Hover.hover/4
        (language_server 0.9.0) lib/language_server/server.ex:783: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2
  Code: -32000 

01:47:06.431 [error] Process #PID<0.172.0> raised an exception
** (UndefinedFunctionError) function :"Elixir.hello".__info__/1 is undefined (module :"Elixir.hello" is not available)
    :"Elixir.hello".__info__(:compile)
    (language_server 0.9.0) lib/language_server/providers/hover.ex:149: ElixirLS.LanguageServer.Providers.Hover.source/1
    (language_server 0.9.0) lib/language_server/providers/hover.ex:134: ElixirLS.LanguageServer.Providers.Hover.dep_name/2
    (language_server 0.9.0) lib/language_server/providers/hover.ex:92: ElixirLS.LanguageServer.Providers.Hover.hexdocs_link/3
    (language_server 0.9.0) lib/language_server/providers/hover.ex:72: ElixirLS.LanguageServer.Providers.Hover.add_hexdocs_link/3
    (language_server 0.9.0) lib/language_server/providers/hover.ex:65: ElixirLS.LanguageServer.Providers.Hover.contents/3
    (language_server 0.9.0) lib/language_server/providers/hover.ex:29: ElixirLS.LanguageServer.Providers.Hover.hover/4
    (language_server 0.9.0) lib/language_server/server.ex:783: anonymous fn/3 in ElixirLS.LanguageServer.Server.handle_request_async/2

Expected behavior

This seems to be happening since this commit: 2e7ac6d

Before that, it worked as expected.

@lukaszsamson
Copy link
Collaborator

@zhenfeng-zhu can you take a look?

@gofenix
Copy link
Contributor

gofenix commented Feb 9, 2022

I found the cause of this bug,let me fix it.

gofenix pushed a commit to gofenix/elixir-ls that referenced this issue Feb 10, 2022
@gofenix gofenix mentioned this issue Feb 10, 2022
lukaszsamson pushed a commit that referenced this issue Feb 11, 2022
* #673 fix hover bug for

* use function_exported to check module be loaded

Change-Id: I8e3c3cde067a7d3313422c0a94f4c4a464bd37de

* remove rescue and use if instead of nested cond

Change-Id: Ia85056971d7333df5d6a7cf6d3a6bd21c87635eb

Co-authored-by: zhuzhenfeng.code <[email protected]>
@lukaszsamson
Copy link
Collaborator

Addressed in #674

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