Package com.google.caja.reporting

Examples of com.google.caja.reporting.MessageLevel


        compiledHtmlOutput = compiledDomOutput != null ?
            Nodes.render(compiledDomOutput) : "";
      }
    } finally {
      if (mc == null) { mc = new MessageContext(); }
      MessageLevel maxMessageLevel = dumpMessages(mq, mc, System.err);
      success &= MessageLevel.ERROR.compareTo(maxMessageLevel) > 0;
    }

    if (!writeFiles) {
      return success ? 0 : -1;
View Full Code Here


   * Dumps messages to the given output stream, returning the highest message
   * level seen.
   */
  static MessageLevel dumpMessages(
      MessageQueue mq, MessageContext mc, Appendable out) {
    MessageLevel maxLevel = MessageLevel.values()[0];
    for (Message m : mq.getMessages()) {
      MessageLevel level = m.getMessageLevel();
      if (maxLevel.compareTo(level) < 0) { maxLevel = level; }
    }
    MessageLevel ignoreLevel = null;
    if (maxLevel.compareTo(MessageLevel.LINT) < 0) {
      // If there's only checkpoints, be quiet.
      ignoreLevel = MessageLevel.LOG;
    }
    try {
      for (Message m : mq.getMessages()) {
        MessageLevel level = m.getMessageLevel();
        if (ignoreLevel != null && level.compareTo(ignoreLevel) <= 0) {
          continue;
        }
        String levelName = level.name();
        out.append(levelName);
        if (levelName.length() < 7) {
          out.append("       ".substring(levelName.length()));
        }
        out.append(": ");
View Full Code Here

    }
    return output.toString();
  }

  public static MessageLevel maxMessageLevel(MessageQueue mq) {
    MessageLevel max = MessageLevel.values()[0];
    for (Message msg : mq.getMessages()) {
      MessageLevel lvl = msg.getMessageLevel();
      if (max.compareTo(lvl) < 0) { max = lvl; }
    }
    return max;
  }
View Full Code Here

  }

  private void runTestCssParser(
      CharProducer css, CharProducer golden, boolean tolerant)
      throws Exception {
    MessageLevel lvl = tolerant
        ? MessageLevel.WARNING : MessageLevel.FATAL_ERROR;
    CssTree.StyleSheet stylesheet = new CssParser(
        CssParser.makeTokenQueue(css.clone(), mq, false), mq, lvl)
        .parseStyleSheet();
    assertCloneable(stylesheet);
View Full Code Here

      ex.toMessageQueue(errs);
    }

    out.flush();

    MessageLevel maxMessageLevel = MessageLevel.values()[0];
    for (Message msg : errs.getMessages()) {
      if (msg.getMessageLevel().compareTo(maxMessageLevel) >= 0) {
        maxMessageLevel = msg.getMessageLevel();
      }
    }
    return maxMessageLevel.compareTo(MessageLevel.ERROR) < 0;
  }
View Full Code Here

  /** 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());
View Full Code Here

                ((CssTree.IdentLiteral) term.getExprAtom()).getValue());
            if (!stdColorMatcher.matcher(colorName.getCanonicalForm() + " ")
                .matches()) {
              FilePosition pos = term.getExprAtom().getFilePosition();
              CssTree.HashLiteral replacement = colorHash(pos, colorName);
              MessageLevel lvl = MessageLevel.LINT;
              if (replacement == null) {
                lvl = MessageLevel.ERROR;
                replacement = CssTree.HashLiteral.hex(pos, 0, 3);
              }
              term.replaceChild(replacement, term.getExprAtom());
View Full Code Here

      }
    }
    rc.getOut().noMoreTokens();
    out.flush();

    MessageLevel maxMessageLevel = MessageLevel.values()[0];
    for (Message msg : errs.getMessages()) {
      if (msg.getMessageLevel().compareTo(maxMessageLevel) >= 0) {
        maxMessageLevel = msg.getMessageLevel();
      }
    }
    return maxMessageLevel.compareTo(MessageLevel.ERROR) < 0;
  }
View Full Code Here

  private void fails(String css) throws Exception {
    CssTree t = css(fromString(css), true);
    mq.getMessages().clear();
    CssValidator v = makeCssValidator(mq);
    assertTrue(css, !v.validateCss(ac(t)));
    MessageLevel maxLevel = MessageLevel.values()[0];
    for (Message msg : mq.getMessages()) {
      MessageLevel level = msg.getMessageLevel();
      if (level.compareTo(maxLevel) > 0) { maxLevel = level; }
    }
    // If there is a failure, there should be an error or greater on the queue.
    assertTrue(maxLevel.name(), MessageLevel.ERROR.compareTo(maxLevel) <= 0);
  }
View Full Code Here

TOP

Related Classes of com.google.caja.reporting.MessageLevel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.