Package com.google.caja.lexer

Examples of com.google.caja.lexer.TokenConsumer.noMoreTokens()


  public final void testRenderPostRemove2() {
    doRemove(1);
    StringBuilder sb = new StringBuilder();
    TokenConsumer tc = new JsPrettyPrinter(sb);
    root.render(new RenderContext(tc));
    tc.noMoreTokens();
    assertEquals(
        "$0: {\n"
        + "  $5: {\n"
        + "    6;\n"
        + "    7;\n"
View Full Code Here


      throws Exception {
    StringBuilder sb = new StringBuilder();
    TokenConsumer tc = new JsPrettyPrinter(sb);
    RenderContext rc = new RenderContext(tc);
    js(fromString(code)).children().get(0).render(rc);
    tc.noMoreTokens();
    assertEquals(code, expectedRendering, sb.toString());
  }

  private void assertMinified(String code, String expectedRendering)
      throws Exception {
View Full Code Here

      throws Exception {
    StringBuilder sb = new StringBuilder();
    TokenConsumer tc = new JsMinimalPrinter(sb);
    RenderContext rc = new RenderContext(tc);
    js(fromString(code)).children().get(0).render(rc);
    tc.noMoreTokens();
    assertEquals(code, expectedRendering, sb.toString());
  }

  private static void log(String testName, String code) {
    System.err.println();
View Full Code Here

    StringBuilder sb = new StringBuilder();
    TokenConsumer tc = new JsPrettyPrinter(sb);
    RenderContext rc = new RenderContext(tc);
    parseTree.render(rc);
    tc.noMoreTokens();
    sb.append('\n');

    String golden = TestUtil.readResource(getClass(), goldenFile);
    String actual = sb.toString();
    assertEquals(actual, golden, actual);
View Full Code Here

  private static String render(ParseTreeNode node) {
    StringBuilder sb = new StringBuilder();
    TokenConsumer tc = node.makeRenderer(sb, null);
    node.render(new RenderContext(tc));
    tc.noMoreTokens();
    return sb.toString();
  }

  /** Encapsulates information about a single input to the linter. */
  public static final class LintJob {
View Full Code Here

        "poolDecls", poolDecls,
        "cssSchema", cssSchema,
        "hasAliases", new BooleanLiteral(unk, hasAliases));
    TokenConsumer tc = js.makeRenderer(out, null);
    js.render(new RenderContext(tc));
    tc.noMoreTokens();
    out.append(";\n");
  }

  private static Statement joinDeclarations(
      @Nullable Statement decl, Declaration d) {
View Full Code Here

    } else {
      tc = new JsPrettyPrinter(new Concatenator(buf));
    }
    RenderContext rc = new RenderContext(tc);
    n.render(rc);
    tc.noMoreTokens();
    return buf.toString();
  }
}
View Full Code Here

        ? new JsPrettyPrinter(new Concatenator(rendered))
        : new JsMinimalPrinter(new Concatenator(rendered));
    cajoled.render(new RenderContext(tc)
        .withAsciiOnly(true)
        .withEmbeddable(true));
    tc.noMoreTokens();
    return rendered.toString();
  }

  private Element cajaStart(Document doc, String cajoledJs, boolean debug) {
    Element scriptElement = doc.createElement("script");
View Full Code Here

        ? new JsPrettyPrinter(new Concatenator(rendered))
        : new JsMinimalPrinter(new Concatenator(rendered));
    cajoled.render(new RenderContext(tc)
        .withAsciiOnly(true)
        .withEmbeddable(true));
    tc.noMoreTokens();
    return rendered.toString();
  }

  private Element cajaStart(Document doc, String cajoledJs, boolean debug) {
    Element scriptElement = doc.createElement("script");
View Full Code Here

        ? new JsPrettyPrinter(new Concatenator(rendered))
        : new JsMinimalPrinter(new Concatenator(rendered));
    cajoled.render(new RenderContext(tc)
        .withAsciiOnly(true)
        .withEmbeddable(true));
    tc.noMoreTokens();
    return rendered.toString();
  }

  private Element cajaStart(Document doc, String cajoledJs, boolean debug) {
    Element scriptElement = doc.createElement("script");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.