@@ -82,7 +82,6 @@ import Development.IDE.Types.Location
82
82
import Development.IDE.GHC.Compat hiding (parseModule , typecheckModule , writeHieFile , TargetModule , TargetFile )
83
83
import Development.IDE.GHC.ExactPrint
84
84
import Development.IDE.GHC.Util
85
- import Data.Either.Extra
86
85
import qualified Development.IDE.Types.Logger as L
87
86
import Data.Maybe
88
87
import Data.Foldable
@@ -402,17 +401,11 @@ getLocatedImportsRule =
402
401
(diags, imports') <- fmap unzip $ forM imports $ \ (isSource, (mbPkgName, modName)) -> do
403
402
diagOrImp <- locateModule dflags import_dirs (optExtensions opt) getTargetExists modName mbPkgName isSource
404
403
case diagOrImp of
405
- Left diags -> pure (diags, Left (modName, Nothing ))
406
- Right (FileImport path) -> pure ([] , Left (modName, Just path))
407
- Right (PackageImport pkgId) -> liftIO $ do
408
- diagsOrPkgDeps <- computePackageDeps env pkgId
409
- case diagsOrPkgDeps of
410
- Left diags -> pure (diags, Right Nothing )
411
- Right pkgIds -> pure ([] , Right $ Just $ pkgId : pkgIds)
412
- let (moduleImports, pkgImports) = partitionEithers imports'
413
- case sequence pkgImports of
414
- Nothing -> pure (concat diags, Nothing )
415
- Just pkgImports -> pure (concat diags, Just (moduleImports, Set. fromList $ concat pkgImports))
404
+ Left diags -> pure (diags, Just (modName, Nothing ))
405
+ Right (FileImport path) -> pure ([] , Just (modName, Just path))
406
+ Right PackageImport -> pure ([] , Nothing )
407
+ let moduleImports = catMaybes imports'
408
+ pure (concat diags, Just moduleImports)
416
409
417
410
type RawDepM a = StateT (RawDependencyInformation , IntMap ArtifactsLocation ) Action a
418
411
@@ -427,19 +420,23 @@ execRawDepM act =
427
420
-- imports recursively.
428
421
rawDependencyInformation :: [NormalizedFilePath ] -> Action RawDependencyInformation
429
422
rawDependencyInformation fs = do
430
- (rdi, ss) <- execRawDepM (mapM_ go fs)
423
+ (rdi, ss) <- execRawDepM (goPlural fs)
431
424
let bm = IntMap. foldrWithKey (updateBootMap rdi) IntMap. empty ss
432
425
return (rdi { rawBootMap = bm })
433
426
where
427
+ goPlural ff = do
428
+ mss <- lift $ (fmap . fmap ) fst <$> uses GetModSummaryWithoutTimestamps ff
429
+ zipWithM go ff mss
430
+
434
431
go :: NormalizedFilePath -- ^ Current module being processed
432
+ -> Maybe ModSummary -- ^ ModSummary of the module
435
433
-> StateT (RawDependencyInformation , IntMap ArtifactsLocation ) Action FilePathId
436
- go f = do
434
+ go f msum = do
437
435
-- First check to see if we have already processed the FilePath
438
436
-- If we have, just return its Id but don't update any of the state.
439
437
-- Otherwise, we need to process its imports.
440
438
checkAlreadyProcessed f $ do
441
- msum <- lift $ fmap fst <$> use GetModSummaryWithoutTimestamps f
442
- let al = modSummaryToArtifactsLocation f msum
439
+ let al = modSummaryToArtifactsLocation f msum
443
440
-- Get a fresh FilePathId for the new file
444
441
fId <- getFreshFid al
445
442
-- Adding an edge to the bootmap so we can make sure to
@@ -454,19 +451,19 @@ rawDependencyInformation fs = do
454
451
-- elements in the queue
455
452
modifyRawDepInfo (insertImport fId (Left ModuleParseError ))
456
453
return fId
457
- Just ( modImports, pkgImports) -> do
454
+ Just modImports -> do
458
455
-- Get NFPs of the imports which have corresponding files
459
456
-- Imports either come locally from a file or from a package.
460
457
let (no_file, with_file) = splitImports modImports
461
458
(mns, ls) = unzip with_file
462
459
-- Recursively process all the imports we just learnt about
463
460
-- and get back a list of their FilePathIds
464
- fids <- mapM (go . artifactFilePath) ls
461
+ fids <- goPlural $ map artifactFilePath ls
465
462
-- Associate together the ModuleName with the FilePathId
466
463
let moduleImports' = map (,Nothing ) no_file ++ zip mns (map Just fids)
467
464
-- Insert into the map the information about this modules
468
465
-- imports.
469
- modifyRawDepInfo $ insertImport fId (Right $ ModuleImports moduleImports' pkgImports )
466
+ modifyRawDepInfo $ insertImport fId (Right $ ModuleImports moduleImports')
470
467
return fId
471
468
472
469
@@ -612,7 +609,7 @@ getHieAstRuleDefinition f hsc tmr = do
612
609
getImportMapRule :: Rules ()
613
610
getImportMapRule = define $ \ GetImportMap f -> do
614
611
im <- use GetLocatedImports f
615
- let mkImports ( fileImports, _) = M. fromList $ mapMaybe (\ (m, mfp) -> (unLoc m,) . artifactFilePath <$> mfp) fileImports
612
+ let mkImports fileImports = M. fromList $ mapMaybe (\ (m, mfp) -> (unLoc m,) . artifactFilePath <$> mfp) fileImports
616
613
pure ([] , ImportMap . mkImports <$> im)
617
614
618
615
-- | Ensure that go to definition doesn't block on startup
@@ -857,7 +854,7 @@ isHiFileStableRule = defineEarlyCutoff $ \IsHiFileStable f -> do
857
854
if modificationTime x < modificationTime modVersion
858
855
then pure SourceModified
859
856
else do
860
- ( fileImports, _) <- use_ GetLocatedImports f
857
+ fileImports <- use_ GetLocatedImports f
861
858
let imports = fmap artifactFilePath . snd <$> fileImports
862
859
deps <- uses_ IsHiFileStable (catMaybes imports)
863
860
pure $ if all (== SourceUnmodifiedAndStable ) deps
0 commit comments