@@ -195,7 +195,7 @@ main = do
195
195
, optInterfaceLoadingDiagnostics = argsTesting
196
196
}
197
197
debouncer <- newAsyncDebouncer
198
- initialise caps (mainRule >> pluginRules plugins)
198
+ fst <$> initialise caps (mainRule >> pluginRules plugins)
199
199
getLspId event hlsLogger debouncer options vfs
200
200
else do
201
201
-- GHC produces messages with UTF8 in them, so make sure the terminal doesn't error
@@ -218,15 +218,15 @@ main = do
218
218
putStrLn $ " Found " ++ show n ++ " cradle" ++ [' s' | n /= 1 ]
219
219
putStrLn " \n Step 3/6: Initializing the IDE"
220
220
vfs <- makeVFSHandle
221
-
222
221
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
224
223
225
224
putStrLn " \n Step 4/6: Type checking the files"
226
225
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)
228
227
-- results <- runActionSync ide $ use TypeCheck $ toNormalizedFilePath' "src/Development/IDE/Core/Rules.hs"
229
228
-- results <- runActionSync ide $ use TypeCheck $ toNormalizedFilePath' "exe/Main.hs"
229
+ cancel worker
230
230
return ()
231
231
232
232
expandFiles :: [FilePath ] -> IO [FilePath ]
@@ -408,7 +408,7 @@ loadSession dir = liftIO $ do
408
408
modifyVar_ fileToFlags $ \ var -> do
409
409
pure $ Map. insert hieYaml (HM. fromList (cs ++ cached_targets)) var
410
410
411
- return res
411
+ return (cs, res)
412
412
413
413
lock <- newLock
414
414
@@ -432,7 +432,7 @@ loadSession dir = liftIO $ do
432
432
case HM. lookup (toNormalizedFilePath' cfp) v of
433
433
Just opts -> do
434
434
-- putStrLn $ "Cached component of " <> show file
435
- pure (fst opts)
435
+ pure ([] , fst opts)
436
436
Nothing -> do
437
437
finished_barrier <- newBarrier
438
438
-- fork a new thread here which won't be killed by shake
@@ -442,8 +442,8 @@ loadSession dir = liftIO $ do
442
442
cradle <- maybe (loadImplicitCradle $ addTrailingPathSeparator dir) loadCradle hieYaml
443
443
opts <- cradleToSessionOpts cradle cfp
444
444
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)
447
447
waitBarrier finished_barrier
448
448
449
449
dummyAs <- async $ return (error " Uninitialised" )
@@ -454,18 +454,30 @@ loadSession dir = liftIO $ do
454
454
hieYaml <- cradleLoc file
455
455
sessionOpts (hieYaml, file)
456
456
-- 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
+
469
481
470
482
471
483
0 commit comments