@@ -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,62 @@ 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 d) =
343+ Left err -> iPrintError err
344+ Right n -> do res <- findCallers d n
345+ let msg = (IdeSlave.SymbolAtom "ok", res)
346+ runIO . putStrLn $ IdeSlave.convSExp "return" msg id
347+ where findCallers d n | d > 1 = do calls <- whoCalls n
349+ out <- mapM (\(n, ns) ->
350+ do ns' <- mapM (findCallers (d-1)) ns
351+ return (pn ist n, zip (map (pn ist) ns) ns'))
353+ return $ IdeSlave.toSExp out
354+ | otherwise = do calls <- whoCalls n
356+ return . IdeSlave.toSExp $
359+ map (\n -> (pn ist n, nil)) ns))
361+ nil = IdeSlave.SexpList []
362+ pn ist = displaySpans .
363+ renderPretty 0.9 1000 .
364+ fmap (fancifyAnnots ist) .
366+runIdeSlaveCommand id orig fn mods (IdeSlave.CallsWho n d) =
368+ Left err -> iPrintError err
369+ Right n -> do res <- findCallees d n
370+ let msg = (IdeSlave.SymbolAtom "ok", res)
371+ runIO . putStrLn $ IdeSlave.convSExp "return" msg id
372+ where findCallees d n | d > 1 = do calls <- callsWho n
374+ out <- mapM (\(n, ns) ->
375+ do ns' <- mapM (findCallees (d-1)) ns
376+ return (pn ist n, zip (map (pn ist) ns) ns'))
378+ return $ IdeSlave.toSExp out
379+ | otherwise = do calls <- callsWho n
381+ return . IdeSlave.toSExp $
384+ map (\n -> (pn ist n, nil)) ns))
386+ nil = IdeSlave.SexpList []
387+ pn ist = displaySpans .
388+ renderPretty 0.9 1000 .
389+ fmap (fancifyAnnots ist) .
392+splitName :: String -> Either String Name
393+splitName s = case reverse $ splitOn "." s of
394+ [] -> Left ("Didn't understand name '" ++ s ++ "'")
395+ [n] -> Right $ sUN n
396+ (n:ns) -> Right $ sNS (sUN n) ns
347ideslaveProcess :: FilePath -> Command -> Idris ()
398ideslaveProcess :: FilePath -> Command -> Idris ()
348ideslaveProcess fn Help = process stdout fn Help
399ideslaveProcess fn Help = process stdout fn Help