lsp-dart icon indicating copy to clipboard operation
lsp-dart copied to clipboard

Can not jump to definition when current opened buffer was belong to a package. (but VSCode can)

Open zw963 opened this issue 3 years ago • 8 comments

this issue just copy from here

i fork flutter_sample project here, you can try reproduce on test_jump_to_definition branch.

Following is reproduce:

  1. switch to test_jump_to_definition branch
  2. open lib/main.dart, hover on Dashboard, as screenshot. image
  3. try jump to definition. (xref-find-definitions), it jump to lib/screens/dashboard/dashboard.dart, it works!
  4. hover on DesktopMultiWindow, try jump to def, it jump to ~/.pub-cache/hosted/pub.flutter-io.cn/desktop_multi_window-0.0.1/lib/desktop_multi_window.dart:11, it still works!
  5. at this time, lsp give me a selection. like following screenshot. image I select to set root directory interactively, that is, ~/.pub-cache/hosted/pub.flutter-io.cn/desktop_multi_window-0.0.1, i consider this is the correct option, right? please point out if this is not intended. from my point, if not set lsp root, there is no way to continue jump to next definition.
  6. hover on multiWindowChannel, jump to definition, it goto ~/.pub-cache/hosted/pub.flutter-io.cn/desktop_multi_window-0.0.1/lib/src/channels.dart, it seem like sitll works, though, as you can see, many flycheck error on this file.

image

  1. now my issue is coming. when hover on MethodChannel, it can't jump to definition. (but can when use VSCode) image

zw963 avatar Mar 16 '22 07:03 zw963

I can't repro this, but what I do is press n when lsp-mode asks about import that new package and works

ericdallo avatar Jun 11 '22 15:06 ericdallo

In fact, this issue same as #146 , those error not displayed if pressing n to not treat package root as LSP root, but it not jumpable as VSCode does.

as you mention in https://github.com/emacs-lsp/lsp-dart/issues/128#issuecomment-1068581681, VSCode must do some magic things which make jump to definition always happen even in package, maybe lsp-dart will work someday.

zw963 avatar Jun 12 '22 04:06 zw963

it does work for me with lsp-dart jumping to multiple packages, it could be some corner case we are not aware of yet

ericdallo avatar Jun 13 '22 14:06 ericdallo

it does work for me with lsp-dart jumping to multiple packages, it could be some corner case we are not aware of yet

Yes, it can jumping to packages, but, then, ipressing n when tips add package folder into lsp, then, when try do jump in package, it not works.

zw963 avatar Jun 14 '22 02:06 zw963

Yeah, I need to repro to understand why it happens, can you repro on the flutter sample repo?

ericdallo avatar Jun 14 '22 13:06 ericdallo

Yeah, I need to repro to understand why it happens, can you repro on the flutter sample repo?

No, it seem like in flutter_sample repo, there is no dart code use external package, so, there is no way to jump out to package?

zw963 avatar Jun 14 '22 18:06 zw963

Hum, I thought jumping to flutter internal is considered a external package

ericdallo avatar Jun 15 '22 14:06 ericdallo

Hum, I thought jumping to flutter internal is considered a external package

Sure no, haha, let us leave this issue for a moment, if i meet same issue again, i will do some research, and report here ASAP.

zw963 avatar Jun 15 '22 15:06 zw963

@zw963 I made a commit which should fix this: https://github.com/emacs-lsp/lsp-dart/commit/a8939d6784c033f97941908b067fa364ee2580a3 LMK if otherwise

ericdallo avatar Oct 31 '22 00:10 ericdallo

Cool, thanks, that will be a big improvement, i am not use dart recent days, i will test it later and give feedback.

zw963 avatar Oct 31 '22 03:10 zw963