Skip to content

Commit

Permalink
absolute file at the beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
soulomoon committed Nov 5, 2024
1 parent 98ae446 commit f3eb580
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ghcide/session-loader/Development/IDE/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
atomicModifyIORef' error_loading_files (\xs -> (failedLoadingFiles <> xs,()))

Check warning on line 677 in ghcide/session-loader/Development/IDE/Session.hs

View workflow job for this annotation

GitHub Actions / Hlint check run

Warning in loadSessionWithOptions in module Development.IDE.Session: Use atomicModifyIORef'_ ▫︎ Found: "atomicModifyIORef'\n error_loading_files (\\ xs -> (failedLoadingFiles <> xs, ()))" ▫︎ Perhaps: "atomicModifyIORef'_ error_loading_files ((<>) failedLoadingFiles)"
-- retry without other files
atomically $ forM_ pendingFiles (writeTQueue pendingFilesTQueue)
logWith recorder Info $ LogSessionReloadOnError cfp (Set.toList pendingFiles)
consultCradle hieYaml cfp
else do
dep_info <- getDependencyInfo (maybeToList hieYaml)
Expand Down Expand Up @@ -724,8 +725,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
atomicModifyIORef' cradle_files (\_ -> (Set.empty,()))

Check warning on line 725 in ghcide/session-loader/Development/IDE/Session.hs

View workflow job for this annotation

GitHub Actions / Hlint check run

Suggestion in loadSessionWithOptions in module Development.IDE.Session: Use const ▫︎ Found: "\\ _ -> (Set.empty, ())" ▫︎ Perhaps: "const (Set.empty, ())"

v <- Map.findWithDefault HM.empty hieYaml <$> readVar fileToFlags
let cfp = toAbsolutePath file
case HM.lookup (toNormalizedFilePath' cfp) v of
case HM.lookup (toNormalizedFilePath' file) v of
Just (opts, old_di) -> do
deps_ok <- checkDependencyInfo old_di
if not deps_ok
Expand All @@ -739,26 +739,27 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
modifyVar_ filesMap (const (return HM.empty))
-- Keep the same name cache
modifyVar_ hscEnvs (return . Map.adjust (const []) hieYaml )
consultCradle hieYaml cfp
consultCradle hieYaml file
else return (opts, Map.keys old_di)
Nothing -> consultCradle hieYaml cfp
Nothing -> consultCradle hieYaml file

-- The main function which gets options for a file. We only want one of these running
-- at a time. Therefore the IORef contains the currently running cradle, if we try
-- to get some more options then we wait for the currently running action to finish
-- before attempting to do so.
let getOptions :: FilePath -> IO (IdeResult HscEnvEq, [FilePath])
getOptions file = do
let ncfp = toNormalizedFilePath' (toAbsolutePath file)
let ncfp = toNormalizedFilePath' file
cachedHieYamlLocation <- HM.lookup ncfp <$> readVar filesMap
hieYaml <- cradleLoc file
sessionOpts (join cachedHieYamlLocation <|> hieYaml, file) `Safe.catch` \e ->
return (([renderPackageSetupException file e], Nothing), maybe [] pure hieYaml)

returnWithVersion $ \file -> do
atomically $ writeTQueue pendingFilesTQueue $ toAbsolutePath file
let absFile = toAbsolutePath file
atomically $ writeTQueue pendingFilesTQueue absFile
-- see Note [Serializing runs in separate thread]
awaitRunInThread que $ getOptions file
awaitRunInThread que $ getOptions absFile

-- | Run the specific cradle on a specific FilePath via hie-bios.
-- This then builds dependencies or whatever based on the cradle, gets the
Expand Down

0 comments on commit f3eb580

Please sign in to comment.