@@ -30,7 +30,6 @@ module Development.IDE.Core.Rules(
3030 usePropertyAction ,
3131 -- * Rules
3232 CompiledLinkables (.. ),
33- IsHiFileStable (.. ),
3433 getParsedModuleRule ,
3534 getParsedModuleWithCommentsRule ,
3635 getLocatedImportsRule ,
@@ -42,7 +41,6 @@ module Development.IDE.Core.Rules(
4241 getModIfaceFromDiskRule ,
4342 getModIfaceRule ,
4443 getModSummaryRule ,
45- isHiFileStableRule ,
4644 getModuleGraphRule ,
4745 knownFilesRule ,
4846 getClientSettingsRule ,
@@ -121,7 +119,6 @@ import Development.IDE.GHC.ExactPrint hiding (LogShake, Log)
121119import Development.IDE.GHC.Util hiding
122120 (modifyDynFlags )
123121import Development.IDE.Graph
124- import Development.IDE.Graph.Classes
125122import Development.IDE.Import.DependencyInformation
126123import Development.IDE.Import.FindImports
127124import qualified Development.IDE.Spans.AtPoint as AtPoint
@@ -131,7 +128,6 @@ import Development.IDE.Types.Diagnostics as Diag
131128import Development.IDE.Types.HscEnvEq
132129import Development.IDE.Types.Location
133130import Development.IDE.Types.Options
134- import GHC.Generics (Generic )
135131import qualified GHC.LanguageExtensions as LangExt
136132import qualified HieDb
137133import Ide.Plugin.Config
@@ -156,6 +152,7 @@ import Development.IDE.Types.Logger (Recorder, logWith, cmapWithPrio, WithPriori
156152import qualified Development.IDE.Core.Shake as Shake
157153import qualified Development.IDE.GHC.ExactPrint as ExactPrint hiding (LogShake )
158154import qualified Development.IDE.Types.Logger as Logger
155+ import qualified Development.IDE.Types.Shake as Shake
159156
160157data Log
161158 = LogShake Shake. Log
@@ -773,14 +770,18 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
773770-- | Load a iface from disk, or generate it if there isn't one or it is out of date
774771-- This rule also ensures that the `.hie` and `.o` (if needed) files are written out.
775772getModIfaceFromDiskRule :: Recorder (WithPriority Log ) -> Rules ()
776- getModIfaceFromDiskRule recorder = defineEarlyCutoff (cmapWithPrio LogShake recorder) $ Rule $ \ GetModIfaceFromDisk f -> do
773+ getModIfaceFromDiskRule recorder = defineEarlyCutoff (cmapWithPrio LogShake recorder) $ RuleWithOldValue $ \ GetModIfaceFromDisk f old -> do
777774 ms <- msrModSummary <$> use_ GetModSummary f
778775 mb_session <- use GhcSessionDeps f
779776 case mb_session of
780777 Nothing -> return (Nothing , ([] , Nothing ))
781778 Just session -> do
782- sourceModified <- use_ IsHiFileStable f
783779 linkableType <- getLinkableType f
780+ ver <- use_ GetModificationTime f
781+ let sourceModified = case old of
782+ Shake. Succeeded (Just old_version) _ | old_version == ver -> SourceUnmodified
783+ Shake. Stale _ (Just old_version) _ | old_version == ver -> SourceUnmodified
784+ _ -> SourceModified
784785 r <- loadInterface (hscEnv session) ms sourceModified linkableType (regenerateHiFile session f ms)
785786 case r of
786787 (diags, Nothing ) -> return (Nothing , (diags, Nothing ))
@@ -832,31 +833,6 @@ getModIfaceFromDiskAndIndexRule recorder =
832833
833834 return (Just x)
834835
835- isHiFileStableRule :: Recorder (WithPriority Log ) -> Rules ()
836- isHiFileStableRule recorder = defineEarlyCutoff (cmapWithPrio LogShake recorder) $ RuleNoDiagnostics $ \ IsHiFileStable f -> do
837- ms <- msrModSummary <$> use_ GetModSummaryWithoutTimestamps f
838- let hiFile = toNormalizedFilePath'
839- $ Compat. ml_hi_file $ ms_location ms
840- mbHiVersion <- use GetModificationTime_ {missingFileDiagnostics= False } hiFile
841- modVersion <- use_ GetModificationTime f
842- sourceModified <- case mbHiVersion of
843- Nothing -> pure SourceModified
844- Just x ->
845- if modificationTime x < modificationTime modVersion
846- then pure SourceModified
847- else do
848- fileImports <- use_ GetLocatedImports f
849- let imports = fmap artifactFilePath . snd <$> fileImports
850- deps <- uses_ IsHiFileStable (catMaybes imports)
851- pure $ if all (== SourceUnmodifiedAndStable ) deps
852- then SourceUnmodifiedAndStable
853- else SourceUnmodified
854- return (Just (summarize sourceModified), Just sourceModified)
855- where
856- summarize SourceModified = BS. singleton 1
857- summarize SourceUnmodified = BS. singleton 2
858- summarize SourceUnmodifiedAndStable = BS. singleton 3
859-
860836displayTHWarning :: LspT c IO ()
861837displayTHWarning
862838 | not isWindows && not hostIsDynamic = do
@@ -1153,7 +1129,6 @@ mainRule recorder RulesConfig{..} = do
11531129 getModIfaceFromDiskAndIndexRule recorder
11541130 getModIfaceRule recorder
11551131 getModSummaryRule recorder
1156- isHiFileStableRule recorder
11571132 getModuleGraphRule recorder
11581133 knownFilesRule recorder
11591134 getClientSettingsRule recorder
@@ -1175,13 +1150,3 @@ mainRule recorder RulesConfig{..} = do
11751150 persistentHieFileRule recorder
11761151 persistentDocMapRule
11771152 persistentImportMapRule
1178-
1179- -- | Given the path to a module src file, this rule returns True if the
1180- -- corresponding `.hi` file is stable, that is, if it is newer
1181- -- than the src file, and all its dependencies are stable too.
1182- data IsHiFileStable = IsHiFileStable
1183- deriving (Eq , Show , Typeable , Generic )
1184- instance Hashable IsHiFileStable
1185- instance NFData IsHiFileStable
1186-
1187- type instance RuleResult IsHiFileStable = SourceModified
0 commit comments