haskell-language-server/plugins/hls-splice-plugin
awjchen 7385915c99
Get files from Shake VFS from within plugin handlers (#4328)
* Change return type of getFileContents from Text to Rope

- This avoids a few conversions between Rope and Text in the next commit
- Note: Syntactic changes to Development.IDE.Plugin.CodeAction around line
  2000 are to work around the following stylish-haskell failure:

plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs: <string>:2002:5:
error: [GHC-58481]
    parse error (possibly incorrect indentation or mismatched brackets)

* Get virtual files from the Shake VFS in plugins

This commit changes plugins to get virtual files from the Shake VFS
rather than from the language server's VFS.

- Replace `Ide.Types.pluginGetVirtualFile` with
  `Development.IDE.Core.FileStore.getFileContents`
- Replace `Ide.Types.pluginGetVersionedTextDoc` with
  `Development.IDE.Core.FileStore.getVersionedTextDoc`

* Rename `getFileContents` to `getFileModTimeContents`

* Add util functions for common cases of Shake VFS file access

* Cleanup

* Fix warning

* Install notification handlers for cabal files

The cabal formatters read the file contents from the shake VFS. Thus, we
need to make sure there are notification handlers that add the cabal
files to the VFS!

Formatters have to depend on the `hls-cabal-plugin` to have the
necessary notification handlers installed during test time.

---------

Co-authored-by: soulomoon <fwy996602672@gmail.com>
Co-authored-by: Michael Peyton Jones <me@michaelpj.com>
Co-authored-by: Fendor <fendor@posteo.de>
Co-authored-by: fendor <fendor@users.noreply.github.com>
2024-09-28 14:23:35 +02:00
..
src/Ide/Plugin Get files from Shake VFS from within plugin handlers (#4328) 2024-09-28 14:23:35 +02:00
test Refactor hls-test-util and reduce getCurrentDirectory after initilization (#4231) 2024-05-27 14:03:43 +00:00