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

Library dependencies are not resolved #50

Closed
Kavantix opened this issue Jul 21, 2020 · 13 comments
Closed

Library dependencies are not resolved #50

Kavantix opened this issue Jul 21, 2020 · 13 comments

Comments

@Kavantix
Copy link
Collaborator

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

@iamcco
Copy link
Owner

iamcco commented Jul 22, 2020

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 iamcco closed this as completed in d828999 Jul 22, 2020
@Kavantix
Copy link
Collaborator Author

@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.

@iamcco
Copy link
Owner

iamcco commented Jul 22, 2020

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

@Kavantix
Copy link
Collaborator Author

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[]

@iamcco
Copy link
Owner

iamcco commented Jul 22, 2020

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

@iamcco
Copy link
Owner

iamcco commented Jul 22, 2020

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

@Kavantix
Copy link
Collaborator Author

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.

@iamcco
Copy link
Owner

iamcco commented Jul 22, 2020

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

@Kavantix
Copy link
Collaborator Author

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

@iamcco
Copy link
Owner

iamcco commented Jul 27, 2020

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

@PangPangPangPangPang
Copy link

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

1 similar comment
@wangzhaohe
Copy link

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

@wangzhaohe
Copy link

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.

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

4 participants