Skip to content

Commit

Permalink
Remove GeneratedInfo from HieAST before generating references map
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrcek committed Jul 10, 2024
1 parent 8d58bc2 commit 90aa85b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/HieDb/Create.hs
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,20 @@ addRefsFromLoaded_unsafe
mod = moduleName smod
uid = moduleUnit smod
smod = hie_module hf
refmap = generateReferencesMap $ getAsts $ hie_asts hf
refmap = generateReferencesMap $ fmap dropGeneratedInfo $ getAsts $ hie_asts hf
(srcFile, isReal) = case sourceFile of
RealFile f -> (Just f, True)
FakeFile mf -> (mf, False)
modrow = HieModuleRow path (ModuleInfo mod uid isBoot srcFile isReal hash)

-- We only want to index references to things that actually occur in source code
-- (i.e. NodeOrigin is SourceInfo, not GeneratedInfo).
-- So before generating RefMap we drop all GeneratedInfo from the AST.
dropGeneratedInfo :: HieAST a -> HieAST a
dropGeneratedInfo (Node (SourcedNodeInfo sniMap) sp children) =
let sourceOnlyNodeInfo = SourcedNodeInfo $ M.delete GeneratedInfo sniMap
in Node sourceOnlyNodeInfo sp (map dropGeneratedInfo children)

execute conn "INSERT INTO mods VALUES (?,?,?,?,?,?,?)" modrow

let AstInfo rows decls imports = genAstInfo path smod refmap
Expand Down

0 comments on commit 90aa85b

Please sign in to comment.