1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE OverloadedStrings #-}
3module Reporting.Warning where
5import Data.Aeson ((.=))
6import qualified Data.Aeson as Json
7import qualified Text.PrettyPrint as P
8import Text.PrettyPrint ((<+>))
10import qualified AST.Helpers as Help
11import qualified AST.Module.Name as ModuleName
12import qualified AST.Type as Type
13import qualified Reporting.Annotation as A
14import qualified Reporting.PrettyPrint as P
15import qualified Reporting.Report as Report
18-- ALL POSSIBLE WARNINGS
21 = UnusedImport ModuleName.Raw
22 | MissingTypeAnnotation String Type.Canonical
27toString :: P.Dealiaser -> String -> String -> A.Located Warning -> String
28toString dealiaser location source (A.A region warning) =
29 Report.toString location region (toReport dealiaser warning) source
32print :: P.Dealiaser -> String -> String -> A.Located Warning -> IO ()
33print dealiaser location source (A.A region warning) =
34 Report.printWarning location region (toReport dealiaser warning) source
37toReport :: P.Dealiaser -> Warning -> Report.Report
38toReport dealiaser warning =
40 UnusedImport moduleName ->
43 ("Module `" ++ ModuleName.toString moduleName ++ "` is unused.")
46 MissingTypeAnnotation name inferredType ->
48 "missing type annotation"
49 ("Top-level value `" ++ name ++ "` does not have a type annotation.")
50 ( "The type annotation you want looks something like this:\n\n"
51 ++ P.render (P.nest 4 typeDoc)
55 if Help.isOp name then
56 P.parens (P.text name)
64 (P.pretty dealiaser False inferredType)
69toJson :: P.Dealiaser -> FilePath -> A.Located Warning -> Json.Value
70toJson dealiaser filePath (A.A region warning) =
72 (maybeRegion, additionalFields) =
73 Report.toJson [] (toReport dealiaser warning)
77 , "region" .= maybe region id maybeRegion
78 , "type" .= ("warning" :: String)
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