@@ -30,7 +30,6 @@ module Development.IDE.Core.Rules(
30
30
usePropertyAction ,
31
31
-- * Rules
32
32
CompiledLinkables (.. ),
33
- IsHiFileStable (.. ),
34
33
getParsedModuleRule ,
35
34
getParsedModuleWithCommentsRule ,
36
35
getLocatedImportsRule ,
@@ -42,7 +41,6 @@ module Development.IDE.Core.Rules(
42
41
getModIfaceFromDiskRule ,
43
42
getModIfaceRule ,
44
43
getModSummaryRule ,
45
- isHiFileStableRule ,
46
44
getModuleGraphRule ,
47
45
knownFilesRule ,
48
46
getClientSettingsRule ,
@@ -121,7 +119,6 @@ import Development.IDE.GHC.ExactPrint hiding (LogShake, Log)
121
119
import Development.IDE.GHC.Util hiding
122
120
(modifyDynFlags )
123
121
import Development.IDE.Graph
124
- import Development.IDE.Graph.Classes
125
122
import Development.IDE.Import.DependencyInformation
126
123
import Development.IDE.Import.FindImports
127
124
import qualified Development.IDE.Spans.AtPoint as AtPoint
@@ -131,7 +128,6 @@ import Development.IDE.Types.Diagnostics as Diag
131
128
import Development.IDE.Types.HscEnvEq
132
129
import Development.IDE.Types.Location
133
130
import Development.IDE.Types.Options
134
- import GHC.Generics (Generic )
135
131
import qualified GHC.LanguageExtensions as LangExt
136
132
import qualified HieDb
137
133
import Ide.Plugin.Config
@@ -156,6 +152,7 @@ import Development.IDE.Types.Logger (Recorder, logWith, cmapWithPrio, WithPriori
156
152
import qualified Development.IDE.Core.Shake as Shake
157
153
import qualified Development.IDE.GHC.ExactPrint as ExactPrint hiding (LogShake )
158
154
import qualified Development.IDE.Types.Logger as Logger
155
+ import qualified Development.IDE.Types.Shake as Shake
159
156
160
157
data Log
161
158
= LogShake Shake. Log
@@ -773,14 +770,18 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
773
770
-- | Load a iface from disk, or generate it if there isn't one or it is out of date
774
771
-- This rule also ensures that the `.hie` and `.o` (if needed) files are written out.
775
772
getModIfaceFromDiskRule :: 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
777
774
ms <- msrModSummary <$> use_ GetModSummary f
778
775
mb_session <- use GhcSessionDeps f
779
776
case mb_session of
780
777
Nothing -> return (Nothing , ([] , Nothing ))
781
778
Just session -> do
782
- sourceModified <- use_ IsHiFileStable f
783
779
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
784
785
r <- loadInterface (hscEnv session) ms sourceModified linkableType (regenerateHiFile session f ms)
785
786
case r of
786
787
(diags, Nothing ) -> return (Nothing , (diags, Nothing ))
@@ -832,31 +833,6 @@ getModIfaceFromDiskAndIndexRule recorder =
832
833
833
834
return (Just x)
834
835
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
-
860
836
displayTHWarning :: LspT c IO ()
861
837
displayTHWarning
862
838
| not isWindows && not hostIsDynamic = do
@@ -1153,7 +1129,6 @@ mainRule recorder RulesConfig{..} = do
1153
1129
getModIfaceFromDiskAndIndexRule recorder
1154
1130
getModIfaceRule recorder
1155
1131
getModSummaryRule recorder
1156
- isHiFileStableRule recorder
1157
1132
getModuleGraphRule recorder
1158
1133
knownFilesRule recorder
1159
1134
getClientSettingsRule recorder
@@ -1175,13 +1150,3 @@ mainRule recorder RulesConfig{..} = do
1175
1150
persistentHieFileRule recorder
1176
1151
persistentDocMapRule
1177
1152
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