on master help sign in
Rename to Message
commit74ddf724ab9edf13654a021621776c5376faf173 authorJason Felice <jason.m.felice@gmail.com> dateTue 12 Dec 2017, 11:11 (9 years ago) parent826b491
3 files changed+27−27
src/Idris/Output.hs+21−21 src/Idris/Parser.hs+1−1 src/Idris/Parser/Stack.hs+5−5
src/Idris/Output.hs+21−21
@@ -14,7 +14,7 @@ module Idris.Output (clearHighlights, emit, idemodePutSExp, iPrintError, iPrintF
1414 iRender, iRenderError, iRenderOutput, iRenderResult, iWarn,
1515 prettyDocumentedIst, printUndefinedNames, pshow, renderExternal,
1616 sendHighlighting, sendParserHighlighting, warnTotality,
17− writeHighlights, OutputDoc(..), Warning(..)) where
17+ writeHighlights, OutputDoc(..), Message(..)) where
1818
1919import Idris.AbsSyntax
2020import Idris.Colours (hEndColourise, hStartColourise)
@@ -53,30 +53,30 @@ pshow ist err = displayDecorated (consoleDecorate ist) .
5353
5454type OutputDoc = Doc OutputAnnotation
5555
56−class Warning a where
57− warningExtent :: a -> FC
58− warningMessage :: a -> OutputDoc
59− warningSource :: a -> Maybe String
56+class Message a where
57+ messageExtent :: a -> FC
58+ messageText :: a -> OutputDoc
59+ messageSource :: a -> Maybe String
6060
6161data Ann = AText String | ATagged OutputAnnotation Ann | ASplit Ann Ann
6262
6363data Hack = Hack FC OutputDoc
64−instance Warning Hack where
65− warningExtent (Hack extent _) = extent
66− warningMessage (Hack _ msg) = msg
67− warningSource _ = Nothing
64+instance Message Hack where
65+ messageExtent (Hack extent _) = extent
66+ messageText (Hack _ msg) = msg
67+ messageSource _ = Nothing
6868
69−formatWarning :: Warning w => w -> Idris OutputDoc
70−formatWarning w = do
69+formatMessage :: Message w => w -> Idris OutputDoc
70+formatMessage w = do
7171 i <- getIState
72− maybeSource <- case warningSource w of
72+ maybeSource <- case messageSource w of
7373 Just src -> pure (Just src)
7474 Nothing -> readSource fc
7575 let maybeFormattedSource = maybeSource >>= layoutSource fc (idris_highlightedRegions i)
76− return $ layoutWarning (layoutFC fc) maybeFormattedSource (warningMessage w)
76+ return $ layoutMessage (layoutFC fc) maybeFormattedSource (messageText w)
7777 where
7878 fc :: FC
79− fc = warningExtent w
79+ fc = messageExtent w
8080
8181 layoutFC :: FC -> OutputDoc
8282 layoutFC fc@(FC fn _ _) | fn /= "" = text (show $ fc) <> colon
@@ -168,24 +168,24 @@ formatWarning w = do
168168 source = line1 <$$> line2 <$$> line3
169169 layoutSource _ _ _ = Nothing
170170
171− layoutWarning :: OutputDoc -> Maybe OutputDoc -> OutputDoc -> OutputDoc
172− layoutWarning loc (Just src) err = loc <$$> src <$$> err <$$> empty
173− layoutWarning loc Nothing err = loc </> err
171+ layoutMessage :: OutputDoc -> Maybe OutputDoc -> OutputDoc -> OutputDoc
172+ layoutMessage loc (Just src) err = loc <$$> src <$$> err <$$> empty
173+ layoutMessage loc Nothing err = loc </> err
174174
175175iWarn :: FC -> OutputDoc -> Idris ()
176176iWarn fc err = emit $ Hack fc err
177177
178−emit :: Warning w => w -> Idris ()
178+emit :: Message w => w -> Idris ()
179179emit w =
180180 do i <- getIState
181181 case idris_outputmode i of
182182 RawOutput h ->
183− do formattedErr <- formatWarning w
183+ do formattedErr <- formatMessage w
184184 err' <- iRender . fmap (fancifyAnnots i True) $ formattedErr
185185 hWriteDoc h i err'
186186 IdeMode n h ->
187− do err' <- iRender . fmap (fancifyAnnots i True) $ warningMessage w
188− let fc = warningExtent w
187+ do err' <- iRender . fmap (fancifyAnnots i True) $ messageText w
188+ let fc = messageExtent w
189189 let (str, spans) = displaySpans err'
190190 runIO . hPutStrLn h $
191191 convSExp "warning" (fc_fname fc, fc_start fc, fc_end fc, str, spans) n
src/Idris/Parser.hs+1−1
@@ -1519,7 +1519,7 @@ parseProg syn fname input mrk
15191519 case runparser mainProg i fname input of
15201520 Left err -> do emit err
15211521 i <- getIState
1522− putIState (i { errSpan = Just (warningExtent err) })
1522+ putIState (i { errSpan = Just (messageExtent err) })
15231523 return []
15241524 Right (x, i) -> do putIState i
15251525 reportParserWarnings
src/Idris/Parser/Stack.hs+5−5
@@ -33,7 +33,7 @@ module Idris.Parser.Stack
3333where
3434
3535import Idris.Core.TT (FC(..))
36−import Idris.Output (Warning(..))
36+import Idris.Output (Message(..))
3737
3838import Control.Arrow (app)
3939import Control.Monad.State.Strict (StateT(..), evalStateT)
@@ -64,12 +64,12 @@ runparser p i inputname s =
6464
6565data ParseError = ParseError String (P.ParseError (P.Token String) Void)
6666
67−instance Warning ParseError where
68− warningExtent (ParseError _ err) = sourcePositionFC pos
67+instance Message ParseError where
68+ messageExtent (ParseError _ err) = sourcePositionFC pos
6969 where
7070 (pos NonEmpty.:| _) = P.errorPos err
71− warningMessage (ParseError _ err) = PP.text . init . P.parseErrorTextPretty $ err
72− warningSource (ParseError src _) = Just src
71+ messageText (ParseError _ err) = PP.text . init . P.parseErrorTextPretty $ err
72+ messageSource (ParseError src _) = Just src
7373
7474-- | A fully formatted parse error, with caret and bar, etc.
7575prettyError :: ParseError -> String