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

Figure out how to jump to files in zip/jar/.class files #36

Closed
olafurpg opened this issue Nov 14, 2017 · 10 comments
Closed

Figure out how to jump to files in zip/jar/.class files #36

olafurpg opened this issue Nov 14, 2017 · 10 comments
Labels
navigation Related to goto definition, find references, open symbol

Comments

@olafurpg
Copy link
Member

See comment from @gabro https://github.com/scalameta/language-server/pull/23/files#r150784897

Just as a comparison, the Java LSP jumps to a .class file containing the source.
I'm not sure I understand the implementation, but here's the relevant bit https://github.com/eclipse/eclipse.jdt.ls/blob/2127f12fb3700dd783b75d973e4f2ecc134b9ddf/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/NavigateToDefinitionHandler.java#L52

olafurpg added a commit to olafurpg/metals that referenced this issue Nov 19, 2017
This is the best we got until scalameta#36 gets fixed. I had to adapt the
implementation to accommodate the new URI based indexing scheme.
@olafurpg
Copy link
Member Author

olafurpg commented Nov 20, 2017

It seems eclipse.jdt.ls returns URIs with the jdt scheme https://github.com/eclipse/eclipse.jdt.ls/blob/2127f12fb3700dd783b75d973e4f2ecc134b9ddf/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JDTUtils.java#L376

In editors like vscode it's possible to register a text content provider for a particular URI scheme, we use this in metadoc scalameta.org/metadoc/ for "semanticdb". But this functionality is not part of vscode LSP as far as I know.

@laughedelic
Copy link
Member

laughedelic commented Nov 21, 2017

I'm going to check how it works in Atom with the Java LSP plugin. And I'm not if it's related or not, but there is this: http://flight-manual.atom.io/hacking-atom/sections/handling-uris

@gabro
Copy link
Member

gabro commented Nov 21, 2017

But this functionality is not part of vscode as far as I know.

You mean LSP?

@olafurpg
Copy link
Member Author

Yes @gabro ! I meant LSP.

@laughedelic
Copy link
Member

Related: atom/ide-java#42. It just doesn't work now in Atom.

@olafurpg
Copy link
Member Author

We can have different implementations to handle sources in the classpath depending on the capabilities of the editor. The fallback implementation can use the current hack we have in master.

@laughedelic
Copy link
Member

Crosslinking, so that you can vote it up: microsoft/language-server-protocol#335

@olafurpg
Copy link
Member Author

olafurpg commented Jan 7, 2018

Seems like the relevant part of the vscode api is https://code.visualstudio.com/docs/extensionAPI/vscode-api#workspace.registerTextDocumentContentProvider where we can register a provider for the "semanticdb" URI scheme.

@olafurpg
Copy link
Member Author

VS Code 1.25.0 had updates on "Readonly file system provider" https://code.visualstudio.com/updates/v1_25#_readonly-file-system-provider

@olafurpg olafurpg added navigation Related to goto definition, find references, open symbol and removed good first issue labels Sep 26, 2018
@olafurpg
Copy link
Member Author

Fixed in #337. I ended up with writing to files on disk instead of the text content provider system in VS Code with the reasoning being that files work with all clients, not only VS Code.

I actually got the VS Code text content provider working but that opened a can of worms by having to handle metals:// URIs.

Files are written in the .metals/readonly/ directory and preserve the full path from the zip file: .metals/readonly/scala/Predef.scala. The files are marked as read-only (not writable) on macOS/Linux so that users get an error if they try to edit the dependency sources. On Windows I hit on many problems using readonly files (AccessDeniedException from just walking the file tree, not even readon) so I gave up and kept the files writable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
navigation Related to goto definition, find references, open symbol
Projects
None yet
Development

No branches or pull requests

3 participants