Add support for -a: emit for sourced files.

This commit is contained in:
Vidar Holen
2017-08-13 19:34:45 -07:00
parent 73d06c4f47
commit 8dd40efb44
11 changed files with 182 additions and 71 deletions

View File

@@ -34,14 +34,27 @@ format = return Formatter {
putStrLn "<checkstyle version='4.3'>",
onFailure = outputError,
onResult = outputResult,
onResult = outputResults,
footer = putStrLn "</checkstyle>"
}
outputResult result contents = do
let comments = makeNonVirtual (crComments result) contents
putStrLn . formatFile (crFilename result) $ comments
outputResults cr sys =
if null comments
then outputFile (crFilename cr) "" []
else mapM_ outputGroup fileGroups
where
comments = crComments cr
fileGroups = groupWith sourceFile comments
outputGroup group = do
let filename = sourceFile (head group)
result <- (siReadFile sys) filename
let contents = either (const "") id result
outputFile filename contents group
outputFile filename contents warnings = do
let comments = makeNonVirtual warnings contents
putStrLn . formatFile filename $ comments
formatFile name comments = concat [
"<file ", attr "name" name, ">\n",