/** Dumps error messages to the output stream. */
static MessageLevel reportErrors(
Map<InputSource, CharSequence> inputs,
MessageContext mc, MessageQueue mq, Appendable out)
throws IOException {
MessageLevel max = MessageLevel.values()[0];
SnippetProducer sp = new SnippetProducer(inputs, mc);
// HACK: do not commit
Map<MessageTypeInt, Integer> counts = Maps.newHashMap();
for (Message msg : sortMessages(mq.getMessages())) {
counts.put(
msg.getMessageType(),
Integer.valueOf(counts.containsKey(msg.getMessageType())
? counts.get(msg.getMessageType()) + 1
: 1));
MessageLevel level = msg.getMessageLevel();
if (level.compareTo(max) > 0) { max = level; }
String snippet = sp.getSnippet(msg);
out.append(
level.name() + " : " + msg.format(mc)
+ (snippet != null ? "\n" + snippet : "") + "\n");
}
List<Map.Entry<MessageTypeInt, Integer>> countsInOrder
= Lists.newArrayList(counts.entrySet());