@@ -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 ,
@@ -150,6 +148,7 @@ import Control.Concurrent.STM.Stats (atomically)
150
148
import Language.LSP.Server (LspT )
151
149
import System.Info.Extra (isWindows )
152
150
import HIE.Bios.Ghc.Gap (hostIsDynamic )
151
+ import qualified Development.IDE.Types.Shake as Shake
153
152
154
153
templateHaskellInstructions :: T. Text
155
154
templateHaskellInstructions = " https://haskell-language-server.readthedocs.io/en/latest/troubleshooting.html#static-binaries"
@@ -743,14 +742,18 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
743
742
-- | Load a iface from disk, or generate it if there isn't one or it is out of date
744
743
-- This rule also ensures that the `.hie` and `.o` (if needed) files are written out.
745
744
getModIfaceFromDiskRule :: Rules ()
746
- getModIfaceFromDiskRule = defineEarlyCutoff $ Rule $ \ GetModIfaceFromDisk f -> do
745
+ getModIfaceFromDiskRule = defineEarlyCutoff $ RuleWithOldValue $ \ GetModIfaceFromDisk f old -> do
747
746
ms <- msrModSummary <$> use_ GetModSummary f
748
747
mb_session <- use GhcSessionDeps f
749
748
case mb_session of
750
749
Nothing -> return (Nothing , ([] , Nothing ))
751
750
Just session -> do
752
- sourceModified <- use_ IsHiFileStable f
753
751
linkableType <- getLinkableType f
752
+ ver <- use_ GetModificationTime f
753
+ let sourceModified = case old of
754
+ Shake. Succeeded (Just old_version) _ | old_version == ver -> SourceUnmodified
755
+ Shake. Stale _ (Just old_version) _ | old_version == ver -> SourceUnmodified
756
+ _ -> SourceModified
754
757
r <- loadInterface (hscEnv session) ms sourceModified linkableType (regenerateHiFile session f ms)
755
758
case r of
756
759
(diags, Nothing ) -> return (Nothing , (diags, Nothing ))
@@ -802,31 +805,6 @@ getModIfaceFromDiskAndIndexRule =
802
805
803
806
return (Just x)
804
807
805
- isHiFileStableRule :: Rules ()
806
- isHiFileStableRule = defineEarlyCutoff $ RuleNoDiagnostics $ \ IsHiFileStable f -> do
807
- ms <- msrModSummary <$> use_ GetModSummaryWithoutTimestamps f
808
- let hiFile = toNormalizedFilePath'
809
- $ Compat. ml_hi_file $ ms_location ms
810
- mbHiVersion <- use GetModificationTime_ {missingFileDiagnostics= False } hiFile
811
- modVersion <- use_ GetModificationTime f
812
- sourceModified <- case mbHiVersion of
813
- Nothing -> pure SourceModified
814
- Just x ->
815
- if modificationTime x < modificationTime modVersion
816
- then pure SourceModified
817
- else do
818
- fileImports <- use_ GetLocatedImports f
819
- let imports = fmap artifactFilePath . snd <$> fileImports
820
- deps <- uses_ IsHiFileStable (catMaybes imports)
821
- pure $ if all (== SourceUnmodifiedAndStable ) deps
822
- then SourceUnmodifiedAndStable
823
- else SourceUnmodified
824
- return (Just (summarize sourceModified), Just sourceModified)
825
- where
826
- summarize SourceModified = BS. singleton 1
827
- summarize SourceUnmodified = BS. singleton 2
828
- summarize SourceUnmodifiedAndStable = BS. singleton 3
829
-
830
808
displayTHWarning :: LspT c IO ()
831
809
displayTHWarning
832
810
| not isWindows && not hostIsDynamic = do
@@ -1122,7 +1100,6 @@ mainRule RulesConfig{..} = do
1122
1100
getModIfaceFromDiskAndIndexRule
1123
1101
getModIfaceRule
1124
1102
getModSummaryRule
1125
- isHiFileStableRule
1126
1103
getModuleGraphRule
1127
1104
knownFilesRule
1128
1105
getClientSettingsRule
@@ -1144,13 +1121,3 @@ mainRule RulesConfig{..} = do
1144
1121
persistentHieFileRule
1145
1122
persistentDocMapRule
1146
1123
persistentImportMapRule
1147
-
1148
- -- | Given the path to a module src file, this rule returns True if the
1149
- -- corresponding `.hi` file is stable, that is, if it is newer
1150
- -- than the src file, and all its dependencies are stable too.
1151
- data IsHiFileStable = IsHiFileStable
1152
- deriving (Eq , Show , Typeable , Generic )
1153
- instance Hashable IsHiFileStable
1154
- instance NFData IsHiFileStable
1155
-
1156
- type instance RuleResult IsHiFileStable = SourceModified
0 commit comments