Skip to content

Commit 318d89a

Browse files
committed
module graph early cutoff
1 parent 0220797 commit 318d89a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎ghcide/src/Development/IDE/Core/Rules.hs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ import GHC.Unit.Env
169169
importGHC.Unit.Home.ModInfo
170170
#endif
171171
importGHC (mgModSummaries)
172+
importGHC.Fingerprint
172173

173174
dataLog
174175
=LogShakeShake.Log
@@ -523,7 +524,7 @@ rawDependencyInformation fs = do
523524

524525
reportImportCyclesRule::Recorder (WithPriorityLog) ->Rules()
525526
reportImportCyclesRule recorder =
526-
define (cmapWithPrio LogShake recorder) $\ReportImportCycles file ->fmap (\errs ->ifnull errs then ([], Just()) else (errs, Nothing)) $do
527+
defineEarlyCutoff (cmapWithPrio LogShake recorder) $Rule$\ReportImportCycles file ->fmap (\errs ->ifnull errs then (Just"1",([], Just()))else (Nothing, (errs, Nothing))) $do
527528
DependencyInformation{..} <- useNoFile_ GetModuleGraph
528529
let fileId = pathToId depPathIdMap file
529530
caseIntMap.lookup (getFilePathId fileId) depErrorNodes of
@@ -671,15 +672,16 @@ knownFilesRule recorder = defineEarlyCutOffNoFile (cmapWithPrio LogShake recorde
671672
pure (LBS.toStrict $B.encode $ hash fs, unhashed fs)
672673

673674
getModuleGraphRule::Recorder (WithPriorityLog) ->Rules()
674-
getModuleGraphRule recorder =defineNoFile (cmapWithPrio LogShake recorder) $\GetModuleGraph->do
675+
getModuleGraphRule recorder =defineEarlyCutOffNoFile (cmapWithPrio LogShake recorder) $\GetModuleGraph->do
675676
fs <- toKnownFiles <$> useNoFile_ GetKnownTargets
676677
dependencyInfoForFiles (HashSet.toList fs)
677678

678-
dependencyInfoForFiles:: [NormalizedFilePath] ->ActionDependencyInformation
679+
dependencyInfoForFiles:: [NormalizedFilePath] ->Action(BS.ByteString, DependencyInformation)
679680
dependencyInfoForFiles fs =do
680681
(rawDepInfo, bm) <- rawDependencyInformation fs
681682
let (all_fs, _all_ids) =unzip$HM.toList $ pathToIdMap $ rawPathIdMap rawDepInfo
682-
mss <-map (fmap msrModSummary) <$> uses GetModSummaryWithoutTimestamps all_fs
683+
msrs <- uses GetModSummaryWithoutTimestamps all_fs
684+
let mss =map (fmap msrModSummary) msrs
683685
#if MIN_VERSION_ghc(9,3,0)
684686
let deps =map (\i ->IM.lookup (getFilePathId i) (rawImports rawDepInfo)) _all_ids
685687
nodeKeys =IM.fromList $ catMaybes $zipWith (\fi mms -> (getFilePathId fi,) .NodeKey_Module. msKey <$> mms) _all_ids mss
@@ -700,7 +702,7 @@ dependencyInfoForFiles fs = do
700702
#endif
701703
(catMaybes mss)
702704
#endif
703-
pure$processDependencyInformation rawDepInfo bm mg
705+
pure(fingerprintToBS $Util.fingerprintFingerprints $map (maybe fingerprint0 msrFingerprint) msrs, processDependencyInformation rawDepInfo bm mg)
704706

705707
-- This is factored out so it can be directly called from the GetModIface
706708
-- rule. Directly calling this rule means that on the initial load we can
@@ -793,7 +795,7 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
793795
case mbdeps of
794796
Nothing->returnNothing
795797
Just deps ->do
796-
when fullModuleGraph $ void $uses_ReportImportCyclesdeps
798+
when fullModuleGraph $ void $use_ReportImportCyclesfile
797799
ms <- msrModSummary <$>if fullModSummary
798800
then use_ GetModSummary file
799801
else use_ GetModSummaryWithoutTimestamps file

0 commit comments

Comments
(0)