@@ -28,6 +28,7 @@ import Idris.Inliner
28import Idris.CaseSplit
28import Idris.CaseSplit
29import Idris.DeepSeq
29import Idris.DeepSeq
30import Idris.Output
30import Idris.Output
32import Paths_idris
33import Paths_idris
33import Version_idris (gitHash)
34import Version_idris (gitHash)
@@ -275,11 +276,6 @@ runIdeSlaveCommand id orig fn mods (IdeSlave.DocsFor name) =
275 case splitName name of
276 case splitName name of
276 Left err -> iPrintError err
277 Left err -> iPrintError err
277 Right n -> process stdout "(ideslave)" (DocStr n)
278 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
283runIdeSlaveCommand id orig fn mods (IdeSlave.CaseSplit line name) =
279runIdeSlaveCommand id orig fn mods (IdeSlave.CaseSplit line name) =
284 process stdout fn (CaseSplitAt False line (sUN name))
280 process stdout fn (CaseSplitAt False line (sUN name))
285runIdeSlaveCommand id orig fn mods (IdeSlave.AddClause line name) =
281runIdeSlaveCommand id orig fn mods (IdeSlave.AddClause line name) =
@@ -342,7 +338,36 @@ runIdeSlaveCommand id orig fn mods (IdeSlave.Metavariables cols) =
342 pprintPTerm imp (zip ns (repeat False)) [] t
338 pprintPTerm imp (zip ns (repeat False)) [] t
343 rest = sexpGoal ist cols imp (n:ns) (ps, concl)
339 rest = sexpGoal ist cols imp (n:ns) (ps, concl)
344 in ((n', t', spans) : fst rest, snd rest)
340 in ((n', t', spans) : fst rest, snd rest)
345−
341+runIdeSlaveCommand id orig fn mods (IdeSlave.WhoCalls n) =
343+ Left err -> iPrintError err
344+ Right n -> do calls <- whoCalls n
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) .
353+runIdeSlaveCommand id orig fn mods (IdeSlave.CallsWho n) =
355+ Left err -> iPrintError err
356+ Right n -> do calls <- callsWho n
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) .
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
347ideslaveProcess :: FilePath -> Command -> Idris ()
372ideslaveProcess :: FilePath -> Command -> Idris ()
348ideslaveProcess fn Help = process stdout fn Help
373ideslaveProcess fn Help = process stdout fn Help
@@ -405,6 +430,8 @@ ideslaveProcess fn (SetConsoleWidth w) = do process stdout fn (SetConsoleWidth w
405 iPrintResult ""
430 iPrintResult ""
406ideslaveProcess fn (Apropos a) = do process stdout fn (Apropos a)
431ideslaveProcess fn (Apropos a) = do process stdout fn (Apropos a)
407 iPrintResult ""
432 iPrintResult ""
433+ideslaveProcess fn (WhoCalls n) = process stdout fn (WhoCalls n)
434+ideslaveProcess fn (CallsWho n) = process stdout fn (CallsWho n)
408ideslaveProcess fn _ = iPrintError "command not recognized or not supported"
435ideslaveProcess fn _ = iPrintError "command not recognized or not supported"
@@ -1041,6 +1068,24 @@ process h fn (Apropos a) =
1041 isUN (NS n _) = isUN n
1068 isUN (NS n _) = isUN n
1042 isUN _ = False
1069 isUN _ = False
1071+process h fn (WhoCalls n) =
1072+ do calls <- whoCalls n
1074+ ihRenderResult h . vsep $
1076+ text "Callers of" <+> prettyName True [] n <$>
1077+ indent 1 (vsep (map ((text "*" <+>) . align . prettyName True []) ns)))
1080+process h fn (CallsWho n) =
1081+ do calls <- callsWho n
1083+ ihRenderResult h . vsep $
1085+ prettyName True [] n <+> text "calls:" <$>
1086+ indent 1 (vsep (map ((text "*" <+>) . align . prettyName True []) ns)))
1044classInfo :: ClassInfo -> Idris (Doc OutputAnnotation)
1089classInfo :: ClassInfo -> Idris (Doc OutputAnnotation)
1045classInfo ci = do ist <- getIState
1090classInfo ci = do ist <- getIState
1046 ctxt <- getContext
1091 ctxt <- getContext