aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
diff options
context:
space:
mode:
Diffstat (limited to 'haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs')
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs21
1 files changed, 16 insertions, 5 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
index 2749096e..39bbacf5 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
@@ -28,6 +28,7 @@ data RichTokenType
= RtkVar
| RtkType
| RtkBind
+ | RtkDecl
enrich :: GHC.RenamedSource -> [Token] -> [RichToken]
enrich src =
@@ -36,11 +37,12 @@ enrich src =
, rtkDetails = enrichToken token detailsMap
}
where
- detailsMap = concat
- [ variables src
- , types src
- , binds src
- , imports src
+ detailsMap = concatMap ($ src)
+ [ variables
+ , types
+ , binds
+ , imports
+ , decls
]
type DetailsMap = [(GHC.SrcSpan, TokenDetails)]
@@ -91,6 +93,15 @@ binds =
pure (sspan, TokenDetails RtkBind name)
_ -> empty
+decls :: GHC.RenamedSource -> DetailsMap
+decls (group, _, _, _) = concatMap ($ group)
+ [ map typ . concat . map GHC.group_tyclds . GHC.hs_tyclds
+ ]
+ where
+ typ (GHC.L _ t) =
+ let (GHC.L sspan name) = GHC.tcdLName t
+ in (sspan, TokenDetails RtkDecl name)
+
imports :: GHC.RenamedSource -> DetailsMap
imports =
everything (<|>) ie