@@ -195,7 +195,7 @@ main = do
195195 , optInterfaceLoadingDiagnostics = argsTesting
196196 }
197197 debouncer <- newAsyncDebouncer
198- initialise caps (mainRule >> pluginRules plugins)
198+ fst <$> initialise caps (mainRule >> pluginRules plugins)
199199 getLspId event hlsLogger debouncer options vfs
200200 else do
201201 -- GHC produces messages with UTF8 in them, so make sure the terminal doesn't error
@@ -218,15 +218,15 @@ main = do
218218 putStrLn $ " Found " ++ show n ++ " cradle" ++ [' s' | n /= 1 ]
219219 putStrLn " \n Step 3/6: Initializing the IDE"
220220 vfs <- makeVFSHandle
221-
222221 debouncer <- newAsyncDebouncer
223- ide <- initialise def mainRule (pure $ IdInt 0 ) (showEvent lock) (logger Info ) debouncer (defaultIdeOptions $ loadSession dir) vfs
222+ ( ide, worker) <- initialise def mainRule (pure $ IdInt 0 ) (showEvent lock) (logger Info ) debouncer (defaultIdeOptions $ loadSession dir) vfs
224223
225224 putStrLn " \n Step 4/6: Type checking the files"
226225 setFilesOfInterest ide $ HashSet. fromList $ map toNormalizedFilePath' files
227- _ <- runActionSync " TypecheckTest" ide $ uses TypeCheck (map toNormalizedFilePath' files)
226+ -- _ <- runActionSync "TypecheckTest" ide $ uses TypeCheck (map toNormalizedFilePath' files)
228227-- results <- runActionSync ide $ use TypeCheck $ toNormalizedFilePath' "src/Development/IDE/Core/Rules.hs"
229228-- results <- runActionSync ide $ use TypeCheck $ toNormalizedFilePath' "exe/Main.hs"
229+ cancel worker
230230 return ()
231231
232232expandFiles :: [FilePath ] -> IO [FilePath ]
@@ -408,7 +408,7 @@ loadSession dir = liftIO $ do
408408 modifyVar_ fileToFlags $ \ var -> do
409409 pure $ Map. insert hieYaml (HM. fromList (cs ++ cached_targets)) var
410410
411- return res
411+ return (cs, res)
412412
413413 lock <- newLock
414414
@@ -432,7 +432,7 @@ loadSession dir = liftIO $ do
432432 case HM. lookup (toNormalizedFilePath' cfp) v of
433433 Just opts -> do
434434 -- putStrLn $ "Cached component of " <> show file
435- pure (fst opts)
435+ pure ([] , fst opts)
436436 Nothing -> do
437437 finished_barrier <- newBarrier
438438 -- fork a new thread here which won't be killed by shake
@@ -442,8 +442,8 @@ loadSession dir = liftIO $ do
442442 cradle <- maybe (loadImplicitCradle $ addTrailingPathSeparator dir) loadCradle hieYaml
443443 opts <- cradleToSessionOpts cradle cfp
444444 print opts
445- res <- fst <$> session (hieYaml, toNormalizedFilePath' cfp, opts)
446- signalBarrier finished_barrier res
445+ (cs, res) <- session (hieYaml, toNormalizedFilePath' cfp, opts)
446+ signalBarrier finished_barrier (cs, fst res)
447447 waitBarrier finished_barrier
448448
449449 dummyAs <- async $ return (error " Uninitialised" )
@@ -454,18 +454,30 @@ loadSession dir = liftIO $ do
454454 hieYaml <- cradleLoc file
455455 sessionOpts (hieYaml, file)
456456 -- The lock is on the `runningCradle` resource
457- return $ \ file -> liftIO $ withLock lock $ do
458- as <- readIORef runningCradle
459- finished <- poll as
460- case finished of
461- Just {} -> do
462- as <- async $ getOptions file
463- writeIORef runningCradle as
464- wait as
465- -- If it's not finished then wait and then get options, this could of course be killed still
466- Nothing -> do
467- _ <- wait as
468- getOptions file
457+ return $ \ file -> do
458+ (cs, opts) <-
459+ liftIO $ withLock lock $ do
460+ as <- readIORef runningCradle
461+ finished <- poll as
462+ case finished of
463+ Just {} -> do
464+ as <- async $ getOptions file
465+ writeIORef runningCradle as
466+ wait as
467+ -- If it's not finished then wait and then get options, this could of course be killed still
468+ Nothing -> do
469+ _ <- wait as
470+ getOptions file
471+ let cfps = map fst cs
472+ -- Delayed to avoid recursion and only run if something changed.
473+ unless (null cs) (
474+ delay " InitialLoad" (" InitialLoad" :: String , cfps ) (void $ do
475+ cfps' <- liftIO $ filterM (IO. doesFileExist . fromNormalizedFilePath) cfps
476+ mmt <- uses GetModificationTime cfps'
477+ let cs_exist = catMaybes (zipWith (<$) cfps' mmt)
478+ uses GetModIface cs_exist))
479+ return opts
480+
469481
470482
471483
0 commit comments