Skip to content

Commit 84fdb07

Browse files
committed
Export getFileContents rule definition
1 parent 77c4462 commit 84fdb07

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

ghcide/src/Development/IDE/Core/FileStore.hs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Development.IDE.Core.FileStore(
1919
resetInterfaceStore,
2020
getModificationTimeImpl,
2121
addIdeGlobal,
22-
getFileContentsRule,
22+
getFileContentsImpl
2323
) where
2424

2525
import Control.Concurrent.Extra
@@ -71,6 +71,7 @@ import Language.LSP.Server hiding
7171
import qualified Language.LSP.Server as LSP
7272
import Language.LSP.Types (FileChangeType (FcChanged),
7373
FileEvent (FileEvent),
74+
NormalizedFilePath (NormalizedFilePath),
7475
toNormalizedFilePath,
7576
uriToFilePath)
7677
import Language.LSP.VFS
@@ -209,16 +210,21 @@ internalTimeToUTCTime large small =
209210
#endif
210211

211212
getFileContentsRule :: VFSHandle -> Rules ()
212-
getFileContentsRule vfs =
213-
define $ \GetFileContents file -> do
214-
-- need to depend on modification time to introduce a dependency with Cutoff
215-
time <- use_ GetModificationTime file
216-
res <- liftIO $ ideTryIOException file $ do
217-
mbVirtual <- getVirtualFile vfs $ filePathToUri' file
218-
pure $ Rope.toText . _text <$> mbVirtual
219-
case res of
220-
Left err -> return ([err], Nothing)
221-
Right contents -> return ([], Just (time, contents))
213+
getFileContentsRule vfs = define $ \GetFileContents file -> getFileContentsImpl vfs file
214+
215+
getFileContentsImpl
216+
:: VFSHandle
217+
-> NormalizedFilePath
218+
-> Action ([FileDiagnostic], Maybe (FileVersion, Maybe T.Text))
219+
getFileContentsImpl vfs file = do
220+
-- need to depend on modification time to introduce a dependency with Cutoff
221+
time <- use_ GetModificationTime file
222+
res <- liftIO $ ideTryIOException file $ do
223+
mbVirtual <- getVirtualFile vfs $ filePathToUri' file
224+
pure $ Rope.toText . _text <$> mbVirtual
225+
case res of
226+
Left err -> return ([err], Nothing)
227+
Right contents -> return ([], Just (time, contents))
222228

223229
ideTryIOException :: NormalizedFilePath -> IO a -> IO (Either FileDiagnostic a)
224230
ideTryIOException fp act =

0 commit comments

Comments
 (0)