Package com.google.caja.reporting

Examples of com.google.caja.reporting.MessageLevel


      if (!tq.checkToken(Punctuation.SEMI)) {
        Token<JsTokenType> t = !tq.isEmpty() ? tq.peek() : null;
        if ((t == null || !continuesExpr(t.text)) && semicolonInserted()) {
          FilePosition semiPoint = FilePosition.endOf(tq.lastPosition());
          MessageLevel lvl = tq.isEmpty()
              || tq.lookaheadToken(Punctuation.RCURLY)
              ? MessageLevel.LOG : MessageLevel.LINT;
          mq.addMessage(MessageType.SEMICOLON_INSERTED, lvl, semiPoint);
        } else {
          tq.rewind(startOfDirective);
View Full Code Here


    if (tq.checkToken(Punctuation.SEMI)) { return; }
    // None found, so maybe do insertion.
    if (tq.isEmpty()) { return; }
    if (semicolonInserted()) {
      FilePosition semiPoint = FilePosition.endOf(tq.lastPosition());
      MessageLevel lvl = tq.isEmpty() || tq.lookaheadToken(Punctuation.RCURLY)
          ? MessageLevel.LOG : MessageLevel.LINT;
      mq.addMessage(MessageType.SEMICOLON_INSERTED, lvl, semiPoint);
    } else {
      tq.expectToken(Punctuation.SEMI)// Just used to throw an exception
    }
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)
          + ("".equals(snippet) ? "" : "\n" + snippet) + "\n");
    }

    List<Map.Entry<MessageTypeInt, Integer>> countsInOrder
        = Lists.newArrayList(counts.entrySet());
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

  /** 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)
          + ("".equals(snippet) ? "" : "\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

                fold = true;
                msgType = IhtmlMessageType.FOLDING_ELEMENT;
              }
            }

            MessageLevel msgLevel
                = ignore || fold ? MessageLevel.WARNING : msgType.getLevel();
            mq.getMessages().add(new Message(
                msgType, msgLevel, Nodes.getFilePositionFor(el), elKey));

            if (ignore) {
View Full Code Here

      if (!tq.checkToken(Punctuation.SEMI)) {
        Token<JsTokenType> t = !tq.isEmpty() ? tq.peek() : null;
        if ((t == null || !continuesExpr(t.text)) && semicolonInserted()) {
          FilePosition semiPoint = FilePosition.endOf(tq.lastPosition());
          MessageLevel lvl = tq.isEmpty()
              || tq.lookaheadToken(Punctuation.RCURLY)
              ? MessageLevel.LOG : MessageLevel.LINT;
          mq.addMessage(MessageType.SEMICOLON_INSERTED, lvl, semiPoint);
        } else {
          tq.rewind(startOfDirective);
View Full Code Here

    if (tq.checkToken(Punctuation.SEMI)) { return; }
    // None found, so maybe do insertion.
    if (tq.isEmpty()) { return; }
    if (semicolonInserted()) {
      FilePosition semiPoint = FilePosition.endOf(tq.lastPosition());
      MessageLevel lvl = tq.isEmpty() || tq.lookaheadToken(Punctuation.RCURLY)
          ? MessageLevel.LOG : MessageLevel.LINT;
      mq.addMessage(MessageType.SEMICOLON_INSERTED, lvl, semiPoint);
    } else {
      tq.expectToken(Punctuation.SEMI)// Just used to throw an exception
    }
View Full Code Here

      String xmlIdent = n.getNodeName();
      int colon = xmlIdent.indexOf(':');
      if (colon < 0) {  // Don't warn if no prefix
        return defaultNsUri;
      }
      MessageLevel level;
      String prefix = xmlIdent.substring(0, colon);
      Namespaces ns = Namespaces.HTML_DEFAULT.forPrefix(prefix);
      String nsUri;
      if (ns == null) {
        level = PluginMessageType.MISSING_XML_NAMESPACE.getLevel();
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.