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

Investigate generating module interface from .swiftinterface and .swiftdoc files #408

Closed
adam-fowler opened this issue Sep 6, 2022 · 3 comments

Comments

@adam-fowler
Copy link
Member

For jump to definition of symbols in stdlib or Foundation sourcekit-lsp returns a .swiftinterface file. We should look into generating a user readable swift interface from the .swiftinterface file and it's related .swiftdoc file.

@adam-fowler
Copy link
Member Author

It seems sourcekitd has a request which will return the generated interface for a swift module from a .swiftmodule folder. Below is a possible route to implementing jump to interface

Before we start we should setup a textDocumentProvider for scheme "swiftmodule". This will send a custom request to SK-LSP to return a module interface based on the swiftmodule path sent to it and use the response as the documents contents.

  1. Go to definition request is sent to SK-LSP
  2. SK-LSP generates module interface text, works out position in generated text for definition and caches the text for later use.
  3. SK-LSP returns swiftmodule path and position inside module interface text in response
  4. VSCode Language client has middleware which catches this response and edits the file name to use scheme "swiftmodule"
  5. Now we are using "swiftmodule" scheme the textDocumentProvider created above will trigger and send request to SK-LSP for the module interface
  6. Given we have cached the module interface earlier in stage 2 this should be a simple returning the contents of the cache.

@ahoppen
Copy link

ahoppen commented Oct 17, 2022

That sounds like good scheme to me. 👍

@adam-fowler
Copy link
Member Author

This is now merged in sourcekit-lsp apple/sourcekit-lsp#747
And vscode support is done here #538

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants