This PR introduces two new interfaces to aid with accessing configuration in any "abstract" filesystem, such as in-memory FS which is used by the language server. In LSP the server should not read files from disk if there is copy in memory (as sent by the client).
I created interfaces pretty much identical to the ones recently published in the Go proposal for io/fs. We don't actually need Open nor File, but I believe that adding later anything to an interface is going to be much harder than removing anything. Also assuming that the proposal goes ahead and is implemented like this, it should be fairly easy to just swap the argument types for the stdlib ones and add type aliases.
Two new functions which use this new interface were also introduced:
LoadModuleFromFilesystem(fs FS, dir string) (*Module, Diagnostics)
similar to LoadModule(dir string) (*Module, Diagnostics)
IsModuleDirOnFilesystem(fs FS, dir string) bool
similar to IsModuleDir(dir string) bool
Backwards Compatibility for Existing Consumers
The existing interfaces should work the same as before.
Summary
This PR introduces two new interfaces to aid with accessing configuration in any "abstract" filesystem, such as in-memory FS which is used by the language server. In LSP the server should not read files from disk if there is copy in memory (as sent by the client).
I created interfaces pretty much identical to the ones recently published in the Go proposal for
io/fs
. We don't actually needOpen
norFile
, but I believe that adding later anything to an interface is going to be much harder than removing anything. Also assuming that the proposal goes ahead and is implemented like this, it should be fairly easy to just swap the argument types for the stdlib ones and add type aliases.Two new functions which use this new interface were also introduced:
LoadModuleFromFilesystem(fs FS, dir string) (*Module, Diagnostics)
LoadModule(dir string) (*Module, Diagnostics)
IsModuleDirOnFilesystem(fs FS, dir string) bool
IsModuleDir(dir string) bool
Backwards Compatibility for Existing Consumers
The existing interfaces should work the same as before.