Skip to content

Commit ea002d7

Browse files
committed
distribute errors to all pending files are being loading
1 parent 58b8b68 commit ea002d7

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ loadSessionWithOptions :: Recorder (WithPriority Log) -> SessionLoadingOptions -
425425
loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
426426
let toAbsolutePath = toAbsolute rootDir -- see Note [Root Directory]
427427
cradle_files <- newIORef (Set.fromList [])
428+
-- error_loading_files <- newIORef (Set.fromList [])
428429
-- Mapping from hie.yaml file to HscEnv, one per hie.yaml file
429430
hscEnvs <- newVar Map.empty :: IO (Var HieMap)
430431
-- Mapping from a Filepath to HscEnv
@@ -606,6 +607,15 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
606607

607608
return $ (second Map.keys this_options, Set.fromList $ fromNormalizedFilePath <$> newLoaded)
608609

610+
let makeError hieYaml cradle err cfp = do
611+
dep_info <- getDependencyInfo (maybeToList hieYaml)
612+
let ncfp = toNormalizedFilePath' cfp
613+
let res = (map (\err' -> renderCradleError err' cradle ncfp) err, Nothing)
614+
void $ modifyVar' fileToFlags $
615+
Map.insertWith HM.union hieYaml (HM.singleton ncfp (res, dep_info))
616+
void $ modifyVar' filesMap $ HM.insert ncfp hieYaml
617+
return (fst res)
618+
609619
let consultCradle :: Maybe FilePath -> FilePath -> IO (IdeResult HscEnvEq, [FilePath])
610620
consultCradle hieYaml cfp = do
611621
let lfpLog = makeRelative rootDir cfp
@@ -648,13 +658,8 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
648658
| otherwise -> return (([renderPackageSetupException cfp GhcVersionMismatch{..}], Nothing),[])
649659
-- Failure case, either a cradle error or the none cradle
650660
Left err -> do
651-
dep_info <- getDependencyInfo (maybeToList hieYaml)
652-
let ncfp = toNormalizedFilePath' cfp
653-
let res = (map (\err' -> renderCradleError err' cradle ncfp) err, Nothing)
654-
void $ modifyVar' fileToFlags $
655-
Map.insertWith HM.union hieYaml (HM.singleton ncfp (res, dep_info))
656-
void $ modifyVar' filesMap $ HM.insert ncfp hieYaml
657-
return (res, maybe [] pure hieYaml ++ concatMap cradleErrorDependencies err)
661+
errors <- mapM (makeError hieYaml cradle err) $ Set.toList pendingFiles
662+
return ((concat errors, Nothing), maybe [] pure hieYaml ++ concatMap cradleErrorDependencies err)
658663

659664
let
660665
-- | We allow users to specify a loading strategy.

0 commit comments

Comments
 (0)