Skip to content
Browse files

Merge pull request #9 from afcowie/module-names

Add an entry for the name of the module itself
  • Loading branch information...
2 parents 98d3fa3 + 761b0ba commit 7a43e82fa6147955bcbba1204c40a5bbf10f34fa @luqui committed
Showing with 7 additions and 2 deletions.
  1. +7 −2 Main.hs
View
9 Main.hs
@@ -63,9 +63,11 @@ localDecls (L.Module _ _ _ _ decls) = Map.fromList $ concatMap extract decls
extractName (L.Ident loc name) = [(name, getLoc loc)]
extractName (L.Symbol _ _) = [] -- no symbols for now
- getLoc (L.SrcSpanInfo (L.SrcSpan file line _ _ _) _) = Defn file line
localDecls _ = Map.empty
+getLoc :: L.SrcSpanInfo -> Defn
+getLoc (L.SrcSpanInfo (L.SrcSpan file line _ _ _) _) = Defn file line
+
thingMembers :: L.Module L.SrcSpanInfo -> String -> [String]
thingMembers (L.Module _ _ _ _ decls) name = concatMap extract decls
where
@@ -117,8 +119,11 @@ exported mod@(L.Module _ (Just (L.ModuleHead _ _ _ (Just (L.ExportSpecList _ spe
exported _ _ = True
moduleScope :: Database -> L.Module L.SrcSpanInfo -> Map.Map String Defn
-moduleScope db mod@(L.Module _ modhead _ imports _) = localDecls mod `Map.union` Map.unions (map extractImport imports)
+moduleScope db mod@(L.Module _ modhead _ imports _) = moduleItself modhead `Map.union` localDecls mod `Map.union` Map.unions (map extractImport imports)
where
+ moduleItself (Just (L.ModuleHead l (L.ModuleName _ name) _ _)) = Map.singleton name (getLoc l)
+ moduleItself _ = Map.empty
+
extractImport decl@(L.ImportDecl { L.importModule = L.ModuleName _ name, L.importSpecs = spec }) =
Map.unions [
if L.importQualified decl then Map.empty else names,

0 comments on commit 7a43e82

Please sign in to comment.
Something went wrong with that request. Please try again.