Skip to content

Commit 4650063

Browse files
committed
Remove IsHiFileStable rule
1 parent a89df8a commit 4650063

File tree

2 files changed

+8
-42
lines changed

2 files changed

+8
-42
lines changed

Diff for: ghcide/src/Development/IDE.hs

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import Development.IDE.Core.IdeConfiguration as X (IdeConfiguration (.
1717
isWorkspaceFile)
1818
import Development.IDE.Core.OfInterest as X (getFilesOfInterestUntracked)
1919
import Development.IDE.Core.RuleTypes as X
20-
import Development.IDE.Core.Rules as X (IsHiFileStable (..),
21-
getClientConfigAction,
20+
import Development.IDE.Core.Rules as X (getClientConfigAction,
2221
getParsedModule)
2322
import Development.IDE.Core.Service as X (runAction)
2423
import Development.IDE.Core.Shake as X (FastResult (..),

Diff for: ghcide/src/Development/IDE/Core/Rules.hs

+7-40
Original file line numberDiff line numberDiff line change
@@ -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,
@@ -150,6 +148,7 @@ import Control.Concurrent.STM.Stats (atomically)
150148
import Language.LSP.Server (LspT)
151149
import System.Info.Extra (isWindows)
152150
import HIE.Bios.Ghc.Gap (hostIsDynamic)
151+
import qualified Development.IDE.Types.Shake as Shake
153152

154153
templateHaskellInstructions :: T.Text
155154
templateHaskellInstructions = "https://haskell-language-server.readthedocs.io/en/latest/troubleshooting.html#static-binaries"
@@ -743,14 +742,18 @@ ghcSessionDepsDefinition fullModSummary GhcSessionDepsConfig{..} env file = do
743742
-- | Load a iface from disk, or generate it if there isn't one or it is out of date
744743
-- This rule also ensures that the `.hie` and `.o` (if needed) files are written out.
745744
getModIfaceFromDiskRule :: Rules ()
746-
getModIfaceFromDiskRule = defineEarlyCutoff $ Rule $ \GetModIfaceFromDisk f -> do
745+
getModIfaceFromDiskRule = defineEarlyCutoff $ RuleWithOldValue $ \GetModIfaceFromDisk f old -> do
747746
ms <- msrModSummary <$> use_ GetModSummary f
748747
mb_session <- use GhcSessionDeps f
749748
case mb_session of
750749
Nothing -> return (Nothing, ([], Nothing))
751750
Just session -> do
752-
sourceModified <- use_ IsHiFileStable f
753751
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
754757
r <- loadInterface (hscEnv session) ms sourceModified linkableType (regenerateHiFile session f ms)
755758
case r of
756759
(diags, Nothing) -> return (Nothing, (diags, Nothing))
@@ -802,31 +805,6 @@ getModIfaceFromDiskAndIndexRule =
802805

803806
return (Just x)
804807

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-
830808
displayTHWarning :: LspT c IO ()
831809
displayTHWarning
832810
| not isWindows && not hostIsDynamic = do
@@ -1122,7 +1100,6 @@ mainRule RulesConfig{..} = do
11221100
getModIfaceFromDiskAndIndexRule
11231101
getModIfaceRule
11241102
getModSummaryRule
1125-
isHiFileStableRule
11261103
getModuleGraphRule
11271104
knownFilesRule
11281105
getClientSettingsRule
@@ -1144,13 +1121,3 @@ mainRule RulesConfig{..} = do
11441121
persistentHieFileRule
11451122
persistentDocMapRule
11461123
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

Comments
 (0)