@@ -28,6 +28,7 @@ import Idris.Inliner
2828import Idris.CaseSplit
2929import Idris.DeepSeq
3030import Idris.Output
31+import Idris.WhoCalls
3132
3233import Paths_idris
3334import Version_idris (gitHash)
@@ -275,11 +276,6 @@ runIdeSlaveCommand id orig fn mods (IdeSlave.DocsFor name) =
275276 case splitName name of
276277 Left err -> iPrintError err
277278 Right n -> process stdout "(ideslave)" (DocStr n)
278− where splitName :: String -> Either String Name
279− splitName s = case reverse $ splitOn "." s of
280− [] -> Left ("Didn't understand name '" ++ s ++ "'")
281− [n] -> Right $ sUN n
282− (n:ns) -> Right $ sNS (sUN n) ns
283279runIdeSlaveCommand id orig fn mods (IdeSlave.CaseSplit line name) =
284280 process stdout fn (CaseSplitAt False line (sUN name))
285281runIdeSlaveCommand id orig fn mods (IdeSlave.AddClause line name) =
@@ -342,7 +338,36 @@ runIdeSlaveCommand id orig fn mods (IdeSlave.Metavariables cols) =
342338 pprintPTerm imp (zip ns (repeat False)) [] t
343339 rest = sexpGoal ist cols imp (n:ns) (ps, concl)
344340 in ((n', t', spans) : fst rest, snd rest)
345−
341+runIdeSlaveCommand id orig fn mods (IdeSlave.WhoCalls n) =
342+ case splitName n of
343+ Left err -> iPrintError err
344+ Right n -> do calls <- whoCalls n
345+ ist <- getIState
346+ let msg = (IdeSlave.SymbolAtom "ok",
347+ map (\ (n,ns) -> (pn ist n, map (pn ist) ns)) calls)
348+ runIO . putStrLn $ IdeSlave.convSExp "return" msg id
349+ where pn ist = displaySpans .
350+ renderPretty 0.9 1000 .
351+ fmap (fancifyAnnots ist) .
352+ prettyName True []
353+runIdeSlaveCommand id orig fn mods (IdeSlave.CallsWho n) =
354+ case splitName n of
355+ Left err -> iPrintError err
356+ Right n -> do calls <- callsWho n
357+ ist <- getIState
358+ let msg = (IdeSlave.SymbolAtom "ok",
359+ map (\ (n,ns) -> (pn ist n, map (pn ist) ns)) calls)
360+ runIO . putStrLn $ IdeSlave.convSExp "return" msg id
361+ where pn ist = displaySpans .
362+ renderPretty 0.9 1000 .
363+ fmap (fancifyAnnots ist) .
364+ prettyName True []
365+
366+splitName :: String -> Either String Name
367+splitName s = case reverse $ splitOn "." s of
368+ [] -> Left ("Didn't understand name '" ++ s ++ "'")
369+ [n] -> Right $ sUN n
370+ (n:ns) -> Right $ sNS (sUN n) ns
346371
347372ideslaveProcess :: FilePath -> Command -> Idris ()
348373ideslaveProcess fn Help = process stdout fn Help
@@ -405,6 +430,8 @@ ideslaveProcess fn (SetConsoleWidth w) = do process stdout fn (SetConsoleWidth w
405430 iPrintResult ""
406431ideslaveProcess fn (Apropos a) = do process stdout fn (Apropos a)
407432 iPrintResult ""
433+ideslaveProcess fn (WhoCalls n) = process stdout fn (WhoCalls n)
434+ideslaveProcess fn (CallsWho n) = process stdout fn (CallsWho n)
408435ideslaveProcess fn _ = iPrintError "command not recognized or not supported"
409436
410437
@@ -1041,6 +1068,24 @@ process h fn (Apropos a) =
10411068 isUN (NS n _) = isUN n
10421069 isUN _ = False
10431070
1071+process h fn (WhoCalls n) =
1072+ do calls <- whoCalls n
1073+ ist <- getIState
1074+ ihRenderResult h . vsep $
1075+ map (\(n, ns) ->
1076+ text "Callers of" <+> prettyName True [] n <$>
1077+ indent 1 (vsep (map ((text "*" <+>) . align . prettyName True []) ns)))
1078+ calls
1079+
1080+process h fn (CallsWho n) =
1081+ do calls <- callsWho n
1082+ ist <- getIState
1083+ ihRenderResult h . vsep $
1084+ map (\(n, ns) ->
1085+ prettyName True [] n <+> text "calls:" <$>
1086+ indent 1 (vsep (map ((text "*" <+>) . align . prettyName True []) ns)))
1087+ calls
1088+
10441089classInfo :: ClassInfo -> Idris (Doc OutputAnnotation)
10451090classInfo ci = do ist <- getIState
10461091 ctxt <- getContext