Merge pull request #1206 from ngzhian/aeson
Change to aeson (fixes #1085)
This commit is contained in:
commit
4a5ee06ce4
|
@ -49,10 +49,11 @@ library
|
|||
build-depends:
|
||||
-- GHC 7.6.3 (base 4.6.0.1) is buggy (#1131, #1119) in optimized mode.
|
||||
-- Just disable that version entirely to fail fast.
|
||||
aeson,
|
||||
base > 4.6.0.1 && < 5,
|
||||
bytestring,
|
||||
containers >= 0.5,
|
||||
directory,
|
||||
json,
|
||||
mtl >= 2.2.1,
|
||||
parsec,
|
||||
regex-tdfa,
|
||||
|
@ -85,11 +86,12 @@ executable shellcheck
|
|||
build-depends:
|
||||
semigroups
|
||||
build-depends:
|
||||
aeson,
|
||||
base >= 4 && < 5,
|
||||
ShellCheck,
|
||||
bytestring,
|
||||
ShellCheck,
|
||||
containers,
|
||||
directory,
|
||||
json >= 0.3.6,
|
||||
mtl >= 2.2.1,
|
||||
parsec >= 3.0,
|
||||
QuickCheck >= 2.7.4,
|
||||
|
@ -99,11 +101,12 @@ executable shellcheck
|
|||
test-suite test-shellcheck
|
||||
type: exitcode-stdio-1.0
|
||||
build-depends:
|
||||
aeson,
|
||||
base >= 4 && < 5,
|
||||
ShellCheck,
|
||||
bytestring,
|
||||
ShellCheck,
|
||||
containers,
|
||||
directory,
|
||||
json,
|
||||
mtl >= 2.2.1,
|
||||
parsec,
|
||||
QuickCheck >= 2.7.4,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-
|
||||
Copyright 2012-2015 Vidar Holen
|
||||
|
||||
|
@ -22,10 +23,12 @@ module ShellCheck.Formatter.JSON (format) where
|
|||
import ShellCheck.Interface
|
||||
import ShellCheck.Formatter.Format
|
||||
|
||||
import Data.Aeson
|
||||
import Data.IORef
|
||||
import Data.Monoid
|
||||
import GHC.Exts
|
||||
import System.IO
|
||||
import Text.JSON
|
||||
import qualified Data.ByteString.Lazy.Char8 as BL
|
||||
|
||||
format = do
|
||||
ref <- newIORef []
|
||||
|
@ -36,19 +39,30 @@ format = do
|
|||
footer = finish ref
|
||||
}
|
||||
|
||||
instance JSON (PositionedComment) where
|
||||
showJSON comment@(PositionedComment start end (Comment level code string)) = makeObj [
|
||||
("file", showJSON $ posFile start),
|
||||
("line", showJSON $ posLine start),
|
||||
("endLine", showJSON $ posLine end),
|
||||
("column", showJSON $ posColumn start),
|
||||
("endColumn", showJSON $ posColumn end),
|
||||
("level", showJSON $ severityText comment),
|
||||
("code", showJSON code),
|
||||
("message", showJSON string)
|
||||
]
|
||||
instance ToJSON (PositionedComment) where
|
||||
toJSON comment@(PositionedComment start end (Comment level code string)) =
|
||||
object [
|
||||
"file" .= posFile start,
|
||||
"line" .= posLine start,
|
||||
"endLine" .= posLine end,
|
||||
"column" .= posColumn start,
|
||||
"endColumn" .= posColumn end,
|
||||
"level" .= severityText comment,
|
||||
"code" .= code,
|
||||
"message" .= string
|
||||
]
|
||||
|
||||
readJSON = undefined
|
||||
toEncoding comment@(PositionedComment start end (Comment level code string)) =
|
||||
pairs (
|
||||
"file" .= posFile start
|
||||
<> "line" .= posLine start
|
||||
<> "endLine" .= posLine end
|
||||
<> "column" .= posColumn start
|
||||
<> "endColumn" .= posColumn end
|
||||
<> "level" .= severityText comment
|
||||
<> "code" .= code
|
||||
<> "message" .= string
|
||||
)
|
||||
|
||||
outputError file msg = hPutStrLn stderr $ file ++ ": " ++ msg
|
||||
collectResult ref result _ =
|
||||
|
@ -56,5 +70,5 @@ collectResult ref result _ =
|
|||
|
||||
finish ref = do
|
||||
list <- readIORef ref
|
||||
putStrLn $ encodeStrict list
|
||||
BL.putStrLn $ encode list
|
||||
|
||||
|
|
Loading…
Reference in New Issue