@@ -18,7 +18,7 @@ module Development.IDE.Core.FileStore(
18
18
resetFileStore ,
19
19
getModificationTimeImpl ,
20
20
addIdeGlobal ,
21
- getFileContentsRule ,
21
+ getFileContentsImpl
22
22
) where
23
23
24
24
import Control.Concurrent.Extra
@@ -70,6 +70,7 @@ import Language.LSP.Server hiding
70
70
import qualified Language.LSP.Server as LSP
71
71
import Language.LSP.Types (FileChangeType (FcChanged ),
72
72
FileEvent (FileEvent ),
73
+ NormalizedFilePath (NormalizedFilePath ),
73
74
toNormalizedFilePath ,
74
75
uriToFilePath )
75
76
import Language.LSP.VFS
@@ -195,16 +196,21 @@ internalTimeToUTCTime large small =
195
196
#endif
196
197
197
198
getFileContentsRule :: VFSHandle -> Rules ()
198
- getFileContentsRule vfs =
199
- define $ \ GetFileContents file -> do
200
- -- need to depend on modification time to introduce a dependency with Cutoff
201
- time <- use_ GetModificationTime file
202
- res <- liftIO $ ideTryIOException file $ do
203
- mbVirtual <- getVirtualFile vfs $ filePathToUri' file
204
- pure $ Rope. toText . _text <$> mbVirtual
205
- case res of
206
- Left err -> return ([err], Nothing )
207
- Right contents -> return ([] , Just (time, contents))
199
+ getFileContentsRule vfs = define $ \ GetFileContents file -> getFileContentsImpl vfs file
200
+
201
+ getFileContentsImpl
202
+ :: VFSHandle
203
+ -> NormalizedFilePath
204
+ -> Action ([FileDiagnostic ], Maybe (FileVersion , Maybe T. Text ))
205
+ getFileContentsImpl vfs file = do
206
+ -- need to depend on modification time to introduce a dependency with Cutoff
207
+ time <- use_ GetModificationTime file
208
+ res <- liftIO $ ideTryIOException file $ do
209
+ mbVirtual <- getVirtualFile vfs $ filePathToUri' file
210
+ pure $ Rope. toText . _text <$> mbVirtual
211
+ case res of
212
+ Left err -> return ([err], Nothing )
213
+ Right contents -> return ([] , Just (time, contents))
208
214
209
215
ideTryIOException :: NormalizedFilePath -> IO a -> IO (Either FileDiagnostic a )
210
216
ideTryIOException fp act =
0 commit comments