erlang_ls icon indicating copy to clipboard operation
erlang_ls copied to clipboard

cannot code completion(or find definition)

Open lyfwfm opened this issue 2 years ago • 10 comments

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 avatar Nov 22 '22 05:11 lyfwfm

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 avatar Nov 22 '22 05:11 lyfwfm

appreciate to all of you for help!!!

lyfwfm avatar Nov 22 '22 05:11 lyfwfm

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

zylikedream avatar Dec 07 '22 02:12 zylikedream

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.

plux avatar Dec 16 '22 09:12 plux

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 avatar Dec 16 '22 09:12 lyfwfm

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.

plux avatar Dec 16 '22 09:12 plux

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 avatar Dec 16 '22 09:12 lyfwfm

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.

plux avatar Dec 16 '22 09:12 plux

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

lyfwfm avatar Dec 16 '22 10:12 lyfwfm

els_uri.erl image You can try this fix.

misaki214 avatar Dec 23 '22 01:12 misaki214