git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: fix some issues with brief errors
33ad122Andy Arvanitis
pcc/Main.hs+19−16
@@ -31,6 +31,7 @@ import qualified Data.ByteString.Lazy as B
31import qualified Data.ByteString.UTF8 as BU8
31import qualified Data.ByteString.UTF8 as BU8
32import Data.Char (isSpace)
32import Data.Char (isSpace)
33import qualified Data.Map as M
33import qualified Data.Map as M
34+import Data.Maybe (maybe)
34import Data.Text (Text)
35import Data.Text (Text)
35import Data.Version (showVersion)
36import Data.Version (showVersion)
36
37
@@ -97,28 +98,30 @@ printWarningsAndErrors verbose BriefErrors warnings errors = do
97 either (const exitFailure) (const (return ())) errors
98 either (const exitFailure) (const (return ())) errors
98
99
99briefFormat :: JSONResult -> [String]
100briefFormat :: JSONResult -> [String]
100−briefFormat (JSONResult warnings errors) = concat $
101+briefFormat (JSONResult warnings errors) =
101 (renderError Error <$> errors) <> (renderError Warning <$> warnings)
102 (renderError Error <$> errors) <> (renderError Warning <$> warnings)
102 where
103 where
103− renderError :: BriefType -> JSONError -> [String]
104+ renderError :: BriefType -> JSONError -> String
104− renderError t (JSONError pos msg _ lnk file _ suggest) =
105+ renderError t (JSONError (Just pos) msg _ lnk (Just file) _ _) =
105 printf
106 printf
106 "%s:%d:%d: %s: %s"
107 "%s:%d:%d: %s: %s"
107− (concat file)
108+ file
108− (maybe 0 startLine pos)
109+ (startLine pos)
109− (maybe 0 startColumn pos)
110+ (startColumn pos)
110 (show t)
111 (show t)
111− (dropWhile isSpace message) :
112+ (combine msg lnk)
112− notes
113+ renderError t (JSONError _ msg _ lnk _ module' _) =
114+ printf
115+ "%s: in module %s - %s"
116+ (show t)
117+ (maybe "?" (printf "\"%s\"") module')
118+ (combine msg lnk)
119+ combine :: String -> String -> String
120+ combine msg lnk
121+ | null lnk = msg'
122+ | otherwise = printf "%s\nSee %s for more information\n" msg' lnk
113 where
123 where
114− message
124+ msg' = dropWhile isSpace msg
115− | null lnk = msg
116− | otherwise = printf "%s\nSee %s for more information\n" msg lnk
117− notes
118− | Error <- t,
119− Just (ErrorSuggestion s@(_:_) r) <- suggest =
120− renderError Note (JSONError (r <|> pos) s [] [] file Nothing Nothing)
121− | otherwise = []
122
125
123compile :: PCCMakeOptions -> IO ()
126compile :: PCCMakeOptions -> IO ()
124compile PCCMakeOptions{..} = do
127compile PCCMakeOptions{..} = do