@@ -472,7 +472,7 @@ rawDependencyInformation fs = do
472472reportImportCyclesRule :: Recorder (WithPriority Log ) -> Rules ()
473473reportImportCyclesRule recorder =
474474 defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ ReportImportCycles file -> fmap (\ errs -> if null errs then (Just " 1" ,([] , Just () )) else (Nothing , (errs, Nothing ))) $ do
475- DependencyInformation {.. } <- useNoFile_ GetModuleGraph
475+ DependencyInformation {.. } <- useWithSeparateFingerprintRule_ GetModuleGraphTransDepsFingerprints GetModuleGraph file
476476 case pathToId depPathIdMap file of
477477 -- The header of the file does not parse, so it can't be part of any import cycles.
478478 Nothing -> pure []
@@ -608,7 +608,7 @@ typeCheckRule recorder = define (cmapWithPrio LogShake recorder) $ \TypeCheck fi
608608 -- very expensive.
609609 when (foi == NotFOI ) $
610610 logWith recorder Logger. Warning $ LogTypecheckedFOI file
611- typeCheckRuleDefinition hsc pm
611+ typeCheckRuleDefinition hsc pm file
612612
613613knownFilesRule :: Recorder (WithPriority Log ) -> Rules ()
614614knownFilesRule recorder = defineEarlyCutOffNoFile (cmapWithPrio LogShake recorder) $ \ GetKnownTargets -> do
@@ -643,7 +643,10 @@ dependencyInfoForFiles fs = do
643643 go (Just ms) _ = Just $ ModuleNode [] ms
644644 go _ _ = Nothing
645645 mg = mkModuleGraph mns
646- pure (fingerprintToBS $ Util. fingerprintFingerprints $ map (maybe fingerprint0 msrFingerprint) msrs, processDependencyInformation rawDepInfo bm mg)
646+ let shallowFingers = IntMap. fromList $ foldr' (\ (i, m) acc -> case m of
647+ Just x -> (getFilePathId i,msrFingerprint x): acc
648+ Nothing -> acc) [] $ zip _all_ids msrs
649+ pure (fingerprintToBS $ Util. fingerprintFingerprints $ map (maybe fingerprint0 msrFingerprint) msrs, processDependencyInformation rawDepInfo bm mg shallowFingers)
647650
648651-- This is factored out so it can be directly called from the GetModIface
649652-- rule. Directly calling this rule means that on the initial load we can
@@ -652,14 +655,15 @@ dependencyInfoForFiles fs = do
652655typeCheckRuleDefinition
653656 :: HscEnv
654657 -> ParsedModule
658+ -> NormalizedFilePath
655659 -> Action (IdeResult TcModuleResult )
656- typeCheckRuleDefinition hsc pm = do
660+ typeCheckRuleDefinition hsc pm fp = do
657661 IdeOptions { optDefer = defer } <- getIdeOptions
658662
659663 unlift <- askUnliftIO
660664 let dets = TypecheckHelpers
661665 { getLinkables = unliftIO unlift . uses_ GetLinkable
662- , getModuleGraph = unliftIO unlift $ useNoFile_ GetModuleGraph
666+ , getModuleGraph = unliftIO unlift $ useWithSeparateFingerprintRule_ GetModuleGraphTransDepsFingerprints GetModuleGraph fp
663667 }
664668 addUsageDependencies $ liftIO $
665669 typecheckModule defer hsc dets pm
@@ -756,9 +760,10 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
756760 depSessions <- map hscEnv <$> uses_ (GhcSessionDeps_ fullModSummary) deps
757761 ifaces <- uses_ GetModIface deps
758762 let inLoadOrder = map (\ HiFileResult {.. } -> HomeModInfo hirModIface hirModDetails emptyHomeModInfoLinkable) ifaces
763+ de <- useWithSeparateFingerprintRule_ GetModuleGraphTransDepsFingerprints GetModuleGraph file
759764 mg <- do
760765 if fullModuleGraph
761- then depModuleGraph <$> useNoFile_ GetModuleGraph
766+ then return $ depModuleGraph de
762767 else do
763768 let mgs = map hsc_mod_graph depSessions
764769 -- On GHC 9.4+, the module graph contains not only ModSummary's but each `ModuleNode` in the graph
@@ -771,7 +776,6 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
771776 nubOrdOn mkNodeKey (ModuleNode final_deps ms : concatMap mgModSummaries' mgs)
772777 liftIO $ evaluate $ liftRnf rwhnf module_graph_nodes
773778 return $ mkModuleGraph module_graph_nodes
774- de <- useNoFile_ GetModuleGraph
775779 session' <- liftIO $ mergeEnvs hsc mg de ms inLoadOrder depSessions
776780
777781 -- Here we avoid a call to to `newHscEnvEqWithImportPaths`, which creates a new
@@ -801,7 +805,7 @@ getModIfaceFromDiskRule recorder = defineEarlyCutoff (cmapWithPrio LogShake reco
801805 , old_value = m_old
802806 , get_file_version = use GetModificationTime_ {missingFileDiagnostics = False }
803807 , get_linkable_hashes = \ fs -> map (snd . fromJust . hirCoreFp) <$> uses_ GetModIface fs
804- , get_module_graph = useNoFile_ GetModuleGraph
808+ , get_module_graph = useWithSeparateFingerprintRule_ GetModuleGraphTransDepsFingerprints GetModuleGraph f
805809 , regenerate = regenerateHiFile session f ms
806810 }
807811 hsc_env' <- setFileCacheHook (hscEnv session)
@@ -977,7 +981,7 @@ regenerateHiFile sess f ms compNeeded = do
977981 Just pm -> do
978982 -- Invoke typechecking directly to update it without incurring a dependency
979983 -- on the parsed module and the typecheck rules
980- (diags', mtmr) <- typeCheckRuleDefinition hsc pm
984+ (diags', mtmr) <- typeCheckRuleDefinition hsc pm f
981985 case mtmr of
982986 Nothing -> pure (diags', Nothing )
983987 Just tmr -> do
@@ -1135,7 +1139,7 @@ needsCompilationRule file
11351139 | " boot" `isSuffixOf` fromNormalizedFilePath file =
11361140 pure (Just $ encodeLinkableType Nothing , Just Nothing )
11371141needsCompilationRule file = do
1138- graph <- useNoFile GetModuleGraph
1142+ graph <- useWithSeparateFingerprintRule GetModuleGraphImmediateReverseDepsFingerprints GetModuleGraph file
11391143 res <- case graph of
11401144 -- Treat as False if some reverse dependency header fails to parse
11411145 Nothing -> pure Nothing
@@ -1247,6 +1251,19 @@ mainRule recorder RulesConfig{..} = do
12471251 persistentDocMapRule
12481252 persistentImportMapRule
12491253 getLinkableRule recorder
1254+ defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ GetModuleGraphTransDepsFingerprints file -> do
1255+ di <- useNoFile_ GetModuleGraph
1256+ let finger = lookupFingerprint file di (depTransDepsFingerprints di)
1257+ return (fingerprintToBS <$> finger, ([] , finger))
1258+ defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ GetModuleGraphTransReverseDepsFingerprints file -> do
1259+ di <- useNoFile_ GetModuleGraph
1260+ let finger = lookupFingerprint file di (depTransReverseDepsFingerprints di)
1261+ return (fingerprintToBS <$> finger, ([] , finger))
1262+ defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ GetModuleGraphImmediateReverseDepsFingerprints file -> do
1263+ di <- useNoFile_ GetModuleGraph
1264+ let finger = lookupFingerprint file di (depImmediateReverseDepsFingerprints di)
1265+ return (fingerprintToBS <$> finger, ([] , finger))
1266+
12501267
12511268-- | Get HieFile for haskell file on NormalizedFilePath
12521269getHieFile :: NormalizedFilePath -> Action (Maybe HieFile )
0 commit comments