From 0efbabb018e952a63a12d3b6480e21f9b1090764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Sat, 11 Dec 2021 16:02:15 +0100 Subject: [PATCH 1/2] Handle re-exported modules when constructing ExportsMap --- ghcide/src/Development/IDE/Types/HscEnvEq.hs | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ghcide/src/Development/IDE/Types/HscEnvEq.hs b/ghcide/src/Development/IDE/Types/HscEnvEq.hs index 0383ffc59e..3900ea47a0 100644 --- a/ghcide/src/Development/IDE/Types/HscEnvEq.hs +++ b/ghcide/src/Development/IDE/Types/HscEnvEq.hs @@ -76,22 +76,25 @@ newHscEnvEqWithImportPaths envImportPaths hscEnv deps = do -- compute the package imports let pkgst = unitState hscEnv depends = explicitUnits pkgst - targets = - [ (pkg, mn) + modules = + [ m | d <- depends , Just pkg <- [lookupPackageConfig d hscEnv] - , (mn, _) <- unitExposedModules pkg + , (modName, maybeOtherPkgMod) <- unitExposedModules pkg + , m <- pure $ case maybeOtherPkgMod of + -- When module is re-exported from another package, + -- the origin module is represented by value in Just + Just otherPkgMod -> otherPkgMod + Nothing -> mkModule (unitInfoId pkg) modName ] - doOne (pkg, mn) = do - modIface <- liftIO $ initIfaceLoad hscEnv $ loadInterface - "" - (mkModule (unitInfoId pkg) mn) - (ImportByUser NotBoot) + doOne m = do + modIface <- initIfaceLoad hscEnv $ + loadInterface "" m (ImportByUser NotBoot) return $ case modIface of Maybes.Failed _r -> Nothing Maybes.Succeeded mi -> Just mi - modIfaces <- mapMaybeM doOne targets + modIfaces <- mapMaybeM doOne modules return $ createExportsMap modIfaces -- similar to envPackageExports, evaluated lazily From 08f039fdf398ac40b8272f7de9b889c4b3af8d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hr=C4=8Dek?= Date: Sat, 11 Dec 2021 16:10:14 +0100 Subject: [PATCH 2/2] Remove unused import, use let --- ghcide/src/Development/IDE/Types/HscEnvEq.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ghcide/src/Development/IDE/Types/HscEnvEq.hs b/ghcide/src/Development/IDE/Types/HscEnvEq.hs index 3900ea47a0..d175bb884d 100644 --- a/ghcide/src/Development/IDE/Types/HscEnvEq.hs +++ b/ghcide/src/Development/IDE/Types/HscEnvEq.hs @@ -16,7 +16,6 @@ import Control.Concurrent.Strict (modifyVar, newVar) import Control.DeepSeq (force) import Control.Exception (evaluate, mask, throwIO) import Control.Monad.Extra (eitherM, join, mapMaybeM) -import Control.Monad.IO.Class import Data.Either (fromRight) import Data.Set (Set) import qualified Data.Set as Set @@ -81,11 +80,11 @@ newHscEnvEqWithImportPaths envImportPaths hscEnv deps = do | d <- depends , Just pkg <- [lookupPackageConfig d hscEnv] , (modName, maybeOtherPkgMod) <- unitExposedModules pkg - , m <- pure $ case maybeOtherPkgMod of - -- When module is re-exported from another package, - -- the origin module is represented by value in Just - Just otherPkgMod -> otherPkgMod - Nothing -> mkModule (unitInfoId pkg) modName + , let m = case maybeOtherPkgMod of + -- When module is re-exported from another package, + -- the origin module is represented by value in Just + Just otherPkgMod -> otherPkgMod + Nothing -> mkModule (unitInfoId pkg) modName ] doOne m = do