Skip to content

Commit

Permalink
Fix Eval plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pepeiborra committed Nov 12, 2021
1 parent 9d6ba9e commit ef370d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion ghcide/src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -686,11 +686,13 @@ loadGhcSession ghcSessionDepsConfig = do
data GhcSessionDepsConfig = GhcSessionDepsConfig
{ checkForImportCycles :: Bool
, forceLinkables :: Bool
, fullModSummary :: Bool
}
instance Default GhcSessionDepsConfig where
def = GhcSessionDepsConfig
{ checkForImportCycles = True
, forceLinkables = False
, fullModSummary = False
}

ghcSessionDepsDefinition :: GhcSessionDepsConfig -> HscEnvEq -> NormalizedFilePath -> Action (Maybe HscEnvEq)
Expand All @@ -702,7 +704,9 @@ ghcSessionDepsDefinition GhcSessionDepsConfig{..} env file = do
Nothing -> return Nothing
Just deps -> do
when checkForImportCycles $ void $ uses_ ReportImportCycles deps
ms:mss <- map msrModSummary <$> uses_ GetModSummaryWithoutTimestamps (file:deps)
ms:mss <- map msrModSummary <$> if fullModSummary
then uses_ GetModSummary (file:deps)
else uses_ GetModSummaryWithoutTimestamps (file:deps)

depSessions <- map hscEnv <$> uses_ GhcSessionDeps deps
let uses_th_qq =
Expand Down
9 changes: 7 additions & 2 deletions plugins/hls-eval-plugin/src/Ide/Plugin/Eval/CodeLens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import Development.IDE (GetModSummary (..),
ModSummaryResult (..),
NeedsCompilation (NeedsCompilation),
evalGhcEnv, hscEnv,
hscEnvWithImportPaths,
prettyPrint, runAction,
textToStringBuffer,
toNormalizedFilePath',
Expand Down Expand Up @@ -538,8 +539,12 @@ runGetSession st nfp = liftIO $ runAction "eval" st $ do
let fp = fromNormalizedFilePath nfp
((_, res),_) <- liftIO $ loadSessionFun fp
let env = fromMaybe (error $ "Unknown file: " <> fp) res
ghcSessionDepsConfig = def{forceLinkables = True, checkForImportCycles = False}
res <- fmap hscEnv <$> ghcSessionDepsDefinition ghcSessionDepsConfig env nfp
ghcSessionDepsConfig = def
{ forceLinkables = True
, checkForImportCycles = False
, fullModSummary = True
}
res <- fmap hscEnvWithImportPaths <$> ghcSessionDepsDefinition ghcSessionDepsConfig env nfp
return $ fromMaybe (error $ "Unable to load file: " <> fp) res

needsQuickCheck :: [(Section, Test)] -> Bool
Expand Down

0 comments on commit ef370d5

Please sign in to comment.