Replies: 3 comments 7 replies
-
This is an interesting question; its going to involve teaching sourcekit-lsp about the contents of the virtual editor since that is what powers symbol resolution. The extension, and sourcekit-lsp, already work with these virtual files when doing macro expansions. These virtual documents have the scheme |
Beta Was this translation helpful? Give feedback.
-
From SourceKit-LSP’s perspective, the problem is that it needs to get compiler arguments that would be used to build the file so it can provide semantic functionality. The basic information here would include which target the source file is part of but there’s a whole rabbit tail of other options ( The best option I could suggest to get functionality within the files, is that there could be a special URL scheme to open the virtual file and pass a file on disk that should be used to get the compiler arguments – ie. you essentially tell SourceKit-LSP to treat the virtual file as being equivalent to that file within the package. Would that seem feasible to you? Now, with this, you still wouldn’t be able to navigate from files on disk to the virtual file because the files on disk don’t know anything about the virtual file. We also wouldn’t be able to run background indexing for the virtual file because that highly relies on files on disk. Because of this, functionality that needs a global understanding of your project like find call hierarchy won’t be able to show entries from your virtual file. This would be similar to the behavior that you get if you open standalone Swift files (without a package) at the moment. Not sure what your application is, and if those trade-offs are acceptable. Also: What exactly are you trying to accomplish with the virtual files? That might make it easier to understand your use case. |
Beta Was this translation helpful? Give feedback.
-
I don't really have anything to add to what @ahoppen said, he summed it up well. The custom url scheme for the virtual documents were designed to be very flexible. Even for macro expansions, we use the files on disk to derive the compiler arguments, which then allowed us to get semantic functionality in the virtual documents. Virtual documents are not the same as Files on Disk so expect some trade-offs to be made. And, I'm curious about your use case as well. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a use-case in which I create virtual VSCode editors. That mostly means that they don't have a regular
.fsPath
on theirvscode.Uri
and that they're scheme is notfile://
. I want to be able to do Jump to Definition of types that appear in my virtual editor to types that are defined as Swift files on my local machine, say/path/to/swift/package
.In order to do that, I've thought of a couple of ways.
vscode-swift
thinks it's part of that package and resolves types accordingly.Swift.Decoder
) types are resolved even though they're outside of the package.What's the simplest way to solve this? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions