1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
12import qualified Data.ByteString as B
13import qualified Data.NonEmptyList as NE
14import qualified Data.OneOrMore as OneOrMore
16import qualified Elm.ModuleName as ModuleName
18import qualified Json.Encode as E
19import Json.Encode ((==>))
20import qualified Reporting.Annotation as A
21import qualified Reporting.Doc as D
22import qualified Reporting.Error.Canonicalize as Canonicalize
23import qualified Reporting.Error.Docs as Docs
24import qualified Reporting.Error.Import as Import
25import qualified Reporting.Error.Main as Main
26import qualified Reporting.Error.Pattern as Pattern
27import qualified Reporting.Error.Syntax as Syntax
28import qualified Reporting.Error.Type as Type
29import qualified Reporting.Render.Code as Code
30import qualified Reporting.Render.Type.Localizer as L
31import qualified Reporting.Report as Report
40 { _name :: ModuleName.Raw
43 , _source :: B.ByteString
53 = BadSyntax Syntax.Error
54 | BadImports (NE.List Import.Error)
55 | BadNames (OneOrMore.OneOrMore Canonicalize.Error)
56 | BadTypes L.Localizer (NE.List Type.Error)
57 | BadMains L.Localizer (OneOrMore.OneOrMore Main.Error)
58 | BadPatterns (NE.List Pattern.Error)
66toReports :: Code.Source -> Error -> NE.List Report.Report
69 BadSyntax syntaxError ->
70 NE.List (Syntax.toReport source syntaxError) []
73 fmap (Import.toReport source) errs
76 fmap (Canonicalize.toReport source) (OneOrMore.destruct NE.List errs)
78 BadTypes localizer errs ->
79 fmap (Type.toReport source localizer) errs
81 BadMains localizer errs ->
82 fmap (Main.toReport localizer source) (OneOrMore.destruct NE.List errs)
85 fmap (Pattern.toReport source) errs
88 Docs.toReports source docsErr
95toDoc :: Module -> [Module] -> D.Doc
98 (NE.List m ms) = NE.sortBy _time (NE.List err errs)
100 D.vcat (toDocHelp m ms)
103toDocHelp :: Module -> [Module] -> [D.Doc]
104toDocHelp module1 modules =
111 module2 : otherModules ->
113 : toSeparator module1 module2
114 : toDocHelp module2 otherModules
117toSeparator :: Module -> Module -> D.Doc
118toSeparator beforeModule afterModule =
120 before = ModuleName.toChars (_name beforeModule) ++ " ↑ "
121 after = " ↓ " ++ ModuleName.toChars (_name afterModule)
124 [ D.indent (80 - length before) (D.fromChars before)
125 , "====o======================================================================o===="
136moduleToDoc :: Module -> D.Doc
137moduleToDoc (Module _ path _ source err) =
140 toReports (Code.toSource source) err
142 D.vcat $ map (reportToDoc path) (NE.toList reports)
145reportToDoc :: FilePath -> Report.Report -> D.Doc
146reportToDoc path (Report.Report title _ _ message) =
148 [ toMessageBar title path
155toMessageBar :: String -> FilePath -> D.Doc
156toMessageBar title filePath =
159 4 + length title + 1 + length filePath
161 D.dullcyan $ D.fromChars $
163 ++ " " ++ replicate (max 1 (80 - usedSpace)) '-'
171toJson :: Module -> E.Value
172toJson (Module name path _ source err) =
175 toReports (Code.toSource source) err
178 [ "path" ==> E.chars path
179 , "name" ==> E.name name
180 , "problems" ==> E.array (map reportToJson (NE.toList reports))
184reportToJson :: Report.Report -> E.Value
185reportToJson (Report.Report title region _sgstns message) =
187 [ "title" ==> E.chars title
188 , "region" ==> encodeRegion region
189 , "message" ==> D.encode message
193encodeRegion :: A.Region -> E.Value
194encodeRegion (A.Region (A.Position sr sc) (A.Position er ec)) =
198 [ "line" ==> E.int (fromIntegral sr)
199 , "column" ==> E.int (fromIntegral sc)
203 [ "line" ==> E.int (fromIntegral er)
204 , "column" ==> E.int (fromIntegral ec)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list