on master help sign in
Report REPL errors in IDESlave with highlighting
36527f6David Raymond Christiansen
src/Idris/AbsSyntax.hs+13
@@ -579,6 +579,19 @@ fancifyAnnots _ annot = annot
579type1Doc :: Doc OutputAnnotation
579type1Doc :: Doc OutputAnnotation
580type1Doc = (annotate AnnConstType $ text "Type 1")
580type1Doc = (annotate AnnConstType $ text "Type 1")
581
581
582+-- | Show an error with semantic highlighting
583+ihRenderError :: Handle -> Doc OutputAnnotation -> Idris ()
584+ihRenderError h e = do ist <- getIState
585+ case idris_outputmode ist of
586+ RawOutput -> consoleDisplayAnnotated h e
587+ IdeSlave n -> do
588+ (str, spans) <- fmap displaySpans .
589+ iRender .
590+ fmap (fancifyAnnots ist) $
591+ e
592+ let good = [SymbolAtom "error", toSExp str, toSExp spans]
593+ runIO . hPutStrLn h $ convSExp "return" good n
594+
582ihPrintError :: Handle -> String -> Idris ()
595ihPrintError :: Handle -> String -> Idris ()
583ihPrintError h s = do i <- getIState
596ihPrintError h s = do i <- getIState
584 case idris_outputmode i of
597 case idris_outputmode i of
src/Idris/REPL.hs+2−2
@@ -227,11 +227,11 @@ ideslave orig mods
227 Success (Prove n') -> do iPrintResult ""
227 Success (Prove n') -> do iPrintResult ""
228 idrisCatch
228 idrisCatch
229 (process stdout fn (Prove n'))
229 (process stdout fn (Prove n'))
230− (\e -> getIState >>= iPrintError . flip pshow e)
230+ (\e -> getIState >>= ihRenderError . flip pprintErr e)
231 isetPrompt (mkPrompt mods)
231 isetPrompt (mkPrompt mods)
232 Success cmd -> idrisCatch
232 Success cmd -> idrisCatch
233 (ideslaveProcess fn cmd)
233 (ideslaveProcess fn cmd)
234− (\e -> getIState >>= iPrintError . flip pshow e)
234+ (\e -> getIState >>= ihRenderError stdout . flip pprintErr e)
235 Just (IdeSlave.REPLCompletions str) ->
235 Just (IdeSlave.REPLCompletions str) ->
236 do (unused, compls) <- replCompletion (reverse str, "")
236 do (unused, compls) <- replCompletion (reverse str, "")
237 let good = IdeSlave.SexpList [IdeSlave.SymbolAtom "ok", IdeSlave.toSExp (map replacement compls, reverse unused)]
237 let good = IdeSlave.SexpList [IdeSlave.SymbolAtom "ok", IdeSlave.toSExp (map replacement compls, reverse unused)]