aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock
diff options
context:
space:
mode:
Diffstat (limited to 'haddock-api/src/Haddock')
-rw-r--r--haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs20
1 files changed, 19 insertions, 1 deletions
diff --git a/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs b/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
index 19ebbe77..2325aa21 100644
--- a/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
+++ b/haddock-api/src/Haddock/Backends/Hyperlinker/Ast.hs
@@ -36,7 +36,12 @@ enrich src =
, rtkDetails = lookupBySpan (tkSpan token) detailsMap
}
where
- detailsMap = variables src ++ types src ++ binds src
+ detailsMap = concat
+ [ variables src
+ , types src
+ , binds src
+ , imports src
+ ]
type DetailsMap = [(GHC.SrcSpan, TokenDetails)]
@@ -81,6 +86,19 @@ binds =
pure (sspan, TokenDetails RtkBind name)
_ -> empty
+imports :: GHC.RenamedSource -> DetailsMap
+imports =
+ everything (<|>) ie
+ where
+ ie term = case cast term of
+ (Just (GHC.IEVar v)) -> pure $ var v
+ (Just (GHC.IEThingAbs t)) -> pure $ typ t
+ (Just (GHC.IEThingAll t)) -> pure $ typ t
+ (Just (GHC.IEThingWith t vs)) -> [typ t] ++ map var vs
+ _ -> empty
+ typ (GHC.L sspan name) = (sspan, TokenDetails RtkType name)
+ var (GHC.L sspan name) = (sspan, TokenDetails RtkVar name)
+
matches :: Span -> GHC.SrcSpan -> Bool
matches tspan (GHC.RealSrcSpan aspan)
| rs && cs && re && ce = True