mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-14 02:27:30 -07:00
Change definition of Replacement, add ToJSON instance for it
This commit is contained in:
parent
4a87d2a3de
commit
5ed89d2241
4 changed files with 48 additions and 16 deletions
|
@ -39,6 +39,19 @@ format = do
|
|||
footer = finish ref
|
||||
}
|
||||
|
||||
instance ToJSON Replacement where
|
||||
toJSON replacement =
|
||||
let start = repStartPos replacement
|
||||
end = repEndPos replacement
|
||||
str = repString replacement in
|
||||
object [
|
||||
"line" .= posLine start,
|
||||
"endLine" .= posLine end,
|
||||
"column" .= posColumn start,
|
||||
"endColumn" .= posColumn end,
|
||||
"replaceWith" .= str
|
||||
]
|
||||
|
||||
instance ToJSON (PositionedComment) where
|
||||
toJSON comment =
|
||||
let start = pcStartPos comment
|
||||
|
@ -52,7 +65,8 @@ instance ToJSON (PositionedComment) where
|
|||
"endColumn" .= posColumn end,
|
||||
"level" .= severityText comment,
|
||||
"code" .= cCode c,
|
||||
"message" .= cMessage c
|
||||
"message" .= cMessage c,
|
||||
"fix" .= pcFix comment
|
||||
]
|
||||
|
||||
toEncoding comment =
|
||||
|
@ -68,6 +82,7 @@ instance ToJSON (PositionedComment) where
|
|||
<> "level" .= severityText comment
|
||||
<> "code" .= cCode c
|
||||
<> "message" .= cMessage c
|
||||
<> "replaceWith" .= pcFix comment
|
||||
)
|
||||
|
||||
outputError file msg = hPutStrLn stderr $ file ++ ": " ++ msg
|
||||
|
@ -77,4 +92,3 @@ collectResult ref result _ =
|
|||
finish ref = do
|
||||
list <- readIORef ref
|
||||
BL.putStrLn $ encode list
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue