dragos-vscode-scala
dragos-vscode-scala copied to clipboard
How hard to implement goto symbol?
In vscode, you can command+t to do fuzzy find based on symbol and it uses the same functionality as goto definition. How hard would this be to implement?
I think Ensime offers similar functionality (though, it needs an index if this is supposed to work at the workspace level as opposed to in-file only). If that's the case, it's not too hard:
- identify the Ensime API to call
- check and add if needed the language server protocol message/request types
- implement the message/request parts
It would make for a great contribution. :)
According to the readme there is a feature
goto definition (F12 and CMD-F12)
Is this already implemented?
Yes, go to symbol is already implemented. It's different from what the OP is asking, though: it works if you have the identifier in a source file that doesn't have errors (or at least, that particular identifier can be correctly resolved). Then, you can ctrl-click or press F12.
To to a global search in the whole project/classpath you'd need a lot more (if you're wondering why it's harder, it's because in the source-file the compiler already has the imports where that symbol is coming from).
Okay, I'd like to help out on this. Guess I'll start reading the VS Code documentation on implementing a LS to get a hang of this. If you have other suggestions what I should check out let me know.
I think the best way to start is:
- look at the existing code for go to symbol. (it delegates to Ensime)
- check in the Ensime codebase how they implement workspace wide search. I think this is the request to make
- hook up the LSP parts, see what messages are exchanged by following working examples in this project, perhaps all case classes are already available
PS. Thanks a lot for picking up this ticket!
I am a bit confused. The API call you mentioned isn't available in the 3.0 or 2.0 branch, right? So its also not available in the version specified in the dependencies. If you wouldn't send the link to the specific tree I wouldn't have found it.
You're right, I had an old checkout of the 2.0 branch, but this call was removed soon after. I'm not sure what's the current way to query this functionality, maybe @fommil could give us a hint?
In general, since the emacs client is the most complete ensime client, it's the place to look for API use examples.