haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.64k stars 354 forks source link

Clarify how HLS is supposed to access information about files #3739

Open michaelpj opened 1 year ago

michaelpj commented 1 year ago

At the moment it's a little unclear how HLS (rules, plugin handlers, everything really) is supposed to access information about files.

We have two possible sources of information:

Where do we look? What do we do if something is not in the VFS?

After some discussion on IRC, @fendor and I came to the following conclusion:

See also the prose in the spec: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_didOpen

However, at the moment, we are most often using e.g. getFileContents, which only reads from the VFS. That might be fine (it avoids doing filesystem IO, which might be desirable), but it should be very obvious. There is a function that falls back to the filesystem, the confusingly named getSourceFileSource, but it's not as widely used.

We should clarify the situation and try to make things more consistent.

michaelpj commented 1 year ago

Might also be a good candidate for a hlint warning.