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

Files in sources jars with extra parent directories are not found #3815

Closed
arobertn opened this issue Apr 11, 2022 · 3 comments · Fixed by #5009 or #6066
Closed

Files in sources jars with extra parent directories are not found #3815

arobertn opened this issue Apr 11, 2022 · 3 comments · Fixed by #5009 or #6066
Assignees
Labels
bug Something that is making a piece of functionality unusable
Milestone

Comments

@arobertn
Copy link

Describe the bug

Issue description

When working with Scala in VS Code, Metals will download sources jars and support dereferencing classes from them in code files by the "Go to definition" context menu option. However if said source jars contain extra parent directories, e.g. source files are under src/main/java/com/... in the jar instead of com/... then this silently fails and you get "No definition found". The "Language Support for Java by Red Hat" on the other hand correctly finds the source files and allows dereferencing. The attached project demonstrates this for the bindings-rxjava and bindings-java jars which respectively have single and multiple buried roots.

Reproduction steps

  1. Set JAVA_HOME to a JDK-11 installation.
  2. Install Scala (Metals) and Language Support for Java by Red Hat
  3. Unpack the attached src-jar-test.zip and load the resulting src-jar-test directory into VS Code
  4. Wait for the project to import
  5. Open the "JarTest.java" file.
  6. Note that hovering or Ctrl/Cmd hovering over the classes DamlLedgerClient (single-buried-root) and TransactionFilter (multiple roots) results in Javadoc and/or source previews, and Ctrl/Cmd-clicking goes to the source.
  7. Open the "JarTest.scala" file.
  8. Note that Ctrl/Cmd hovering / clicking does NOT work in the Scala file, though it WILL work for the slf4j classes.

src-jar-test.zip

Expected behavior

I have not found anything in the Jar file specification specifically addressing this point, but in practice the Java plugins for VS Code and IntelliJ both find the sources despite the extra parent directories, and I expected Metals to do so as well.

Operating system

macOS

Editor/Extension

VS Code

Version of Metals

v0.11.2

Extra context or search terms

No response

@kpodsiad kpodsiad added the bug Something that is making a piece of functionality unusable label Apr 13, 2022
@zmerr zmerr self-assigned this Apr 20, 2022
@zmerr
Copy link
Contributor

zmerr commented Apr 20, 2022

It can be reproduced when JAVA_HOME is on Java 17 too.

@zmerr zmerr mentioned this issue Jul 5, 2022
dos65 added a commit to dos65/metals that referenced this issue Feb 23, 2023
Implements a lighter version of java parser for extracting toplevel
definitions as we do in Scala

Should fix scalameta#3815
dos65 added a commit to dos65/metals that referenced this issue Feb 23, 2023
Implements a lighter version of java parser for extracting toplevel
definitions as we do in Scala

Should fix scalameta#3815
dos65 added a commit to dos65/metals that referenced this issue Feb 23, 2023
Implements a lighter version of java parser for extracting toplevel
definitions as we do in Scala

Should fix scalameta#3815
dos65 added a commit to dos65/metals that referenced this issue Feb 24, 2023
Implements a lighter version of java parser for extracting toplevel
definitions as we do in Scala

Should fix scalameta#3815
dos65 added a commit to dos65/metals that referenced this issue Feb 24, 2023
Implements a lighter version of java parser for extracting toplevel
definitions as we do in Scala

Should fix scalameta#3815
tgodzik pushed a commit that referenced this issue Apr 17, 2023
Implements a lighter version of java parser for extracting toplevel
definitions as we do in Scala

Should fix #3815
@tgodzik tgodzik added this to the Metals v0.11.12 milestone Apr 17, 2023
@arobertn
Copy link
Author

Just a note, I'm still reproducing this with the project attached above with Metals 0.11.2 which should include #5009. (Java 11 and 18 tried.)

@tgodzik
Copy link
Contributor

tgodzik commented Apr 25, 2023

Just a note, I'm still reproducing this with the project attached above with Metals 0.11.2 which should include #5009. (Java 11 and 18 tried.)

We need to take another look then, thanks for letting us know!

@tgodzik tgodzik added this to Triage in Metals Issue Board via automation Apr 25, 2023
@kasiaMarek kasiaMarek self-assigned this Jan 31, 2024
@kasiaMarek kasiaMarek moved this from Triage to In progress in Metals Issue Board Jan 31, 2024
Metals Issue Board automation moved this from In progress to Done Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable
Projects
Archived in project
5 participants