private StyleSheet parseString(String fuzzString) throws Exception {
return css(fromString(fuzzString));
}
private String renderSnippets(Map<InputSource, String> srcs) {
SnippetProducer sr = new SnippetProducer(srcs, mc, 80);
List<Message> messages = new ArrayList<Message>(mq.getMessages());
Collections.sort(messages, new Comparator<Message>() {
public int compare(Message a, Message b) {
FilePosition fpa = firstFilePosition(a.getMessageParts());
FilePosition fpb = firstFilePosition(b.getMessageParts());
int delta = fpa.startCharInFile() - fpb.startCharInFile();
if (delta == 0) {
delta = fpa.endCharInFile() - fpb.endCharInFile();
}
return delta;
}
private FilePosition firstFilePosition(List<MessagePart> parts) {
if (parts.isEmpty()) { return FilePosition.UNKNOWN; }
MessagePart p0 = parts.get(0);
return p0 instanceof FilePosition
? (FilePosition) p0
: FilePosition.UNKNOWN;
}
});
List<String> snippets = new ArrayList<String>();
for (Message msg : messages) {
snippets.add(msg.getMessageLevel() + " : " + msg.format(mc));
snippets.add(sr.getSnippet(msg));
}
return Join.join("\n", snippets);
}