@@ -21,7 +21,6 @@ module Development.IDE.Core.Compile
21
21
, generateByteCode
22
22
, generateHieAsts
23
23
, writeAndIndexHieFile
24
- , HieDbModuleQuery (.. )
25
24
, indexHieFile
26
25
, writeHiFile
27
26
, getModSummaryFromImports
@@ -860,10 +859,6 @@ spliceExpressions Splices{..} =
860
859
, DL. fromList $ map fst awSplices
861
860
]
862
861
863
- data HieDbModuleQuery
864
- = HieDbModuleQuery ModuleName Unit
865
- | DontCheckForModule
866
-
867
862
-- | In addition to indexing the `.hie` file, this function is responsible for
868
863
-- maintaining the 'IndexQueue' state and notifying the user about indexing
869
864
-- progress.
@@ -892,14 +887,16 @@ data HieDbModuleQuery
892
887
-- TVar to 0 in order to set it up for a fresh indexing session. Otherwise, we
893
888
-- can just increment the 'indexCompleted' TVar and exit.
894
889
--
895
- indexHieFile :: ShakeExtras -> HieDbModuleQuery -> NormalizedFilePath -> HieDb. SourceFile -> Util. Fingerprint -> Compat. HieFile -> IO ()
896
- indexHieFile se query hiePath sourceFile ! hash hf = do
890
+ indexHieFile :: ShakeExtras -> NormalizedFilePath -> HieDb. SourceFile -> Util. Fingerprint -> Compat. HieFile -> IO ()
891
+ indexHieFile se hiePath sourceFile ! hash hf = do
897
892
IdeOptions {optProgressStyle} <- getIdeOptionsIO se
898
893
atomically $ do
899
894
pending <- readTVar indexPending
900
895
case HashMap. lookup hiePath pending of
901
896
Just pendingHash | pendingHash == hash -> pure () -- An index is already scheduled
902
897
_ -> do
898
+ -- hiedb doesn't use the Haskell src, so we clear it to avoid unnecessarily keeping it around
899
+ let ! hf' = hf{hie_hs_src = mempty }
903
900
modifyTVar' indexPending $ HashMap. insert hiePath hash
904
901
writeTQueue indexQueue $ \ withHieDb -> do
905
902
-- We are now in the worker thread
@@ -914,24 +911,8 @@ indexHieFile se query hiePath sourceFile !hash hf = do
914
911
-- Using bracket, so even if an exception happen during withHieDb call,
915
912
-- the `post` (which clean the progress indicator) will still be called.
916
913
bracket_ (pre optProgressStyle) post $
917
- withHieDb indexIfNotAlready
914
+ withHieDb ( \ db -> HieDb. addRefsFromLoaded db (fromNormalizedFilePath hiePath) sourceFile hash hf')
918
915
where
919
- -- hiedb doesn't use the Haskell src, so we clear it to avoid unnecessarily keeping it around
920
- hf' :: Compat. HieFile
921
- ! hf' = hf{hie_hs_src = mempty }
922
- indexIfNotAlready :: HieDb -> IO ()
923
- indexIfNotAlready db = case query of
924
- DontCheckForModule -> doIndexing
925
- HieDbModuleQuery moduleName unit -> do
926
- mRow <- HieDb. lookupHieFile db moduleName unit
927
- case mRow of
928
- Nothing -> doIndexing
929
- Just _row -> return ()
930
- where
931
- doIndexing :: IO ()
932
- doIndexing =
933
- HieDb. addRefsFromLoaded db (fromNormalizedFilePath hiePath) sourceFile hash hf'
934
-
935
916
HieDbWriter {.. } = hiedbWriter se
936
917
937
918
-- Get a progress token to report progress and update it for the current file
@@ -1024,7 +1005,7 @@ writeAndIndexHieFile hscEnv se mod_summary srcPath exports ast source =
1024
1005
GHC. mkHieFile' mod_summary exports ast source
1025
1006
atomicFileWrite se targetPath $ flip GHC. writeHieFile hf
1026
1007
hash <- Util. getFileHash targetPath
1027
- indexHieFile se DontCheckForModule (toNormalizedFilePath' targetPath) (HieDb. RealFile $ fromNormalizedFilePath srcPath) hash hf
1008
+ indexHieFile se (toNormalizedFilePath' targetPath) (HieDb. RealFile $ fromNormalizedFilePath srcPath) hash hf
1028
1009
where
1029
1010
dflags = hsc_dflags hscEnv
1030
1011
mod_location = ms_location mod_summary
0 commit comments