@@ -14,7 +14,7 @@ module Idris.Output (clearHighlights, emit, idemodePutSExp, iPrintError, iPrintF
14 iRender, iRenderError, iRenderOutput, iRenderResult, iWarn,
14 iRender, iRenderError, iRenderOutput, iRenderResult, iWarn,
15 prettyDocumentedIst, printUndefinedNames, pshow, renderExternal,
15 prettyDocumentedIst, printUndefinedNames, pshow, renderExternal,
16 sendHighlighting, sendParserHighlighting, warnTotality,
16 sendHighlighting, sendParserHighlighting, warnTotality,
17− writeHighlights, OutputDoc(..), Warning(..)) where
17+ writeHighlights, OutputDoc(..), Message(..)) where
19import Idris.AbsSyntax
19import Idris.AbsSyntax
20import Idris.Colours (hEndColourise, hStartColourise)
20import Idris.Colours (hEndColourise, hStartColourise)
@@ -53,30 +53,30 @@ pshow ist err = displayDecorated (consoleDecorate ist) .
54type OutputDoc = Doc OutputAnnotation
54type OutputDoc = Doc OutputAnnotation
56−class Warning a where
56+class Message a where
57− warningExtent :: a -> FC
57+ messageExtent :: a -> FC
58− warningMessage :: a -> OutputDoc
58+ messageText :: a -> OutputDoc
59− warningSource :: a -> Maybe String
59+ messageSource :: a -> Maybe String
61data Ann = AText String | ATagged OutputAnnotation Ann | ASplit Ann Ann
61data Ann = AText String | ATagged OutputAnnotation Ann | ASplit Ann Ann
63data Hack = Hack FC OutputDoc
63data Hack = Hack FC OutputDoc
64−instance Warning Hack where
64+instance Message Hack where
65− warningExtent (Hack extent _) = extent
65+ messageExtent (Hack extent _) = extent
66− warningMessage (Hack _ msg) = msg
66+ messageText (Hack _ msg) = msg
67− warningSource _ = Nothing
67+ messageSource _ = Nothing
69−formatWarning :: Warning w => w -> Idris OutputDoc
69+formatMessage :: Message w => w -> Idris OutputDoc
70−formatWarning w = do
70+formatMessage w = do
71 i <- getIState
71 i <- getIState
72− maybeSource <- case warningSource w of
72+ maybeSource <- case messageSource w of
73 Just src -> pure (Just src)
73 Just src -> pure (Just src)
74 Nothing -> readSource fc
74 Nothing -> readSource fc
75 let maybeFormattedSource = maybeSource >>= layoutSource fc (idris_highlightedRegions i)
75 let maybeFormattedSource = maybeSource >>= layoutSource fc (idris_highlightedRegions i)
76− return $ layoutWarning (layoutFC fc) maybeFormattedSource (warningMessage w)
76+ return $ layoutMessage (layoutFC fc) maybeFormattedSource (messageText w)
79− fc = warningExtent w
79+ fc = messageExtent w
81 layoutFC :: FC -> OutputDoc
81 layoutFC :: FC -> OutputDoc
82 layoutFC fc@(FC fn _ _) | fn /= "" = text (show $ fc) <> colon
82 layoutFC fc@(FC fn _ _) | fn /= "" = text (show $ fc) <> colon
@@ -168,24 +168,24 @@ formatWarning w = do
168 source = line1 <$$> line2 <$$> line3
168 source = line1 <$$> line2 <$$> line3
169 layoutSource _ _ _ = Nothing
169 layoutSource _ _ _ = Nothing
171− layoutWarning :: OutputDoc -> Maybe OutputDoc -> OutputDoc -> OutputDoc
171+ layoutMessage :: OutputDoc -> Maybe OutputDoc -> OutputDoc -> OutputDoc
172− layoutWarning loc (Just src) err = loc <$$> src <$$> err <$$> empty
172+ layoutMessage loc (Just src) err = loc <$$> src <$$> err <$$> empty
173− layoutWarning loc Nothing err = loc </> err
173+ layoutMessage loc Nothing err = loc </> err
175iWarn :: FC -> OutputDoc -> Idris ()
175iWarn :: FC -> OutputDoc -> Idris ()
176iWarn fc err = emit $ Hack fc err
176iWarn fc err = emit $ Hack fc err
178−emit :: Warning w => w -> Idris ()
178+emit :: Message w => w -> Idris ()
180 do i <- getIState
180 do i <- getIState
181 case idris_outputmode i of
181 case idris_outputmode i of
182 RawOutput h ->
182 RawOutput h ->
183− do formattedErr <- formatWarning w
183+ do formattedErr <- formatMessage w
184 err' <- iRender . fmap (fancifyAnnots i True) $ formattedErr
184 err' <- iRender . fmap (fancifyAnnots i True) $ formattedErr
185 hWriteDoc h i err'
185 hWriteDoc h i err'
186 IdeMode n h ->
186 IdeMode n h ->
187− do err' <- iRender . fmap (fancifyAnnots i True) $ warningMessage w
187+ do err' <- iRender . fmap (fancifyAnnots i True) $ messageText w
188− let fc = warningExtent w
188+ let fc = messageExtent w
189 let (str, spans) = displaySpans err'
189 let (str, spans) = displaySpans err'
190 runIO . hPutStrLn h $
190 runIO . hPutStrLn h $
191 convSExp "warning" (fc_fname fc, fc_start fc, fc_end fc, str, spans) n
191 convSExp "warning" (fc_fname fc, fc_start fc, fc_end fc, str, spans) n