1-----------------------------------------------------------------------------
4-- Copyright : (c) 2013-15 Phil Freeman, (c) 2014-15 Gary Burgess
5-- License : MIT (http://opensource.org/licenses/MIT)
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
13-----------------------------------------------------------------------------
15{-# LANGUAGE TemplateHaskell #-}
22import qualified Data.Aeson.TH as A
24import qualified Language.PureScript as P
26data ErrorPosition = ErrorPosition
33data ErrorSuggestion = ErrorSuggestion { replacement :: String }
35data JSONError = JSONError
36 { position :: Maybe ErrorPosition
40 , filename :: Maybe String
41 , moduleName :: Maybe String
42 , suggestion :: Maybe ErrorSuggestion
45data JSONResult = JSONResult
46 { warnings :: [JSONError]
47 , errors :: [JSONError]
50$(A.deriveJSON A.defaultOptions ''ErrorPosition)
51$(A.deriveJSON A.defaultOptions ''JSONError)
52$(A.deriveJSON A.defaultOptions ''JSONResult)
53$(A.deriveJSON A.defaultOptions ''ErrorSuggestion)
56toJSONErrors :: Bool -> P.Level -> P.MultipleErrors -> [JSONError]
57toJSONErrors verbose level = map (toJSONError verbose level) . P.runMultipleErrors
59toJSONError :: Bool -> P.Level -> P.ErrorMessage -> JSONError
60toJSONError verbose level e =
61 JSONError (toErrorPosition <$> sspan)
62 (P.renderBox (P.prettyPrintSingleError verbose level False (P.stripModuleAndSpan e)))
65 (P.spanName <$> sspan)
66 (P.runModuleName <$> P.errorModule e)
67 (toSuggestion <$> (P.errorSuggestion $ P.unwrapErrorMessage e))
69 sspan :: Maybe P.SourceSpan
72 toErrorPosition :: P.SourceSpan -> ErrorPosition
74 ErrorPosition (P.sourcePosLine (P.spanStart ss))
75 (P.sourcePosColumn (P.spanStart ss))
76 (P.sourcePosLine (P.spanEnd ss))
77 (P.sourcePosColumn (P.spanEnd ss))
78 toSuggestion :: P.ErrorSuggestion -> ErrorSuggestion
79-- TODO: Adding a newline because source spans chomp everything up to the next character
80 toSuggestion (P.ErrorSuggestion s) = ErrorSuggestion $ if null s then s else s ++ "\n"
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