Skip to content

Commit

Permalink
add doc about limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
soulomoon committed Nov 4, 2024
1 parent 67aebc4 commit 98ae446
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ghcide/session-loader/Development/IDE/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,10 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
if (not $ null extraToLoads)

Check warning on line 669 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: Redundant bracket ▫︎ Found: "if (not $ null extraToLoads) then\n do let failedLoadingFiles\n = (Set.insert cfp extraToLoads) `Set.difference` old_files\n atomicModifyIORef'\n error_loading_files (\\ xs -> (failedLoadingFiles <> xs, ()))\n atomically $ forM_ pendingFiles (writeTQueue pendingFilesTQueue)\n consultCradle hieYaml cfp\nelse\n do dep_info <- getDependencyInfo (maybeToList hieYaml)\n let ncfp = toNormalizedFilePath' cfp\n let res\n = (map (\\ err' -> renderCradleError err' cradle ncfp) err, Nothing)\n void\n $ modifyVar' fileToFlags\n $ Map.insertWith\n HM.union hieYaml (HM.singleton ncfp (res, dep_info))\n void $ modifyVar' filesMap $ HM.insert ncfp hieYaml\n atomicModifyIORef'\n error_loading_files (\\ xs -> (Set.insert cfp xs, ()))\n return\n (res, \n maybe [] pure hieYaml ++ concatMap cradleErrorDependencies err)" ▫︎ Perhaps: "if not $ null extraToLoads then\n do let failedLoadingFiles\n = (Set.insert cfp extraToLoads) `Set.difference` old_files\n atomicModifyIORef'\n error_loading_files (\\ xs -> (failedLoadingFiles <> xs, ()))\n atomically $ forM_ pendingFiles (writeTQueue pendingFilesTQueue)\n consultCradle hieYaml cfp\nelse\n do dep_info <- getDependencyInfo (maybeToList hieYaml)\n let ncfp = toNormalizedFilePath' cfp\n let res\n = (map (\\ err' -> renderCradleError err' cradle ncfp) err, Nothing)\n void\n $ modifyVar' fileToFlags\n $ Map.insertWith\n HM.union hieYaml (HM.singleton ncfp (res, dep_info))\n void $ modifyVar' filesMap $ HM.insert ncfp hieYaml\n atomicModifyIORef'\n error_loading_files (\\ xs -> (Set.insert cfp xs, ()))\n return\n (res, \n maybe [] pure hieYaml ++ concatMap cradleErrorDependencies err)"
then do
-- mark as less loaded files as failedLoadingFiles as possible
-- limitation is that when we are loading files, and the dependencies of old_files
-- are changed, and old_files are not valid anymore.
-- but they will still be in the old_files, and will not move to error_loading_files.
-- And make other files failed to load in batch mode.
let failedLoadingFiles = (Set.insert cfp extraToLoads) `Set.difference` old_files

Check warning on line 676 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: Redundant bracket ▫︎ Found: "(Set.insert cfp extraToLoads) `Set.difference` old_files" ▫︎ Perhaps: "Set.insert cfp extraToLoads `Set.difference` old_files"
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
Expand Down Expand Up @@ -726,7 +730,6 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
deps_ok <- checkDependencyInfo old_di
if not deps_ok
then do
-- todo invoke the action to recompile the file
-- if deps are old, we can try to load the error files again
atomicModifyIORef' error_loading_files (\xs -> (Set.delete file xs,()))

Check warning on line 734 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 -> (Set.delete file xs, ()))" ▫︎ Perhaps: "atomicModifyIORef'_ error_loading_files (Set.delete file)"
atomicModifyIORef' cradle_files (\xs -> (Set.delete file xs,()))
Expand Down

0 comments on commit 98ae446

Please sign in to comment.