Package com.google.caja.reporting

Examples of com.google.caja.reporting.MessageContext


  public static String render(MessageQueue mq) {
    StringBuilder sb = new StringBuilder();
    for (Message m : mq.getMessages()) {
      try {
        m.format(new MessageContext(), sb);
      } catch (IOException e) {
        sb.append(e.toString());
      }
      sb.append("\n");
    }
View Full Code Here


  @Override
  public void setUp() throws Exception {
    super.setUp();
    cssSchema = CssSchema.getDefaultCss21Schema(
        new EchoingMessageQueue(
            new PrintWriter(System.err), new MessageContext()));
  }
View Full Code Here

        RhinoTestBed.class, "/js/envjs/env.js"));
    int injectHtmlIndex = inputs.size();

    List<Pair<String, InputSource>> scriptContent
        = new ArrayList<Pair<String, InputSource>>();
    MessageContext mc = new MessageContext();

    List<Element> scripts = new ArrayList<Element>();
    for (Node root : Nodes.childrenOf(html)) {
      if (root.getNodeType() == 1) {
        for (Element script : Nodes.nodeListIterable(
            ((Element) root).getElementsByTagNameNS(HTML_NS, "script"),
            Element.class)) {
          scripts.add(script);
        }
      }
    }
    for (Element script : scripts) {
      Attr src = script.getAttributeNodeNS(HTML_NS, "src");
      CharProducer scriptBody;
      if (src != null) {
        String resourcePath = src.getNodeValue();
        InputSource resource;
        if (resourcePath.startsWith("/")) {
          try {
            resource = new InputSource(
                RhinoTestBed.class.getResource(resourcePath).toURI());
          } catch (URISyntaxException ex) {
            throw new SomethingWidgyHappenedError(
                "java.net.URL is not a valid java.net.URI", ex);
          }
        } else {
          InputSource baseUri = Nodes.getFilePositionFor(html).source();
          resource = new InputSource(baseUri.getUri().resolve(resourcePath));
        }
        scriptBody = loadResource(resource);
      } else {
        scriptBody = textContentOf(script);
      }
      String scriptText;
      InputSource isrc = scriptBody.getSourceBreaks(0).source();
      // Add blank lines at the front so that Rhino stack traces have correct
      // line numbers.
      scriptText = prefixWithBlankLines(
        scriptBody.toString(0, scriptBody.getLimit()),
        Nodes.getFilePositionFor(script).startLineNo() - 1);
      scriptContent.add(Pair.pair(scriptText, isrc));
      mc.addInputSource(isrc);
      script.getParentNode().removeChild(script);
    }
    for (Pair<String, InputSource> script : scriptContent) {
      inputs.add(new Executor.Input(script.a, mc.abbreviate(script.b)));
    }

    // Set up the DOM.  env.js requires that location be set to a URI before it
    // creates a DOM.  Since it fetches HTML via java.net.URL and passes it off
    // to the org.w3c parser, we use a content: URL which is handled by handlers
View Full Code Here

    root = null;
  }

  public final void testFormatTree() throws Exception {
    StringBuilder sb = new StringBuilder();
    MessageContext mc = new MessageContext();
    root.formatTree(mc, 0, sb);
    assertEquals(
        "LabeledStmtWrapper : $0\n"
        + "  Block\n"
        + "    LabeledStmtWrapper : $1\n"
View Full Code Here

  }

  public final void testFormatTreePostReplace() throws Exception {
    doReplace();
    StringBuilder sb = new StringBuilder();
    MessageContext mc = new MessageContext();
    root.formatTree(mc, 0, sb);
    assertEquals(
        "LabeledStmtWrapper : $0\n"
        + "  Block\n"
        + "    LabeledStmtWrapper : $1\n"
View Full Code Here

  }

  public final void testFormatTreePostInsert() throws Exception {
    doInsert(5);
    StringBuilder sb = new StringBuilder();
    MessageContext mc = new MessageContext();
    root.formatTree(mc, 0, sb);
    assertEquals(
        "LabeledStmtWrapper : $0\n"
        + "  Block\n"
        + "    LabeledStmtWrapper : $1\n"
View Full Code Here

  }

  public final void testFormatTreePostInsert2() throws Exception {
    doInsert(1);
    StringBuilder sb = new StringBuilder();
    MessageContext mc = new MessageContext();
    root.formatTree(mc, 0, sb);
    assertEquals(
        "LabeledStmtWrapper : $0\n"
        + "  Block\n"
        + "    LabeledStmtWrapper : $9\n"
View Full Code Here

  }

  public final void testFormatTreePostInsert3() throws Exception {
    doInsert(-1);
    StringBuilder sb = new StringBuilder();
    MessageContext mc = new MessageContext();
    root.formatTree(mc, 0, sb);
    assertEquals(
        "LabeledStmtWrapper : $0\n"
        + "  Block\n"
        + "    LabeledStmtWrapper : $1\n"
View Full Code Here

  }

  public final void testFormatTreePostRemove() throws Exception {
    doRemove(5);
    StringBuilder sb = new StringBuilder();
    MessageContext mc = new MessageContext();
    root.formatTree(mc, 0, sb);
    assertEquals(
        "LabeledStmtWrapper : $0\n"
        + "  Block\n"
        + "    LabeledStmtWrapper : $1\n"
View Full Code Here

  }

  public final void testFormatTreePostRemove2() throws Exception {
    doRemove(1);
    StringBuilder sb = new StringBuilder();
    MessageContext mc = new MessageContext();
    root.formatTree(mc, 0, sb);
    assertEquals(
        "LabeledStmtWrapper : $0\n"
        + "  Block\n"
        + "    LabeledStmtWrapper : $5\n"
View Full Code Here

TOP

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

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.