CharSequence orig, MessageQueue mq, boolean visible) {
MessageContext mc = new MessageContext();
Map<InputSource, CharSequence> originalSrc = Maps.newHashMap();
originalSrc.put(is, orig);
mc.addInputSource(is);
SnippetProducer sp = new SnippetProducer(originalSrc, mc);
Element errElement = doc.createElement("ul");
// Style defined in gadgets.css
errElement.setAttribute("class", "gadgets-messages");
if (!visible) {
errElement.setAttribute("style", "display: none");
}
for (Message msg : mq.getMessages()) {
// Ignore LINT messages
if (MessageLevel.LINT.compareTo(msg.getMessageLevel()) <= 0) {
String snippet = sp.getSnippet(msg);
String messageText = msg.getMessageLevel().name() + ' ' +
html(msg.format(mc)) + ':' + snippet;
Element li = doc.createElement("li");
li.appendChild(doc.createTextNode(messageText));
errElement.appendChild(li);