Permalink
Browse files

Add an entry for the name of the module itself

  • Loading branch information...
1 parent 98d3fa3 commit 761b0babf83f2329cddc59811059f2719cd8c289 @afcowie afcowie committed Jan 18, 2013
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 761b0ba

Please sign in to comment.