- globals = typeEnvIds (md_types (hm_details hmi))
- Just decl = find (\n -> nameSrcSpan n < span)
- (reverse $ map idName globals)
- -- ^^ assumes md_types is sorted
- in decl
-
--- | Finds the span of the (smallest) function containing this BreakIndex
-findEnclosingDeclSpanByTick :: HscEnv -> Module -> BreakIndex -> SrcSpan
-findEnclosingDeclSpanByTick hsc_env mod tick =
- case lookupUFM (hsc_HPT hsc_env) (moduleName mod) of
- Nothing -> panic "findEnclosingDecl"
- Just hmi -> let
- modbreaks = md_modBreaks (hm_details hmi)
- in ASSERT (inRange (bounds modBreaks) tick)
- modBreaks_decls modbreaks ! tick
-
--- | Find the Module corresponding to a FilePath
-findModuleFromFile :: HscEnv -> FilePath -> Maybe Module
-findModuleFromFile hsc_env fp =
- listToMaybe $ [ms_mod ms | ms <- hsc_mod_graph hsc_env
- , ml_hs_file(ms_location ms) == Just (read fp)]
-
+ globals = typeEnvIds (md_types (hm_details hmi))
+ Just decl =
+ find (\id -> let n = idName id in
+ nameSrcSpan n < span && isExternalName n)
+ (reverse$ sortBy (compare `on` (nameSrcSpan.idName))
+ globals)
+ in decl