Skip to content

Commit b211bc5

Browse files
committed
wip
1 parent 07d7583 commit b211bc5

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

ghcide/src/Development/IDE/GHC/Compat/Core.hs

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ module Development.IDE.GHC.Compat.Core (
8686
loadInterface,
8787
SourceModified(..),
8888
loadModuleInterface,
89+
Warnings(..),
8990
RecompileRequired(..),
9091
#if MIN_VERSION_ghc(8,10,0)
9192
mkPartialIface,
@@ -614,6 +615,7 @@ import GHC.Unit.Module.ModGuts
614615
import GHC.Unit.Module.ModIface (IfaceExport, ModIface (..),
615616
ModIface_ (..))
616617
import GHC.Unit.Module.ModSummary (ModSummary (..))
618+
import GHC.Unit.Module.Warnings (Warnings (..))
617619
#endif
618620
import GHC.Unit.State (ModuleOrigin (..))
619621
import GHC.Utils.Error (Severity (..))

ghcide/src/Development/IDE/Types/Exports.hs

+16-10
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ createExportsMap modIface = do
119119
ExportsMap exportsMap $ buildModuleExportMap $ map (\(_,b,c) -> (b, c)) exportList
120120
where
121121
doOne modIFace = do
122-
let getModDetails = unpackAvail $ moduleName $ mi_module modIFace
122+
let getModDetails = unpackAvail (moduleName $ mi_module modIFace) (mi_warns modIFace)
123123
concatMap (fmap (second Set.fromList) . getModDetails) (mi_exports modIFace)
124124

125125
createExportsMapMg :: [ModGuts] -> ExportsMap
@@ -129,8 +129,8 @@ createExportsMapMg modGuts = do
129129
ExportsMap exportsMap $ buildModuleExportMap $ map (\(_,b,c) -> (b, c)) exportList
130130
where
131131
doOne mi = do
132-
let getModuleName = moduleName $ mg_module mi
133-
concatMap (fmap (second Set.fromList) . unpackAvail getModuleName) (mg_exports mi)
132+
let getModDetails = unpackAvail (moduleName $ mg_module mi) (mg_warns mi)
133+
concatMap (fmap (second Set.fromList) . getModDetails) (mg_exports mi)
134134

135135
updateExportsMapMg :: [ModGuts] -> ExportsMap -> ExportsMap
136136
updateExportsMapMg modGuts old = old' <> new
@@ -139,15 +139,15 @@ updateExportsMapMg modGuts old = old' <> new
139139
old' = deleteAll old (Map.keys $ getModuleExportsMap new)
140140
deleteAll = foldl' (flip deleteEntriesForModule)
141141

142-
nonInternalModules :: ModuleName -> Bool
143-
nonInternalModules = not . (".Internal" `isSuffixOf`) . moduleNameString
142+
isInternalModule :: ModuleName -> Bool
143+
isInternalModule= (".Internal" `isSuffixOf`) . moduleNameString
144144

145145
type WithHieDb = forall a. (HieDb -> IO a) -> IO a
146146

147147
createExportsMapHieDb :: WithHieDb -> IO ExportsMap
148148
createExportsMapHieDb withHieDb = do
149149
mods <- withHieDb getAllIndexedMods
150-
idents <- forM (filter (nonInternalModules . modInfoName . hieModInfo) mods) $ \m -> do
150+
idents <- forM (filter (not . isInternalModule . modInfoName . hieModInfo) mods) $ \m -> do
151151
let mn = modInfoName $ hieModInfo m
152152
mText = pack $ moduleNameString mn
153153
fmap (wrap . unwrap mText) <$> withHieDb (\hieDb -> getExportsForModule hieDb mn)
@@ -161,10 +161,16 @@ createExportsMapHieDb withHieDb = do
161161
n = pack (occNameString exportName)
162162
p = pack . occNameString <$> exportParent
163163

164-
unpackAvail :: ModuleName -> IfaceExport -> [(Text, Text, [IdentInfo])]
165-
unpackAvail mn
166-
| nonInternalModules mn = map f . mkIdentInfos mod
167-
| otherwise = const []
164+
unpackAvail :: ModuleName -> Warnings -> IfaceExport -> [(Text, Text, [IdentInfo])]
165+
unpackAvail mn warnings
166+
| isInternalModule mn = const []
167+
| otherwise = case warnings of
168+
NoWarnings -> map f . mkIdentInfos mod
169+
WarnAll {} -> const []
170+
WarnSome deprThings -> do
171+
let deprNames = Set.fromList $ fst <$> deprThings
172+
notDeprecated = not . flip Set.member deprNames
173+
map f . filter (notDeprecated . name) . mkIdentInfos mod
168174
where
169175
!mod = pack $ moduleNameString mn
170176
f id@IdentInfo {..} = (printOutputable name, moduleNameText,[id])

0 commit comments

Comments
 (0)