Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #10 from afcowie/file-names

Add entry for file names
  • Loading branch information...
commit 7d571b65a878a542ef561a88418b3b4f77b721a3 2 parents 7a43e82 + dfcff0a
@luqui authored
Showing with 13 additions and 3 deletions.
  1. +12 −3 Main.hs
  2. +1 −0  hothasktags.cabal
View
15 Main.hs
@@ -10,6 +10,7 @@ import qualified Language.Preprocessor.Cpphs as CPP
import Control.Monad (forM, when)
import Data.List (sort)
import Data.Maybe (fromMaybe)
+import System.FilePath.Posix (takeFileName)
type Database = Map.Map String (L.Module L.SrcSpanInfo)
@@ -119,11 +120,19 @@ 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 _) = moduleItself modhead `Map.union` localDecls mod `Map.union` Map.unions (map extractImport imports)
+moduleScope db mod@(L.Module _ modhead _ imports _) = moduleItself `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
+ moduleItself = moduleDecl modhead `Map.union` enclosingFilename mod
+
+ moduleDecl (Just (L.ModuleHead l (L.ModuleName _ name) _ _)) = Map.singleton name (getLoc l)
+ moduleDecl _ = Map.empty
+
+ enclosingFilename (L.Module l _ _ _ _) = Map.singleton (filename l) (getLoc l)
+ enclosingFilename _ = Map.empty
+
+ filename (L.SrcSpanInfo (L.SrcSpan file _ _ _ _) _) = takeFileName file
+
extractImport decl@(L.ImportDecl { L.importModule = L.ModuleName _ name, L.importSpecs = spec }) =
Map.unions [
if L.importQualified decl then Map.empty else names,
View
1  hothasktags.cabal
@@ -30,6 +30,7 @@ executable hothasktags
build-depends:
base == 4.*,
containers,
+ filepath,
haskell-src-exts >= 1.11 && < 1.14,
cpphs >= 1.11 && < 1.15
main-is: Main.hs
Please sign in to comment.
Something went wrong with that request. Please try again.