Thanks for taking the time to look into this, and for your explanations!
Aha! I figured it wouldn't be too difficult to make this work because you've already got the documentation popups, and I thought the extension must be getting that info from this interface view, and it would be just a matter of opening that in a new tab. Now I know better...
Just out of curiosity I did a search for these files and found 456 of them under /Library/Developer/CommandLineTools/SDKs. swiftmodule
seems to be a container for one or more swiftinterface
+ swiftdoc
pairs.
Isn't the extension already having to find these files in order to show the documentation hover popups? Or is it embedded in the extension?
Didn't think about that, but yeah, the interface syntax is like a mix between protocols and regular Swift, so it needs its own grammar rules and all that.
To me, as a user of the extension, this would make sense. But perhaps that's just due to my previous experience with Xcode? Don't know how it is with other languages.
If I understand correctly, you're saying it would be somewhat like this:
- User clicks 'go to definition'.
- LSP figures out this comes from a pre-compiled framework and finds the relevant
swiftmodule
, swiftinterface
, swiftdoc
files.
- LSP generates the interface view.
- LSP finds the definition in the interface view.
- LSP responds saying "the definition is on line 400, column 20, in file xyz, but xyz doesn't yet exist, here I'll give it to you: «interface view»" or instead gives the path to a temporary file.
- VS Code opens the new file and goes to line 400, column 20.
But the way @stevapple described it, it sounds like it could also be like this:
- User clicks 'go to definition'.
- LSP figures out this comes from a pre-compiled framework and tells the extension which one it is.
- The extension finds the relevant files and generates the interface view.
- The extension opens the interface view in a new tab, as a temporary file.
- The extension then asks LSP for the definition again, but passes the interface view as new context.
- LSP finds the definition in the interface view and responds with the line number and column.
Either way seems like a lot of plumbing, and I have to admit, the payoff is not so big. Arguably my single motivating example could be solved some other way. Perhaps just adding the protocol name to the hover popup is feasible and would be, I imagine, a much simpler solution?
I'm not sure what you mean by this, but assuming you mean the 'opening a temporary file' aspect, then again, as a (Xcode) user, this technical inconsistency wouldn't be an issue to me.