Package com.google.caja.reporting

Examples of com.google.caja.reporting.Message


    FilePosition endPos = checkEnd(elementStack);

    DocumentFragment root = elementStack.getRootElement();
    Node firstChild = root.getFirstChild();
    if (firstChild == null || firstChild.getNodeType() != Node.ELEMENT_NODE) {
      throw new ParseException(new Message(
          DomParserMessageType.MISSING_DOCUMENT_ELEMENT, endPos));
    }

    // Check that there isn't any extraneous content after the root element.
    for (Node child = firstChild.getNextSibling(); child != null;
         child = child.getNextSibling()) {
      switch (child.getNodeType()) {
        case Node.COMMENT_NODE:
        case Node.DOCUMENT_TYPE_NODE:
          continue;
        case Node.TEXT_NODE:
          if ("".equals(child.getNodeValue().trim())) { continue; }
          break;
        default: break;
      }
      throw new ParseException(new Message(
          DomParserMessageType.MISPLACED_CONTENT,
          Nodes.getFilePositionFor(child)));
    }

    Nodes.setFilePositionFor(doc, Nodes.getFilePositionFor(root));
View Full Code Here


              // the browser.
              // At this point, we can be sure that createElement will not fail
              // because Html5ElementStack did not ignore this element.
              replacement = doc.createElement(qname);
            } else {
              throw new ParseException(new Message(
                  DomParserMessageType.IGNORING_TOKEN, pos,
                  MessagePart.Factory.valueOf("'" + qname + "'")), e);
            }
          }
          el.getParentNode().replaceChild(replacement, el);
View Full Code Here

                      Nodes.getFilePositionFor(attr),
                      MessagePart.Factory.valueOf("'" + qname + "'"));
        el.removeAttributeNode(attr);
        return;
      }
      throw new ParseException(new Message(DomParserMessageType.IGNORING_TOKEN,
          Nodes.getFilePositionFor(attr),
          MessagePart.Factory.valueOf("'" + qname + "'")), e);
    }

    newAttr.setValue(attr.getValue());
View Full Code Here

                              .NOT_IGNORING_DOWNLEVEL_REVEALED_COMMENT,
                          t.pos, MessagePart.Factory.valueOf(t.text));
          }
          break;
        default:
          throw new ParseException(new Message(
              MessageType.MALFORMED_XHTML, t.pos,
              MessagePart.Factory.valueOf(t.text)));
      }
    }
  }
View Full Code Here

    Token<HtmlTokenType> last;
    tokloop:
    while (true) {
      if (tokens.isEmpty()) {
        throw new ParseException(
            new Message(DomParserMessageType.UNCLOSED_TAG, start));
      }
      last = tokens.peek();
      switch (last.type) {
      case TAGEND:
        tokens.advance();
        break tokloop;
      case ATTRNAME:
        AttrStub a = parseAttrib(out);
        if (a != null) { attrs.add(a); }
        break;
      default:
        throw new ParseException(new Message(
            MessageType.MALFORMED_XHTML, FilePosition.span(start, last.pos),
            MessagePart.Factory.valueOf(last.text)));
      }
    }
    return last;
View Full Code Here

            MessagePart.Factory.valueOf(name.text));
        return null;
      }
      // XML does not allow valueless attributes.
      throw new ParseException(
          new Message(MessageType.MISSING_ATTRIBUTE_VALUE,
                      value.pos, MessagePart.Factory.valueOf(value.text)));
    } else {
      value = Token.instance(name.text, HtmlTokenType.ATTRVALUE, name.pos);
    }
    String rawValue = value.text;
View Full Code Here

    URI uri;
    try {
      uri = new URI(attr.getNodeValue());
    } catch (URISyntaxException ex) {
      mq.getMessages().add(
          new Message(PluginMessageType.MALFORMED_URL, MessageLevel.ERROR,
                      Nodes.getFilePositionFor(attr), a));
      return null;
    }
    return new ExternalReference(uri, Nodes.getFilePositionForValue(attr));
  }
View Full Code Here

    assertFalse(
        "Expected error, found none: " + error,
        mq.getMessages().isEmpty());

    StringBuilder messageText = new StringBuilder();
    Message firstError = null;
    for (Message m: mq.getMessages()) {
      if (m.getMessageLevel().compareTo(MessageLevel.WARNING) >= 0) {
        firstError = m;
      }
    }
    firstError.format(mc, messageText);
    assertTrue(
        "First error is not \"" + error + "\": " + messageText.toString(),
        messageText.toString().contains(error));
  }
View Full Code Here

              }
            }

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

            if (ignore) {
              assert p != null// ignore = true  ->  p != null above
              p.removeChild(el);
View Full Code Here

  void match(CssTree.Term term, CssPropertyPartType type, Name propertyName) {
    this.match = new Match(term, type, propertyName, this.match);
  }

  void warn(MessageTypeInt msgType, MessagePart... parts) {
    warning = new MessageSList(new Message(msgType, parts), this.warning);
  }
View Full Code Here

TOP

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

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.