@@ -8,7 +8,7 @@ module Reporting.Doc
8 , P.red, P.cyan, P.magenta, P.green, P.blue, P.black, P.yellow
8 , P.red, P.cyan, P.magenta, P.green, P.blue, P.black, P.yellow
9 , P.dullred, P.dullcyan, P.dullyellow
9 , P.dullred, P.dullcyan, P.dullyellow
11− , fromString, fromText, fromName, fromInt, fromUtf8
11+ , fromChars, fromName, fromInt, fromUtf8
12 , toAnsi, toString, toLine
12 , toAnsi, toString, toLine
@@ -26,17 +26,12 @@ import Prelude hiding (cycle)
26import qualified Data.List as List
26import qualified Data.List as List
27import Data.Monoid ((<>))
27import Data.Monoid ((<>))
28import qualified Data.Name as Name
28import qualified Data.Name as Name
29−import qualified Data.Text as Text
30−import qualified Data.Text.Lazy as TL
31−import qualified Data.Text.Lazy.Builder as TB
32import qualified Data.Utf8 as Utf8
29import qualified Data.Utf8 as Utf8
33import qualified System.Console.ANSI.Types as Ansi
30import qualified System.Console.ANSI.Types as Ansi
34import System.IO (Handle)
31import System.IO (Handle)
35import qualified Text.PrettyPrint.ANSI.Leijen as P
32import qualified Text.PrettyPrint.ANSI.Leijen as P
37import qualified Data.Index as Index
34import qualified Data.Index as Index
38−import qualified Elm.Compiler.Version as Compiler
39−import qualified Elm.Package as Pkg
40import qualified Json.Encode as E
35import qualified Json.Encode as E
@@ -44,19 +39,14 @@ import qualified Json.Encode as E
47−fromString :: String -> P.Doc
42+fromChars :: String -> P.Doc
48−fromString =
43+fromChars =
52−fromText :: Text.Text -> P.Doc
54− P.text (Text.unpack txt)
57fromName :: Name.Name -> P.Doc
47fromName :: Name.Name -> P.Doc
58fromName name =
48fromName name =
59− P.text (Name.toString name)
49+ P.text (Name.toChars name)
62fromInt :: Int -> P.Doc
52fromInt :: Int -> P.Doc
@@ -64,9 +54,9 @@ fromInt n =
64 P.text (show n)
54 P.text (show n)
67−fromUtf8 :: Utf8.Utf8 -> P.Doc
57+fromUtf8 :: Utf8.String -> P.Doc
68fromUtf8 utf8 =
58fromUtf8 utf8 =
69− P.text (Utf8.toString utf8)
59+ P.text (Utf8.toChars utf8)
@@ -159,12 +149,12 @@ fancyLink word before fileName after =
160makeLink :: String -> String
150makeLink :: String -> String
161makeLink fileName =
151makeLink fileName =
162− "<https://elm-lang.org/" <> Pkg.versionToString Compiler.version <> "/" <> fileName <> ">"
152+ "<https://elm-lang.org/" <> error "TODO V.toString V.compiler" <> "/" <> fileName <> ">"
165makeNakedLink :: String -> String
155makeNakedLink :: String -> String
166makeNakedLink fileName =
156makeNakedLink fileName =
167− "https://elm-lang.org/" <> Pkg.versionToString Compiler.version <> "/" <> fileName
157+ "https://elm-lang.org/" <> error "TODO V.toString V.compiler" <> "/" <> fileName
170reflowLink :: String -> String -> String -> P.Doc
160reflowLink :: String -> String -> String -> P.Doc
@@ -267,8 +257,10 @@ data Color
270−toJsonHelp :: Style -> [TB.Builder] -> P.SimpleDoc -> [E.Value]
260+toJsonHelp :: Style -> [a] -> P.SimpleDoc -> [E.Value]
271toJsonHelp style revChunks simpleDoc =
261toJsonHelp style revChunks simpleDoc =
262+ error "TODO generate json on errors" style revChunks simpleDoc sgrToStyle encodeColor
272 case simpleDoc of
264 case simpleDoc of
273 P.SFail ->
265 P.SFail ->
@@ -294,7 +286,7 @@ toJsonHelp style revChunks simpleDoc =
294spaces :: Int -> TB.Builder
286spaces :: Int -> TB.Builder
295spaces n =
287spaces n =
296 TB.fromText (Text.replicate n " ")
288 TB.fromText (Text.replicate n " ")
299sgrToStyle :: [Ansi.SGR] -> Style -> Style
291sgrToStyle :: [Ansi.SGR] -> Style -> Style
300sgrToStyle sgrs style@(Style bold underline color) =
292sgrToStyle sgrs style@(Style bold underline color) =
@@ -356,35 +348,28 @@ toColor layer intensity color =
356 Ansi.White -> pick White WHITE
348 Ansi.White -> pick White WHITE
357 Ansi.Black -> pick Black BLACK
349 Ansi.Black -> pick Black BLACK
360encodeChunks :: Style -> [TB.Builder] -> E.Value
352encodeChunks :: Style -> [TB.Builder] -> E.Value
361encodeChunks (Style bold underline color) revChunks =
353encodeChunks (Style bold underline color) revChunks =
363− text =
355+ !str = Utf8.concat (reverse revChunks)
369− TL.toStrict $ TB.toLazyText $
370− List.foldl' (\builder chunk -> chunk <> builder) c cs
372 case color of
357 case color of
373 Nothing | not bold && not underline ->
358 Nothing | not bold && not underline ->
374− E.text text
359+ E.string str
378 [ ("bold", E.bool bold)
363 [ ("bold", E.bool bold)
379 , ("underline", E.bool underline)
364 , ("underline", E.bool underline)
380 , ("color", maybe E.null encodeColor color)
365 , ("color", maybe E.null encodeColor color)
381− , ("string", E.text text)
366+ , ("string", E.string str)
385encodeColor :: Color -> E.Value
370encodeColor :: Color -> E.Value
386encodeColor color =
371encodeColor color =
387− E.text $
372+ E.string $
388 case color of
373 case color of
389 Red -> "red"
374 Red -> "red"
390 RED -> "RED"
375 RED -> "RED"