Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
pepeiborra committed Jun 17, 2020
1 parent 56cb08f commit 871d2d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Development/IDE/Core/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ getModSummaryFromImports fp contents = do
-- To avoid silent issues where something is not processed because the date
-- has not changed, we make sure that things blow up if they depend on the date.
, ms_hsc_src = sourceType
-- The contents are used by the GetModSummary rule
, ms_hspp_buf = Just contents
, ms_hspp_file = fp
, ms_hspp_opts = dflags
Expand Down
20 changes: 16 additions & 4 deletions src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -651,19 +651,29 @@ getModSummaryRule = defineEarlyCutoff $ \GetModSummary f -> do
modS <- liftIO $ evalWithDynFlags dflags $ runExceptT $
getModSummaryFromImports (fromNormalizedFilePath f) (textToStringBuffer <$> mFileContent)
case modS of
Right ms@ModSummary{..} -> do
Right ms -> do
-- Clear the contents as no longer needed
let !ms' = ms{ms_hspp_buf=Nothing}
return ( Just (computeFingerprint dflags ms), ([], Just ms'))
Left diags -> return (Nothing, (diags, Nothing))
where
-- Compute a fingerprint from the contents of `ModSummary`,
-- eliding the timestamps and other non relevant fields.
computeFingerprint dflags ModSummary{..} =
let fingerPrint =
( moduleNameString (moduleName ms_mod)
, ms_hsc_src
, ms_hspp_file
, map unLoc opts
, ml_hs_file ms_location
, ms_iface_date
, fingerPrintImports ms_srcimps
, fingerPrintImports ms_textual_imps
, map unLoc opts
)
fingerPrintImports = map (fmap uniq *** (moduleNameString . unLoc))
opts = Hdr.getOptions dflags (fromJust ms_hspp_buf) (fromNormalizedFilePath f)
fp = hash fingerPrint
return ( Just (BS.pack $ show fp), ([], Just ms{ms_hspp_buf=Nothing}))
Left diags -> return (Nothing, (diags, Nothing))
in BS.pack (show fp)

getModIfaceRule :: Rules ()
getModIfaceRule = define $ \GetModIface f -> do
Expand Down Expand Up @@ -702,6 +712,8 @@ getModIfaceRule = define $ \GetModIface f -> do
case mb_pm of
Nothing -> return (diags, Nothing)
Just pm -> do
-- We want GhcSessionDeps cache objects only for files of interest
-- As that's no the case here, call the implementation directly
(diags, mb_hsc) <- ghcSessionDepsDefinition f
case mb_hsc of
Nothing -> return (diags, Nothing)
Expand Down

0 comments on commit 871d2d1

Please sign in to comment.