From d275f87c4cfa1e8da042f70659331121afa9a15c Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Sat, 6 Jun 2015 19:27:37 +0200 Subject: Create scaffolding of module for associating tokens with AST names. --- haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs (limited to 'haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs') diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs new file mode 100644 index 00000000..abd3ca2b --- /dev/null +++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs @@ -0,0 +1,20 @@ +module Haddock.Backends.Hyperlinker.Ast where + +import qualified GHC + +import Haddock.Backends.Hyperlinker.Parser + +data RichToken = RichToken + { rtkToken :: Token + , rtkName :: Maybe GHC.Name + } + +enrich :: GHC.RenamedSource -> [Token] -> [RichToken] +enrich src = + map $ \token -> RichToken + { rtkToken = token + , rtkName = lookupName src $ tkSpan token + } + +lookupName :: GHC.RenamedSource -> Span -> Maybe GHC.Name +lookupName = undefined -- cgit v1.2.3