@@ -232,12 +232,20 @@ handleGetHieAst state nfp =
232
232
-- | We don't want to rename in code generated by GHC as this gives false positives.
233
233
-- So we restrict the HIE file to remove all the generated code.
234
234
removeGenerated :: HieAstResult -> HieAstResult
235
- removeGenerated HAR {.. } = HAR {hieAst = go hieAst, .. }
235
+ removeGenerated HAR {.. } = HAR {hieAst = sourceOnlyAsts, refMap = sourceOnlyRefMap, .. }
236
236
where
237
- go :: HieASTs a -> HieASTs a
238
- go hf =
239
- HieASTs (fmap goAst (getAsts hf))
240
- goAst (Node nsi sp xs) = Node (SourcedNodeInfo $ M. restrictKeys (getSourcedNodeInfo nsi) (S. singleton SourceInfo )) sp (map goAst xs)
237
+ goAsts :: HieASTs a -> HieASTs a
238
+ goAsts (HieASTs asts) = HieASTs (fmap goAst asts)
239
+
240
+ goAst :: HieAST a -> HieAST a
241
+ goAst (Node (SourcedNodeInfo sniMap) sp children) =
242
+ let sourceOnlyNodeInfos = SourcedNodeInfo $ M. delete GeneratedInfo sniMap
243
+ in Node sourceOnlyNodeInfos sp $ map goAst children
244
+
245
+ sourceOnlyAsts = goAsts hieAst
246
+ -- Also need to regenerate the RefMap, because the one in HAR
247
+ -- is generated from HieASTs containing GeneratedInfo
248
+ sourceOnlyRefMap = Compat. generateReferencesMap $ Compat. getAsts sourceOnlyAsts
241
249
242
250
collectWith :: (Hashable a , Eq b ) => (a -> b ) -> HashSet a -> [(b , HashSet a )]
243
251
collectWith f = map (\ (a :| as) -> (f a, HS. fromList (a: as))) . groupWith f . HS. toList
0 commit comments