scalameta / metals

Scala language server with rich IDE features šŸš€
https://scalameta.org/metals/
Apache License 2.0
2.06k stars 320 forks source link

Invalid scaladoc links in hover response #3383

Open ayoub-benali opened 2 years ago

ayoub-benali commented 2 years ago

Describe the bug The hover response contains invalid scaladoc links

To Reproduce

  1. Hover over the String type
  2. Click on the scala.collection.immutable.StringOps link
  3. Browser opens up with an invalid url

Bellow is the LSP log

:: --> metals textDocument/hover(8): {'textDocument': {'uri': 'file:///home/ayoub/workspace/test-project/src/main/scala/example/Hello.scala'}, 'position': {'line': 3, 'character': 26}}
:: <<< metals 8: {'range': {'start': {'line': 3, 'character': 23}, 'end': {'line': 3, 'character': 29}}, 'contents': {'kind': 'markdown', 'value': '```scala\ntype String: String\n```\nThe `String` type in Scala has methods that come either from the underlying\n Java String (see the documentation corresponding to your Java version, for\n example [http://docs.oracle.com/javase/8/docs/api/java/lang/String.html](http://docs.oracle.com/javase/8/docs/api/java/lang/String.html)) or\n are added implicitly through [scala.collection.immutable.StringOps](scala.collection.immutable.StringOps).'}}

Expected behavior This kind of scaladoc links should probably be rewritten by metals and be replace by a goto-position command. Ultimately the link should trigger a valid action.

Installation:

Search terms hover, scaladoc

tgodzik commented 2 years ago

Thanks for reporting! What is the invalid link that this opens?

ayoub-benali commented 2 years ago

scala.collection.immutable.StringOps is the invalid link as you can see it in the hover response above

tgodzik commented 2 years ago

scala.collection.immutable.StringOps is the invalid link as you can see it in the hover response above

Ach, right! I looked at the other link in the response.

kpodsiad commented 2 years ago

(note) It'll be easier to do this after https://github.com/scalameta/metals/pull/3378 is merged.

SoTeKie commented 1 year ago

Is there any way we could potentially get the needle moving on this? I just moved from a jetbrains setup to vscode+metals recently and if I'm understanding things correctly most of the documentation linking I have in my project is broken related to this issue šŸ˜…

I'm sadly not well-versed in the project so this wouldn't exactly be a quickfix with my skillset, but I can take this issue if there are no plans for this to be taken otherwise.

tgodzik commented 1 year ago

I talk a quick look into that and got something working in https://github.com/scalameta/metals/pull/4813

However, I am not super happy about the solution with relative links, which might break at times. I will check if there are better solutions for it.

tgodzik commented 1 year ago

I worked a bit on this in https://github.com/tgodzik/metals/commit/7bebb91e5c5fe4936d7adaafbb00b8e7415bb735

I might get back to it at some point, but as it stands if anyone else wants to take a look that's would be cool.

Dessix commented 2 months ago

This issue is still present in current Metals versions, and still leads to "Unable to open " errors even when interacting with official types in Predef.scala, such as the links in the tooltip for String, which end up linking to scala.collection.StringOps instead of documentation on (or navigation to) the type. While this issue was not closed or claimed to be resolved, I wanted to make sure that the keywords I began by searching for would also lead here.

After searching for documentation covering this as the "correct" way to link types in Scaladoc, I found that it's described in the Scaladoc3 guide.