@@ -52,7 +52,7 @@ getSrcSpanInfos
52 -> [(Located ModuleName, Maybe NormalizedFilePath)]
52 -> [(Located ModuleName, Maybe NormalizedFilePath)]
53 -> TcModuleResult
53 -> TcModuleResult
54 -> [TcModuleResult]
54 -> [TcModuleResult]
55− -> IO [SpanInfo]
55+ -> IO SpansInfo
56getSrcSpanInfos env imports tc tms =
56getSrcSpanInfos env imports tc tms =
57 runGhcEnv env $
57 runGhcEnv env $
58 getSpanInfo imports (tmrModule tc) (map tmrModule tms)
58 getSpanInfo imports (tmrModule tc) (map tmrModule tms)
@@ -62,7 +62,7 @@ getSpanInfo :: GhcMonad m
62 => [(Located ModuleName, Maybe NormalizedFilePath)] -- ^ imports
62 => [(Located ModuleName, Maybe NormalizedFilePath)] -- ^ imports
63 -> TypecheckedModule
63 -> TypecheckedModule
64 -> [TypecheckedModule]
64 -> [TypecheckedModule]
65− -> m [SpanInfo]
65+ -> m SpansInfo
66getSpanInfo mods tcm tcms =
66getSpanInfo mods tcm tcms =
67 do let tcs = tm_typechecked_source tcm
67 do let tcs = tm_typechecked_source tcm
68 bs = listifyAllSpans tcs :: [LHsBind GhcTc]
68 bs = listifyAllSpans tcs :: [LHsBind GhcTc]
@@ -78,13 +78,16 @@ getSpanInfo mods tcm tcms =
78 let imports = importInfo mods
78 let imports = importInfo mods
79 let exports = getExports tcm
79 let exports = getExports tcm
80 let exprs = addEmptyInfo exports ++ addEmptyInfo imports ++ concat bts ++ concat tts ++ catMaybes (ets ++ pts)
80 let exprs = addEmptyInfo exports ++ addEmptyInfo imports ++ concat bts ++ concat tts ++ catMaybes (ets ++ pts)
81+ let constraints = map constraintToInfo (concatMap getConstraintsLHsBind bs)
81− return (mapMaybe toSpanInfo (sortBy cmp exprs))
82+ return $ SpansInfo (mapMaybe toSpanInfo (sortBy cmp exprs))
83+ (mapMaybe toSpanInfo (sortBy cmp constraints))
82 where cmp (_,a,_,_) (_,b,_,_)
84 where cmp (_,a,_,_) (_,b,_,_)
83 | a `isSubspanOf` b = LT
85 | a `isSubspanOf` b = LT
84 | b `isSubspanOf` a = GT
86 | b `isSubspanOf` a = GT
85 | otherwise = compare (srcSpanStart a) (srcSpanStart b)
87 | otherwise = compare (srcSpanStart a) (srcSpanStart b)
87 addEmptyInfo = map (\(a,b) -> (a,b,Nothing,emptySpanDoc))
89 addEmptyInfo = map (\(a,b) -> (a,b,Nothing,emptySpanDoc))
90+ constraintToInfo (sp, ty) = (SpanS sp, sp, Just ty, emptySpanDoc)
89-- | The locations in the typechecked module are slightly messed up in some cases (e.g. HsMatchContext always
92-- | The locations in the typechecked module are slightly messed up in some cases (e.g. HsMatchContext always
90-- points to the first match) whereas the parsed module has the correct locations.
93-- points to the first match) whereas the parsed module has the correct locations.
@@ -130,6 +133,13 @@ getTypeLHsBind tms _ (L _spn FunBind{fun_id = pid,fun_matches = MG{}}) = do
130 return [(Named name, getLoc pid, Just (varType (unLoc pid)), docs)]
133 return [(Named name, getLoc pid, Just (varType (unLoc pid)), docs)]
131getTypeLHsBind _ _ _ = return []
134getTypeLHsBind _ _ _ = return []
136+-- | Get information about constraints
137+getConstraintsLHsBind :: LHsBind GhcTc
138+ -> [(SrcSpan, Type)]
139+getConstraintsLHsBind (L spn AbsBinds { abs_ev_vars = vars })
140+ = map (\v -> (spn, varType v)) vars
141+getConstraintsLHsBind _ = []
133-- | Get the name and type of an expression.
143-- | Get the name and type of an expression.
134getTypeLHsExpr :: (GhcMonad m)
144getTypeLHsExpr :: (GhcMonad m)
135 => [TypecheckedModule]
145 => [TypecheckedModule]