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

cannot code completion(or find definition) #1411

Open
lyfwfm opened this issue Nov 22, 2022 · 10 comments
Open

cannot code completion(or find definition) #1411

lyfwfm opened this issue Nov 22, 2022 · 10 comments
Labels
bug Something isn't working

Comments

@lyfwfm
Copy link

lyfwfm commented Nov 22, 2022

Describe the bug
cannot code completion(or find definition) for new function or new macro

To Reproduce
new a macro in test.hrl (eg: -define(new_macro, test).), then test.erl use ?new_macro, it cannot code completion and cannot jump to definition.

Expected behavior
want code completion and definition

Actual behavior
as above

Context

  • erlang_ls version (tag/sha): erlang-ls v0.0.39 in vsCode
  • Editor used:
  • LSP client used:

ps:erlang_ls.config has include like
include_dirs:
-"include"

@lyfwfm lyfwfm added the bug Something isn't working label Nov 22, 2022
@lyfwfm
Copy link
Author

lyfwfm commented Nov 22, 2022

important: when i reopen vscode, then i can code completion and find definition, but new function or macro cannot. unless i reopen vscode again

@lyfwfm
Copy link
Author

lyfwfm commented Nov 22, 2022

appreciate to all of you for help!!!

@zylikedream
Copy link

i have same problem on windows, but works fine on wsl

@plux
Copy link
Contributor

plux commented Dec 16, 2022

I can confirm this.

This happens in a rebar3 project with the following config (from erlang ls docs):

apps_dirs:
  - "_build/default/lib/*"
include_dirs:
  - "_build/default/lib/*/include"
  - "include"

The app has a simple structure like this, generate by rebar3 new app example:

.
├── _build
│   └── default
│       └── lib
│           └── example
│               ├── ebin
│               │   ├── example.app
│               │   ├── example_app.beam
│               │   └── example_sup.beam
│               ├── include -> ../../../../include
│               ├── priv -> ../../../../priv
│               └── src -> ../../../../src
├── erlang_ls.config
├── LICENSE
├── README.md
├── rebar.config
├── rebar.lock
└── src
    ├── example_app.erl
    ├── example.app.src
    └── example_sup.erl

For example adding a new exported function to example_sup and then completing in example the new function won't show up in completions.

@lyfwfm
Copy link
Author

lyfwfm commented Dec 16, 2022

I can confirm this.

This happens in a rebar3 project with the following config (from erlang ls docs):

apps_dirs:
  - "_build/default/lib/*"
include_dirs:
  - "_build/default/lib/*/include"
  - "include"

The app has a simple structure like this, generate by rebar3 new app example:

.
├── _build
│   └── default
│       └── lib
│           └── example
│               ├── ebin
│               │   ├── example.app
│               │   ├── example_app.beam
│               │   └── example_sup.beam
│               ├── include -> ../../../../include
│               ├── priv -> ../../../../priv
│               └── src -> ../../../../src
├── erlang_ls.config
├── LICENSE
├── README.md
├── rebar.config
├── rebar.lock
└── src
    ├── example_app.erl
    ├── example.app.src
    └── example_sup.erl

For example adding a new exported function to example_sup and then completing in example the new function won't show up in completions.

thanks a lot.
question above is happen on win10, when i work on wsl, completion works fine. so i think it's maybe bugs on win10

@lyfwfm lyfwfm closed this as completed Dec 16, 2022
@plux
Copy link
Contributor

plux commented Dec 16, 2022

Don't close the issue, please reopen.
This is real and happens on Linux too.

My theory is that this is related to the face that rebar3 creates symlinks in _build to src directory which makes erlang_ls confused as there are two modules resolving to different Uris (one in src and one in _build).

Seems like the src document is updated when changes to the file happens, but completion will do a lookup of the module name and find the Uri of the _build file, which has not been re-indexed.

@lyfwfm
Copy link
Author

lyfwfm commented Dec 16, 2022

Don't close the issue, please reopen. This is real and happens on Linux too.

My theory is that this is related to the face that rebar3 creates symlinks in _build to src directory which makes erlang_ls confused as there are two modules resolving to different Uris (one in src and one in _build).

Seems like the src document is updated when changes to the file happens, but completion will do a lookup of the module name and find the Uri of the _build file, which has not been re-indexed.

sounds like that...

@lyfwfm lyfwfm reopened this Dec 16, 2022
@plux
Copy link
Contributor

plux commented Dec 16, 2022

I think the solution would either be to not index the _build symlink documents or make sure that those documents are also updated when a change is registed on the src document.

@lyfwfm
Copy link
Author

lyfwfm commented Dec 16, 2022

I think the solution would either be to not index the _build symlink documents or make sure that those documents are also updated when a change is registed on the src document.

yeah, maybe all(exclude deps) should index the src, and deps could index the _build, because deps not changes frequently

@misaki214
Copy link
Contributor

els_uri.erl
image
You can try this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants