iamcco/coc-flutter

Library dependencies are not resolved

Kavantix opened this issue · 13 comments

Describe the bug
Dependencies are not resolved when looking at library code.
This fills up the diagnostics list every time one takes a look at the implementation of some Flutter widget for example.

To Reproduce
Steps to reproduce the behavior:

  1. Go to any of your dart projects.
  2. Go to the definition of some class of a library
  3. Notice that all non relative dependencies are marked as errors

Expected behavior
It should be able to resolve these dependencies
Using the LSP in VSCode this works just fine

Desktop (please complete the following information):

  • OS: MacOs 10.15.4
  • Vim or Neovim: Neovim
  • (Neo)vim version: 0.4.3

Output channel:

  1. Set "flutter.trace.server": "verbose"
  2. Reproduce the issue
  3. :CocList output open output list and select flutter

Log:
When trying to open the output of the log vim freezes

It's because coc.nvim will add workspace change when go to the sdk directory, and there's no .dart_tool info of that package. I will fix it do not send workspace change when go to sdk directory.

@iamcco thanks for the quick response.
This seems to fix the cases when looking at code in the sdk.
However, other libraries still show the same behaviour.

Use "flutter.workspaceFolder.ignore": [] options.

Can you give me an example of how to use it for a package in the .pub_cache folder.
Already tried a lot of possibilities but non work.

Also, the option gives a warning that it expects type string instead of string[]

"flutter.workspaceFolder.ignore": ["~/xxx/xxx"] path start with ~/xxx/xxx will not change workspace folder.

Also you can improve it if you have any good idea.

If I understand correctly then the default should actually work for me since the default ignored path ends up being .../flutter since the flutter binary is at .../flutter/bin/flutter and the pubcache folder which holds all dependencies is at .../flutter/.pub_cache`

However, its still not finding those dependencies so I'm not sure that changing workspace folder is what is causing this issue although at least now files in the sdk don't have errors all over

Don't have any ideas looking at the code how to fix it atm.

Dart LSP use project .dart_tool packages info to resolve dependence, so if your lib package do not run flutter packages get it will not have the dependence info. so if goto lib file and coc.nvim change workspace to lib directory it can't resolve dependence. if your lib is in flutter sdk directory, it should not have the problem. i don't know what happend.

debug at https://github.com/iamcco/coc-flutter/blob/master/src/server/lsp/index.ts#L97

Running pub get in the package's directory indeed resolves this.
Would there be any way we could automatically do this?

It is also still interesting that the vscode extensions does not need to do this even when running it using the LSP

I don't have the issue, you can debug with above response.

Encountered exactly the same problem. And SDK directory still show errors.

Encountered exactly the same problem. And SDK directory still show errors.

Running pub get in the package's directory indeed resolves this. Would there be any way we could automatically do this?

It is also still interesting that the vscode extensions does not need to do this even when running it using the LSP

I open a new issue, then I found the discuss here.

#150 (comment)

Would you teach me how to solve this problem? Wish your help, thanks.

Now I make a link to .dart_tool, but there are many 3rd libs. So I think it is not a good method.