Skip to content

Commit 25761b0

Browse files
committed
Export getFileContents rule definition
1 parent 36fdc17 commit 25761b0

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
@@ -18,7 +18,7 @@ module Development.IDE.Core.FileStore(
1818
resetFileStore,
1919
getModificationTimeImpl,
2020
addIdeGlobal,
21-
getFileContentsRule,
21+
getFileContentsImpl
2222
) where
2323

2424
import Control.Concurrent.Extra
@@ -70,6 +70,7 @@ import Language.LSP.Server hiding
7070
import qualified Language.LSP.Server as LSP
7171
import Language.LSP.Types (FileChangeType (FcChanged),
7272
FileEvent (FileEvent),
73+
NormalizedFilePath (NormalizedFilePath),
7374
toNormalizedFilePath,
7475
uriToFilePath)
7576
import Language.LSP.VFS
@@ -195,16 +196,21 @@ internalTimeToUTCTime large small =
195196
#endif
196197

197198
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))
208214

209215
ideTryIOException :: NormalizedFilePath -> IO a -> IO (Either FileDiagnostic a)
210216
ideTryIOException fp act =

0 commit comments

Comments
 (0)