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

URI is not valid for textDocument/definition outside a package #660

Closed
non-Jedi opened this issue May 5, 2020 · 7 comments
Closed

URI is not valid for textDocument/definition outside a package #660

non-Jedi opened this issue May 5, 2020 · 7 comments
Assignees
Labels
Projects

Comments

@non-Jedi
Copy link
Member

non-Jedi commented May 5, 2020

A file URI is required to be absolute as far as I can tell. Even if it isn't, the language-server client doesn't know what directory to resolve a relative file URI to.

If you create a file main.jl:

include("utils.jl")

lang = to_upper("julia")

and utils.jl:

to_upper(x) = uppercase(x)

And request textDocument/definition of to_upper from within main.jl, the URI is given as "file://utils.jl" instead of the full path that it should be:

client-request (id:62) Tue May  5 08:00:46 2020:
(:jsonrpc "2.0" :id 62 :method "textDocument/definition" :params
          (:textDocument
           (:uri "file:///home/adam/tmp/main.jl")
           :position
           (:line 2 :character 10)))

server-reply (id:62) Tue May  5 08:00:46 2020:
(:id 62 :jsonrpc "2.0" :result
     [(:uri "file://utils.jl" :range
            (:start
             (:line 0 :character 0)
             :end
             (:line 2 :character 3)))])

Thanks to @prasannakog for the reproducer at gdkrmr/lsp-julia#25 (comment)

@ZacLN
Copy link
Contributor

ZacLN commented May 5, 2020

Hiya, a couple questions to help me understand this.

  • Could you elaborate a bit on what you mean by 'works inside a package' on the downstream issue?
  • Are these files saved (in the sense of having sent a didSave notification to the server? And if so are both files saved with a full URI?

@non-Jedi
Copy link
Member Author

non-Jedi commented May 5, 2020

  • If main.jl is instead Main.jl inside the src directory of a package (and the contents are wrapped in module Main), the full URI is given for utils.jl e.g. /home/adam/tmp/Main/src/utils.jl. The difference might have to do with the fact that the environment path passed to LanguageServerInstance is the path to the default environment when outside a package (different than rootPath/rootURI sent during initialize)?
  • Behavior is the same whether or not a didSave notification has been sent. When a didSave notification is sent, it includes the full URI:
client-notification Tue May  5 10:29:26 2020:
(:jsonrpc "2.0" :method "textDocument/didSave" :params
          (:text "to_upper(x) = uppercase(x)\n\n" :textDocument
                 (:uri "file:///home/adam/tmp/utils.jl")))

@ZacLN
Copy link
Contributor

ZacLN commented May 7, 2020

As per the other issue, could you send me some logs from initialization through to the problem (maybe as a gist?)

@non-Jedi
Copy link
Member Author

non-Jedi commented May 7, 2020

Here you go: https://gist.github.com/non-Jedi/fd8c9f5e31f9cac9e47d7a81d142a4b8

Thanks for taking a look. :)

@ZacLN ZacLN closed this as completed May 30, 2020
Current automation moved this from To do to Done May 30, 2020
@non-Jedi
Copy link
Member Author

Per report on discourse this is still a problem on master. I haven't personally replicated it though.

@non-Jedi non-Jedi reopened this Jul 23, 2020
Current automation moved this from Done to In progress Jul 23, 2020
@ffevotte
Copy link
Contributor

Ah, sorry, it looks like I have been too careless when doing tests: I can now confirm that this issue is indeed fixed.

I'm very sorry for the noise.

Current automation moved this from In progress to Done Jul 23, 2020
@pfitzseb
Copy link
Member

Thanks for reporting back! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Current
  
Done
Development

No branches or pull requests

5 participants