Make haskell-language-server work with `NormalizedUri` instead of `NormalizedFilePath`
Currently, hls assumes that everything that it is working with are files. This is true even for the VFS.
This is a problem because it prevents hls to work with URIs like inmemory://, which would be useful when trying to deploy haskell-language-server on an online-playground-like webpage (as an example).
The interesting bit is that there are very few places where the knowledge that something is a filepath (vs an URI) is actually required, (probably) non-exhaustive list
-
FileExists.getFileExistsVFS(we need to load the file if the file is not part of the virtual file system) -
FileStore.addWatchedFileRule(we need to register file watchers, I think there should be an error here, if the uri is not a file) -
FileStore.getModificationTimeImpl(we need to get the last modified date of the file, we can just assume that the last modified date is the current time, or annotate this as an optional information) -
IdeConfiguration.isWorkspaceFile(we need to check if the path is relative, but I think that can be worked around by just assuming that an URI that is not a filepath is part of the workspace)
I know that changing NormalizedFilePath to NormalizedUri quickly is possible and I also know that it works, but I think that would leave HLS with a lot of kind of "ad hoc" logic where
- you check that the thing if that thing is a file
- you do something with the filepath
I think this is an option because it seems as if this is done quite a lot in Notifications with whenUriFile but maybe someone has an idea of how to create a better interface of "things that are only supported if the uri is a file"
Seems fine. If someone's willing to do the work I think we could do this!
I am going to work on this.